XInclude processing
If you are using Xerces as your XML parser, you can have Xerces expand any XInclude directives.
The -xi
option on the command line causes XInclude processing to be applied to
all input XML documents. This includes source documents, stylesheets, and schema documents
listed on the command line, and also those loaded indirectly for example by calls on the
doc()
function or by mechanisms such as xsl:include
and
xs:include
.
From the Java API, the equivalent is to call setXInclude()
on the
Configuration
object, or to set the attribute denoted by FeatureKeys.XINCLUDE to
Boolean.TRUE
on the TransformerFactory
.
XInclude processing can be requested at a per-document level by creating an AugmentedSource and calling its
setXIncludeAware()
method. The corresponding method is also recognized on
Saxon's implementation of the JAXP DocumentBuilderFactory
. When the
doc()
or document()
or collection()
function is
called from an XPath expression, XInclude processing can be enabled by including
xinclude=yes
among the query parameters in the URI.
It is also possible to switch on XInclude processing (for all documents) by setting the system property:
-Dorg.apache.xerces.xni.parser.XMLParserConfiguration= org.apache.xerces.parsers.XIncludeParserConfigurationAn alternative approach is to incorporate an XInclude processor as a SAX filter in the input pipeline. You can find a suitable SAX filter at http://xincluder.sourceforge.net/, and you can incorporate it into your application as described in Writing Input Filters.
On the .NET platform, there is a customized XmlReader
that performs XInclude
processing available at http://mvpxml.codeplex.com. You can supply this as an argument to the method
Build(XmlReader parser)
in the DocumentBuilder class of the .NET Saxon API.
For further information on using XInclude, see http://www.sagehill.net/docbookxsl/Xinclude.html.