SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
| Handling Source Documents
| Source Documents on the Command Line
| Collections
| Building a Source Document from an application
| Writing input filters
» | XInclude processing
| Saxon and XML 1.1
| JAXP Source Types
| Third-party Object Models: DOM, JDOM, XOM, and DOM4J
| Choosing a Tree Model
| The PTree File Format
| Validation of Source Documents
| Whitespace Stripping in Source Documents
| Streaming of Large Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# 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.XIncludeParserConfiguration

An 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 at Writing Input Filters.

On the .NET platform, there is a customized `XmlReader` that performs XInclude processing available at http://www.xmlmvp.org/xinclude/index.html. 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

Next