<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="sourcedocs" page="XInclude" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: XInclude processing</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: XInclude processing"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>XInclude processing</h1>
      <p>If you are using Xerces as your XML parser, you can have Xerces expand any XInclude
directives.</p>
      <p>The <code>-xi</code> 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 <code>doc()</code> function or by mechanisms such as
<code>xsl:include</code> and <code>xs:include</code>.</p>
      <p>From the Java API, the equivalent is to call <code>setXInclude()</code> on the <code>Configuration</code> object,
or to set the attribute denoted by <a class="bodylink" href="../javadoc/net/sf/saxon/lib/FeatureKeys.html#XINCLUDE"><code>FeatureKeys.XINCLUDE</code></a> to <code>Boolean.TRUE</code> on the
<code>TransformerFactory</code>.</p>
      <p>XInclude processing can be requested at a per-document level by creating an <a class="bodylink" href="../javadoc/net/sf/saxon/lib/AugmentedSource.html"><code>AugmentedSource</code></a> and calling
its <code>setXIncludeAware()</code> method. The corresponding method is also recognized on Saxon's implementation of the
JAXP <code>DocumentBuilderFactory</code>. When the <code>doc()</code> or <code>document()</code> or <code>collection()</code>
function is called from an XPath expression, XInclude processing can be enabled by including <code>xinclude=yes</code>
among the query parameters in the URI.</p>
      <p>It is also possible to switch on XInclude processing (for all documents) by setting the system property:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>
-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=
    org.apache.xerces.parsers.XIncludeParserConfiguration
</code>
         </pre>
      </div>
      <p>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 <a href="http://xincluder.sourceforge.net/" class="bodylink">http://xincluder.sourceforge.net/</a>, and
you can incorporate it into your application as described at <a class="bodylink" href="../sourcedocs/input-filters.xml">Writing Input Filters</a>.</p>
      <p>On the .NET platform, there is a customized <code>XmlReader</code> that performs XInclude processing available at
<a href="http://www.xmlmvp.org/xinclude/index.html" class="bodylink">http://www.xmlmvp.org/xinclude/index.html</a>. You can supply 
this as an argument to the method <code>Build(XmlReader parser)</code> in the <code>DocumentBuilder</code> class
of the .NET Saxon API.</p>
      <p>For further information on using XInclude, see 
<a href="http://www.sagehill.net/docbookxsl/Xinclude.html" class="bodylink">http://www.sagehill.net/docbookxsl/Xinclude.html</a></p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="controlling-parsing.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>