|
|||||||||||||||||
OPS User Guide
|
XInclude Processor1. 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. 2. Note About XInclude in Orbeon PresentationServerBy default, XInclude processing is not automatic in OPS, and must be enabled explicitly, except in a few cases described below. 2.1. Explicit XInclude HandlingThere are two ways to use XInclude explicitly in OPS:
2.2. Implicit XInclude HandlingXInclude processing is implicit in the following cases:
It must be noted that, in particular, XInclude processing is not implicit in the following cases:
3. Inputs and Outputs
4. Usage4.1. Config Input
The
The main XInclude element is
This is a fragment of an XForms page using XInclude, in a resource named
<xhtml:html> <xhtml:head> <xhtml:title>XForms Text Controls</xhtml:title> <xforms:model id="main-model"> <xforms:instance id="instance"> <!-- This is where the inclusion is performed --> <xi:include href="main-xforms-instance.xml"/> </xforms:instance> </xforms:model> </xhtml:head>... </xhtml:html>
With the example above, the resource
<instance> <age>35</age> <secret>42</secret> <textarea>The world is but a canvas for the imagination.</textarea> <label>Hello, World!</label> <date>2004-01-07</date>... </instance>
The processor is configured as follows:
<p:processor name="oxf:xinclude" xmlns:p="http://www.orbeon.com/oxf/pipeline"> <p:input name="config" href="view.xhtml"/> <p:output name="data" id="result"/> </p:processor>
The result of the inclusion on the
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xhtml:head> <xhtml:title>XForms Text Controls</xhtml:title> <xforms:model id="main-model" xmlns:xforms="http://www.w3.org/2002/xforms"> <xforms:instance id="instance"> <instance xml:base="oxf:/examples/xforms/xforms-controls/main-xforms-instance.xml"> <age>35</age> <secret>42</secret> <textarea>The world is but a canvas for the imagination.</textarea> <label>Hello, World!</label> <date>2004-01-07</date>... </instance> </xforms:instance> </xforms:model> </xhtml:head>... </xhtml:html>
Notice how the
An included document may in turn use further 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.
4.2. User-Defined InputsUser-defined inputs allow the XInclude processor do include dynamically generated XML documents. For example, connecting the XInclude processor as follows:
<p:processor name="oxf:xinclude" xmlns:p="http://www.orbeon.com/oxf/pipeline"> <p:input name="config" href="view.xhtml"/> <p:input name="my-dynamic-content" href="#some-dynamic-content"/> <p:output name="data" id="result"/> </p:processor>
It is possible to include the XML document available on the custom
<xhtml:html> <xhtml:head> <xhtml:title>XForms Text Controls</xhtml:title> <xforms:model id="main-model"> <xforms:instance id="instance"> <!-- This is where the inclusion is performed --> <xi:include href="input:my-dynamic-content"/> </xforms:instance> </xforms:model> </xhtml:head>... </xhtml:html>
This makes the XInclude processor very versatile as a simple template processor. |