From: Todd B. <tod...@gm...> - 2011-10-03 16:13:57
|
I'm not sure if what I'm asking is possible without a custom Marshaller, but I thought I'd ask in case I missed something in the documentation. I've got an xml document that looks something like this: <foo> <bar .../> <bar .../> .... </foo> where foo is the root element, and the document contains several (possibly on the order of thousands) of bars. I'm receiving the Java objects that will be mapped to bar from another source across the wire, so it's possible that they'll trickle in over time. I can marshal the Foo element without issue, but, when using the standard MarshallingContext methods, that involves constructing an entire Bar collection. What I'd like to do is write out the root element (if need b,e this can be at the lower level with something like an IXMLWriter, and calls to the context's startDocument() and endDocument() method) and then marshal the bar elements as they arrive. It'd be ideal to it in this fashion: IBindingFactory barFact = BindingDirectory.getFactory(Bar.class); IMarshallingContext barCtxt = barFact.createMarshallingContext(); ... barCtxt.marshalDocument(barInstance) so I can marshall the Bar instances on a piecemeal basis. It appears, though, that binding.xml file doesn't define a mapping for Bar, only Foo as the root element, so when I attempt to run the BindingDirectory.getFactory(Bar.class) code, I get an error that the binding isn't available. Is there a way I can marshal the Bar element without having to manually make changes to the binding.xml document or without writing a custom marshaller? My goal is to take the source schema and the customized schema-set.xml (or some other customization file), generate the appropriate POJOs, and write the appropriate XML so that my code has to know as little about the schema as possible. Thanks, Todd |