XInclude is a generic mechanism for mergingXML documents, by writing inclusion tags in the "main" document to automatically include other documents or parts thereof.[1] The resulting document becomes a single compositeXML Information Set. The XInclude mechanism can be used to incorporate content from either XML files or non-XML text files.
XInclude is not natively supported in Web browsers, but may be partially achieved by using some extraJavaScript code.[2]
For example, including the text filelicense.txt
:
This document is published under GNU Free Documentation License
in anXHTML document:
<?xml version="1.0"?><htmlxmlns="http://www.w3.org/1999/xhtml"xmlns:xi="http://www.w3.org/2001/XInclude"><head>...</head><body>...<p><xi:includehref="license.txt"parse="text"/></p></body></html>
gives:
<?xml version="1.0"?><htmlxmlns="http://www.w3.org/1999/xhtml"xmlns:xi="http://www.w3.org/2001/XInclude"><head>...</head><body>...<p>ThisdocumentispublishedunderGNUFreeDocumentationLicense</p></body></html>
The mechanism is similar toHTML's<object>
tag (which is specific to the HTMLmarkup language), but the XInclude mechanism works with any XML format, such asSVG andXHTML.