users@jaxb.java.net

How to marshal XML fragments with JAXB

From: Arek Stryjski <developer_at_krzyzowki.net.pl>
Date: Thu, 24 Apr 2003 16:45:20 +0200

Hello,

I have Object unashamed from XML. I would like to insert part of this
object in another XML document. I'm using Cocoon Transformer for this. In
startElement then I detect element which I would like replace I would like
to write something like this:

Marshaller m = jc.createMarshaller();
m.marshal(myElem, contentHandler);

However this method try to marshal it as whole document with:
<?xml version="1.0" encoding="UTF-8" ?>
This probably case problems for next Transformer.

I have this problem in Cocoon and with SAX. I found simple solution by
palcing another ContentHandler which works as a filter, but there should be
some general solution to marshal JAXB objects as XML fragments, not whole
documents. However I can't found it.

Thanks for any help
Arek Stryjski