@Test void getXMLStreamWriterWithSAXREsult() throws TransformerConfigurationException, XMLStreamException { TransformerFactory tf = TransformerFactory.newInstance(); if (!tf.getFeature(SAXTransformerFactory.FEATURE)) { throw new RuntimeException("Did not find a SAX-compatible TransformerFactory."); } StringWriter output = new StringWriter(); SAXTransformerFactory stf = (SAXTransformerFactory) tf; TransformerHandler th = stf.newTransformerHandler(); th.setResult(new StreamResult(output)); XMLStreamWriter writer = StAXUtils.getXMLStreamWriter(new SAXResult(th)); writer.writeStartDocument(); writer.writeStartElement("element"); writer.writeAttribute("attribute", "value"); writer.writeCharacters("characters"); writer.writeCData("cdata"); writer.writeEndElement(); writer.writeEndDocument(); assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<element attribute=\"value\">" + "characters" + "<![CDATA[cdata]]>" + "</element>", output.getBuffer().toString()); }
public static XMLStreamWriter getXMLStreamWriter(Result result) throws XMLStreamException { return getXMLStreamWriter(XML_OUTPUT_FACTORY, result); }
StAXUtils { public static XMLStreamWriter getXMLStreamWriter(Result result) throws XMLStreamException { return getXMLStreamWriter(XML_OUTPUT_FACTORY, result); } }
StAXUtils { public static XMLStreamWriter getXMLStreamWriter(Result result) throws XMLStreamException { return getXMLStreamWriter(XML_OUTPUT_FACTORY, result); } private  StAXUtils(); }
StAXUtils { public static XMLStreamWriter getXMLStreamWriter(Result result) throws XMLStreamException { return getXMLStreamWriter(XML_OUTPUT_FACTORY, result); } private  StAXUtils(); static XMLStreamReader getXMLStreamReader(Source source); static XMLStreamReader getXMLStreamReader(XMLInputFactory factory, Source source); static XMLEventReader getXMLEventReader(Source source); static XMLStreamWriter getXMLStreamWriter(Result result); static XMLStreamWriter getXMLStreamWriter(XMLOutputFactory factory, Result result); static int skipElement(XMLStreamReader xmlReader); }
StAXUtils { public static XMLStreamWriter getXMLStreamWriter(Result result) throws XMLStreamException { return getXMLStreamWriter(XML_OUTPUT_FACTORY, result); } private  StAXUtils(); static XMLStreamReader getXMLStreamReader(Source source); static XMLStreamReader getXMLStreamReader(XMLInputFactory factory, Source source); static XMLEventReader getXMLEventReader(Source source); static XMLStreamWriter getXMLStreamWriter(Result result); static XMLStreamWriter getXMLStreamWriter(XMLOutputFactory factory, Result result); static int skipElement(XMLStreamReader xmlReader);  }