[ https://issues.apache.org/activemq/browse/SM-993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_39606 ]
Renaud Bruyeron commented on SM-993: ------------------------------------ After applying the patch: {code} $ cd core/servicemix-core $ mvn -Dtest=FragmentStreamReaderTest {code} To see that saxon + StreamResult works, you need to modify the servicemix-core pom to add saxon to the classpath: {code:title=core/servicemix-core/pom.xml} <dependency> <groupId>net.sf.saxon</groupId> <artifactId>saxon</artifactId> <version>8.8</version> <scope>test</scope> </dependency> <dependency> <groupId>net.sf.saxon</groupId> <artifactId>saxon-dom</artifactId> <version>8.8</version> <scope>test</scope> </dependency> {code} Then change the testcase like so: {code:title=switch to stream mode} public void testStaxSourceOnFragmentStream() throws Exception { InputStream is = getClass().getResourceAsStream("mm7.xml"); InputStream xlsis = getClass().getResourceAsStream("clean-namespace.xsl"); XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); XMLStreamReader xsr = factory.createXMLStreamReader(is); xsr.nextTag(); StaxSource ss = new StaxSource(new FragmentStreamReader(xsr)); Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xlsis)); //DOMResult result = new DOMResult(); StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); transformer.transform(ss, result); System.out.println(sw.toString()); // output must be a document //assertTrue(Document.class.isAssignableFrom(result.getNode().getClass())); // there should be more than one element in the output document //assertTrue(result.getNode().getChildNodes().getLength() > 0); } {code} You should see this in the output: {code} <?xml version="1.0" encoding="UTF-8"?> <SubmitReq xmlns="http://www.firsthop.com/specs/MM7-extended/MM7-extended-1-2"> <MM7Version>5.3.0</MM7Version> <SenderIdentification> <VASPID>yo</VASPID> <VASID>dude</VASID> <SenderAddress> <Number>33611111125</Number> </SenderAddress> </SenderIdentification> <Recipients> <To> <Number>33601020304</Number> </To> </Recipients> <ServiceCode>9999</ServiceCode> <MessageClass>Personal</MessageClass> <TimeStamp>2007-07-04T11:49:38.260Z</TimeStamp> <DeliveryReport>false</DeliveryReport> <Content allowAdaptations="true" href="cid:mmscontent"/> </SubmitReq> {code} > StaxSource + FragmentStreamReader interference with TRaX > -------------------------------------------------------- > > Key: SM-993 > URL: https://issues.apache.org/activemq/browse/SM-993 > Project: ServiceMix > Issue Type: Bug > Components: servicemix-core > Affects Versions: 3.1.1 > Environment: JDK5 > Reporter: Renaud Bruyeron > Attachments: patch.txt > > > My use-case is this: > * a message comes in via an http:endpoint - it is a soap with attachment > message, and thus the body is stored in a SoapMessage as a StaxSource, and a > FragmentStreamReader is used to cut out the SOAP envelope and only keep the > content of the soap message. > * I try to apply an XSL on this body directly - I notice that it fails > (output document is empty) > * if I switch to saxon (instead of the default TrAx=xalan 2.7.0), it kind of > works if I use a StreamResult, but not if I use a DOMResult: saxon complains > that something is doing some unspeakable deed with namespaces ;-) > I narrowed this down to the FragmentStreamReader, and wrote a simple testcase > that shows the bug. However I can't see what's throwing off xalan/saxon, I am > not familiar enough with Stax, therefore I don't have a fix. > The testcase includes: an XML document, an XSL stylesheet, and a new testcase > in FragmentStreamReaderTest -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.