XInclude and JAXB
Posted by kohsuke on January 13, 2006 at 4:49 PM EST
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:
import com.elharo.xml.xinclude.XIncludeFilter; import javax.xml.bind.*; JAXBContext context = ...; uh = context.createUnmarshaller().getUnmarshallerHandler(); // create a parser spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); xr = spf.newSAXParser().getXMLReader(); // hook things up XIncludeFilter includer = new XIncludeFilter(); includer.setParent(xr); includer.setContentHandler(uh); // and run! includer.parse(xmlToParse);
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- kohsuke's blog
- 1839 reads





