Convert StAX source to Java

I have code like:

XMLInputFactory xif = XMLInputFactory.newInstance() TransformerFactory tf = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null) Transformer t = tf.newTransformer() DOMResult result = new DOMResult() t.transform(new StAXSource(reader), result) 

Which causes the following error:

Caught: javax.xml.transform.TransformerException: cannot convert source of type javax.xml.transform.stax.StAXSource

The reader object is of type com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl

+7
source share
1 answer

So I was stupidly trying to make a mistake. This fixed this:

 System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); 
+5
source

All Articles