users@jaxb.java.net

marshal using a pull model

From: Nico Snosloski <snosloski_at_yahoo.com>
Date: Wed, 9 Nov 2005 14:55:17 -0800 (PST)

Hello Experts,
 
I'd like to be able to marshal a JAXB2 bound object incrementally into a proprietary format using a pull model, similar to the way in which an XMLStreamReader gives you control over the parsing an XML document. I also have the added requirements of a) accessing the corresponding JAXB bound object and b) skipping a sub tree while processing. I'm currently using a ContentHandler to accomplish this, but this has the following downsides for my use case:
 
1) the entire binding hierarchy (from the root starting point) is traversed, which can inefficient in my case because it forces me to generate my proprietary format for the entire tree while only parts of it will be used. I would like to traverse a sub tree of the binding hierarchy only when necessary, with the ability to skip a sub tree if the information within it is not needed.
2) the corresponding JAXB2 object is difficult to get to from my ContentHandler callbacks. I'm using a beforeMarshaller callback which solves most of this problem, but it is not called for built-in types, so some hacks were necessary to overcome this.
 
Ideally, I'd like to have a tree iterator with which I could walk the JAXB2 bound objects while skipping subtrees when necessary. I'd need to be able to retrieve the runtime type information at each point as well (i.e. qname, attribute/element). Is there something like this already available? If not, is my best bet to use the reflection library API? Any more example usages of this that could help guide me? How will the performance of this API compare to my existing ContentHandler usage (assuming a full traversal in both cases)?
 
Thanks in advance for any advice. Regards,
 
-Nico




                
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.