Posted by kohsuke
on January 13, 2006 at 1:49 PM PST
Someone asked me how to use JAXB in conjunction with XInclude, so here it goes.
XInclude is really just a very simple filtering. So all you need is a bit of SAX programming to put together pieces in the right order. The idea is that you parse XML, run it through XInclude filter (that expands inclusion), then feed it to JAXB unmarshaller. By using xincluder , it would be:
JAXBContext context = ...;
uh = context.createUnmarshaller().getUnmarshallerHandler();
// create a parser
spf = SAXParserFactory.newInstance();
xr = spf.newSAXParser().getXMLReader();
// hook things up
XIncludeFilter includer = new XIncludeFilter();
// and run!