XInclude

From Vero - Wikipedia
Jump to navigation Jump to search

XInclude is a generic mechanism for merging XML documents, by writing inclusion tags in the "main" document to automatically include other documents or parts thereof.<ref>Template:Cite web</ref> The resulting document becomes a single composite XML 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 extra JavaScript code.<ref> Template:Cite web</ref>

Example

For example, including the text file license.txt:

This document is published under GNU Free Documentation License

in an XHTML document:

<syntaxhighlight lang="xml"> <?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml"

     xmlns:xi="http://www.w3.org/2001/XInclude">
  <head>...</head>
  <body>
     ...

<xi:include href="license.txt" parse="text"/>

  </body>

</html> </syntaxhighlight>

gives:

<syntaxhighlight lang="xml"> <?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml"

     xmlns:xi="http://www.w3.org/2001/XInclude">
  <head>...</head>
  <body>
     ...

This document is published under GNU Free Documentation License

  </body>

</html> </syntaxhighlight>

The mechanism is similar to HTML's <object> tag (which is specific to the HTML markup language), but the XInclude mechanism works with any XML format, such as SVG and XHTML.

See also

References

<references/>

Template:W3C standards