Reading documents containing XInclude statements

The XML Data Binding Libraries do not natively support XInclude, however some of the underlying XML Parsers do, depending on the language you are working with.

Their are a number of Xinclude implementations which are free and easy to use.

The MVP.XML Project for .Net - http://mvp-xml.sourceforge.net/xinclude/

This allows you to read a source document into an XmlDocument link this

XmlReader reader = new XIncludingReader(XmlReader.Create("source.xml"));
XmlDocument doc = new XmlDocument();    
doc.Load(reader);

The complete XmlDocument can then be read into generated data binding objects like this.

MyRootElm root = new MyRootElm();
root.FromXmlElement(doc.DocumentElement);

Also see Combining XML Documents with XInclude 
 

Java
XInclude support was included from Java 1.5, and can be enabled like this

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
factory
.setXIncludeAware(true);
 


Add Feedback