MENU
XInclude
XInclude is a generic mechanism for merging XML documents. The valid values for the attribute ‘parse’ are ‘text’ and ‘xml’. Like XLink, its special namespace should be declared becfore it is used. For a working PHP example, refer to 6.7.2.The following demonstrates range inclusion. The second row below shows how XInclude may be invoked. The third row shows 'source.xml'. The fourth row shows the XML obtained.
RESETRUNFULL
RESETRUNFULL
<?xml version='1.0'?>
<document>
<p>The relevant excerpt is:</p>
<quotation>
<include xmlns="http://www.w3.org/2001/XInclude"
href="source.xml" xpointer="xpointer(string-range(chapter/p[1],'Sentence 2')/range-to(string-range(/chapter/p[2]/i,'3.',1,2)))"/>
</quotation>
</document>
<chapter>
<p>Sentence 1. Sentence 2.</p>
<p><i>Sentence 3. Sentence 4.</i> Sentence 5.</p>
</chapter>
<?xml version='1.0'?>
<document>
<p>The relevant excerpt is:</p>
<quotation>
<p xml:base="http://www.example.com/source.xml">
Sentence 2.</p>
<p xml:base="http://www.example.com/source.xml">
<i>Sentence 3.</i></p>
</quotation>
</document>
<!-- (Courtesy of http://www.w3.org/TR/xinclude/#examples) -->
The following demonstrates fallback. If neither example.txt nor fallback-example.txt is available, the XML obtained is shown in the third row.
RESETRUNFULL
Currently browsers do not support XLink and XPointer in general. However, they support simple XLinks in SVG.
RESETRUNFULL
<?xml version='1.0'?>
<div>
<xi:include href="example.txt" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:fallback>
<xi:include href="fallback-example.txt" parse="text">
<xi:fallback>
<a href="mailto:bob@example.org">
Report error</a>
</xi:fallback>
</xi:include>
</xi:fallback>
</xi:include>
</div>
<!-- (Courtesy of http://www.w3.org/TR/xinclude/#examples) -->