servicemix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Renaud Bruyeron (JIRA)" <>
Subject [jira] Commented: (SM-993) StaxSource + FragmentStreamReader interference with TRaX
Date Wed, 04 Jul 2007 15:33:32 GMT


Renaud Bruyeron commented on SM-993:

After applying the patch:
$ cd core/servicemix-core
$ mvn -Dtest=FragmentStreamReaderTest

To see that saxon + StreamResult works, you need to modify the servicemix-core pom to add
saxon to the classpath:

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);
        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);
        // output must be a document
        // there should be more than one element in the output document
        //assertTrue(result.getNode().getChildNodes().getLength() > 0);

You should see this in the output:
<?xml version="1.0" encoding="UTF-8"?>
<SubmitReq xmlns="">
   <Content allowAdaptations="true" href="cid:mmscontent"/>

> StaxSource + FragmentStreamReader interference with TRaX
> --------------------------------------------------------
>                 Key: SM-993
>                 URL:
>             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.

View raw message