IntroductionXInclude 1.0 is a simple language for XML inclusions. It's main use is to specify that content from a target XML document must be included at a certain place within a source XML document. By default, XInclude processing is not automatic in Orbeon Forms, and must be enabled explicitly, except in a few cases described below. Explicit XInclude handlingThere are two ways to use XInclude explicitly in Orbeon Forms: At parsing timeThe XML parser included with Orbeon Forms is able to process XInclude instructions when an XML file is being parsed (i.e. loaded) into Orbeon Forms. This is usually controlled with the URL generator. Example:
With the XInclude processorThe processor documented here allows to explicitly control the use of XInclude instructions in any XML document, including documents that are not loaded with the URL generator, but dynamically generated. Example:
This example is equivalent to the example using the URL generator.
NOTE: The correct namespace to use for XInclude 1.0 is
http://www.w3.org/2001/XInclude.
When using XInclude to perform inclusions, with the XInclude processor or during parsing, be
sure to use this correct namespace instead of the older
http://www.w3.org/2003/XInclude, which is used by some XML parsers (see next
entry). Note that the correct version has the older year, 2001, instead of the
newer year, 2003.
Implicit XInclude handlingXInclude processing is implicit in the following cases:
Note that, in particular, XInclude processing is not implicit in the following cases:
XInclude processorInputs and outputs
Config input
The
The main XInclude element is
This is a fragment of an XForms page using XInclude, in a resource named
With the example above, the resource
The processor is configured as follows:
The result of the inclusion on the
Notice how the
An included document may in turn use further
It is possible to tell the XInclude processor not to produce
This produces:
Notice how there is no longer an
NOTE:
The XInclude processor only supports
xi:include with the href attribute
and an optional parse attribute set to the constant xml. Other features of
XInclude such as the xpointer, encoding, accept or
accept-language attributes, and xi:fallback are not supported. It is
planned to enhance the XInclude processor over time to support those features.
User-defined inputsUser-defined inputs allow the XInclude processor do include dynamically generated XML documents. For example, connecting the XInclude processor as follows:
It is possible to include the XML document available on the custom
This makes the XInclude processor very versatile as a simple template processor.
The xpointer attribute[SINCE: 2011-03-10] The <xi:include> element supports the xpointer attribute with the xpath() scheme.This allows fine-grained control of what exactly, in the included document, gets inserted into the final document. You simply provide an XPath 2.0 expression within the xpath() scheme:
NOTE: When the xpointer attribute is provided, the included document is first entirely loaded into memory before the XPath expression is applied. This can have a negative performance impact.XML external entitiesXML external entities are a relatively rarely used feature of XML, which allows you to specify, at the top of your XML document, a mapping between a name and a file. For example:
Here, anytime you write &bar;, the content of the bar.xml file is loaded and replaces the occurrence of &bar;. This allows you to perform inclusions, but without the use of XInclude.By default, XML documents loaded by the XInclude processor process XML external entities. You can configure the XInclude processor to ignore external entities by using the optional attributes input:
NOTE: This setting does not apply to the config input, which, when it reaches the XInclude processor, has already been parsed.XML external entities or XPointer?Both XML external entities or the
xpointer attribute allow doing more than simply include a full XML document into another. Processing is done by different pieces of software:
Use XPointer when:
Use external entities when:
Whenever possible, we recommend using XInclude rather than external entities.
|