On Friday 10 December 2010 5:23:42 pm Jason Pell wrote: > Hi, > Not strictly cxf but I was hoping for a solution to this to use in cxf > interceptors so thought I would ask. > > I know it's possible to chain a reader to a writer. But what I want to do > is take the xmlstreamreader opened by the staxininterceptor and run a xsl > transformation that would result in a outgoing xmlstreamwriter. I want to > chain this writer to a new reader to replace the original reader so none > of the interceptors after are the wiser?
The only way I can really think to do this is by transforming the XMLStreamReader into a DOM and wrappering the DOM with a new XMLStreamReader. (or use a temporary file and input/output streams if very large). There are a bunch of utilities in our org.apache.cxf.staxutils package that can help. If you have the XMLStreamReader, you can do: Source source = new StaxSource(reader); to create a javax.xml.transform.Source object to feed into the XSLT. Transform to a DOMSource or StreamSource. Grab the DOM or Stream and call the StaxUtils.createXMLStreamReader(...) with it and reset the content in the message. Hope that helps! Dan > > I have done some searching but stax is new for me and not sure if this is > an easy ask or a pain or impossible? > > Any pointers or ideas will be gratefully received > > Sent from my iPhone -- Daniel Kulp [email protected] http://dankulp.com/blog
