Contact Free trial Login

XmlToXMLStreamReader Transformer

The XmlToXMLStreamReader transformer converts XML representations to a StAX XMLStreamReader. XMLStreamReaders allow XML to be parsed as a series of events that are "pulled" from the stream. It is very efficient.

This transformer supports the following input formats:

  • javax.xml.transform.Source.class

  • org.xml.sax.InputSource.class

  • org.dom4j.Document.class

  • org.w3c.dom.Document.class

  • org.w3c.dom.Element.class

  • org.mule.module.xml.transformer.DelayedResult.class

  • String

  • byte[]

  • InputStream


To use the transformer, you must declare a custom transformer element:

<custom-transformer name="XmlToXSR" class="org.mule.module.xml.transformer.XmlToXMLStreamReader"/>

You can also create a "reversible" XMLStreamReader:

<custom-transformer name="XmlToXSR" class="org.mule.module.xml.transformer.XmlToXMLStreamReader">
   <property key="reversible" value="true"/>

This allows you to cache XML events and replay them:

MuleMessage message = ...;
ReversibleXMLStreamReader xsr = (ReversibleXMLStreamReader) message.getPayload();

// start caching events

// parse....
while (...) {; }

// Go back to the beginning of the XML document


// Don't cache events any more

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.