@Test public void testStAXSerializer() throws TTException, XMLStreamException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final XMLSerializerBuilder builder = new XMLSerializerBuilder(holder.getSession(), out); builder.setDeclaration(false); final XMLSerializer xmlSerializer = builder.build(); xmlSerializer.call(); final INodeReadTrx rtx = new NodeReadTrx(holder.getSession().beginBucketRtx(holder.getSession().getMostRecentVersion())); StAXSerializer serializer = new StAXSerializer(new DescendantAxis(rtx), rtx); final StringBuilder strBuilder = new StringBuilder(); boolean isEmptyElement = false; while (serializer.hasNext()) { XMLEvent event = serializer.nextEvent(); switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); break; case XMLStreamConstants.START_ELEMENT: emitElement(event, strBuilder); if (serializer.peek().getEventType() == XMLStreamConstants.END_ELEMENT) { strBuilder.append("/>"); isEmptyElement = true; } else { strBuilder.append('>'); } break; case XMLStreamConstants.END_ELEMENT: if (isEmptyElement) { isEmptyElement = false; } else { emitQName(true, event, strBuilder); strBuilder.append('>'); } break; case XMLStreamConstants.CHARACTERS: strBuilder.append(((Characters)event).getData()); break; } } assertEquals(out.toString(), strBuilder.toString()); holder.getNRtx().moveTo(ROOT_NODE); serializer = new StAXSerializer(new DescendantAxis(rtx), rtx); String elemText = null; if (serializer.hasNext()) { serializer.next(); elemText = serializer.getElementText(); } assertEquals("oops1foooops2baroops3", elemText); checkForException(serializer); if (serializer.hasNext()) { serializer.next(); elemText = serializer.getElementText(); } assertEquals("foo", elemText); checkForException(serializer); if (serializer.hasNext()) { serializer.next(); elemText = serializer.getElementText(); } assertEquals("", elemText); checkForException(serializer); checkForException(serializer); checkForException(serializer); if (serializer.hasNext()) { serializer.next(); elemText = serializer.getElementText(); } assertEquals("bar", elemText); if (serializer.hasNext()) { serializer.next(); elemText = serializer.getElementText(); } assertEquals("", elemText); checkForException(serializer); checkForException(serializer); checkForException(serializer); checkForException(serializer); checkForException(serializer); rtx.close(); }
public StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx) { this(paramAxis, pRtx, true); }
StAXSerializer implements XMLEventReader { public StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx) { this(paramAxis, pRtx, true); } }
StAXSerializer implements XMLEventReader { public StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx) { this(paramAxis, pRtx, true); } StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx);  StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx, final boolean paramCloseRtx); }
StAXSerializer implements XMLEventReader { public StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx) { this(paramAxis, pRtx, true); } StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx);  StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx, final boolean paramCloseRtx); @Override void close(); @Override String getElementText(); @Override Object getProperty(final String mName); @Override boolean hasNext(); @Override XMLEvent nextEvent(); @Override XMLEvent nextTag(); @Override XMLEvent peek(); @Override Object next(); @Override void remove(); }
StAXSerializer implements XMLEventReader { public StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx) { this(paramAxis, pRtx, true); } StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx);  StAXSerializer(final AbsAxis paramAxis, final INodeReadTrx pRtx, final boolean paramCloseRtx); @Override void close(); @Override String getElementText(); @Override Object getProperty(final String mName); @Override boolean hasNext(); @Override XMLEvent nextEvent(); @Override XMLEvent nextTag(); @Override XMLEvent peek(); @Override Object next(); @Override void remove();  }