On Aug 10, 2010, at 3:42 PM, bmraczk wrote:
>
> Is there an example of using streaming xml in jersey
>
There is no example with JAXB. Do you want to manage the unmarshalling
of a large XML document in chunks binding sub-elements to a JAXB beans?
If so it is possible with StAX, but i just realized we have an
oversight in Jersey and it is not possible to inject an XmlStreamReader.
But you can do this:
...
@POST
pubiic .... post(InputStream in, @Context
Injectable<XMLInputFactory> xif) {
XMLStreamReader r = xif.getValue().createXMLStreamReader(in);
// loop through reader and marshall sub parts to JAXB beans
}
For marshalling it should be possible to do something similar
XMLStreamWriter in conjunction with JAXB marshalling and
StreamingOutput [1]. Just make sure you set the fragment property of
the marshaller to true
Paul.
[1]
https://jsr311.dev.java.net/nonav/releases/1.1/javax/ws/rs/core/StreamingOutput.html