<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xmlspec.xsl"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.10//EN"
                      "xmlspec.dtd" [
<!ENTITY year "2013">
<!ENTITY month "January">
<!ENTITY MM "01">
<!ENTITY day "15">
<!ENTITY DD "15">
<!ENTITY MMDD "&MM;&DD;">
<!ENTITY status "WD">
<!ENTITY status-lc "wd">
<!ENTITY includensuri "http://www.w3.org/2001/XInclude">
<!ENTITY XMLCore-IPR "http://www.w3.org/2002/08/xmlcore-IPR-statements">
<!ENTITY internalXInclude "http://www.w3.org/XML/Group/2004/12/&status;-xinclude-11-&year;&MMDD;">
<!ENTITY externalXInclude "http://www.w3.org/TR/&year;/&status;-xinclude-11-&year;&MMDD;">
<!ENTITY XInclude "&externalXInclude;">
<!ENTITY errataloc "http://www.w3.org/XML/2006/11/xinclude-errata/">
<!ENTITY translationloc "http://www.w3.org/2003/03/Translations/byTechnology?technology=xinclude10">
<!ENTITY impreploc "http://www.w3.org/XML/2004/xinclude-implementation/report.html">
<!ENTITY testsuiteloc "http://www.w3.org/XML/Test/XInclude/">
<!ENTITY commentlistmailtoloc "www-xml-xinclude-comments@w3.org">
<!ENTITY commentlistarchiveloc "http://lists.w3.org/Archives/Public/www-xml-xinclude-comments/">
<!-- DTD Extensions -->
<!ENTITY % local.list.class "|options-list">
<!ELEMENT options-list (item+)>
<!ATTLIST options-list
diff (chg | add | del | off) #IMPLIED
role NMTOKEN #IMPLIED
id ID #IMPLIED
spacing (normal | compact) #IMPLIED
>
<!ATTLIST resolution
href CDATA #IMPLIED
>
<!ENTITY % local.loc.class "|loc-content">
<!ELEMENT loc-content (#PCDATA | acronym)*>
<!ATTLIST loc-content
href CDATA #IMPLIED
>
<!ELEMENT acronym (#PCDATA)>
<!ATTLIST acronym
lang CDATA #IMPLIED
title CDATA #IMPLIED
>
<!ENTITY nbsp "&#160;">
<!-- nonbreakable space, U+00A0 -->
<!ENTITY copy "&#169;">
<!-- copyright sign, U+00A9 ISOnum -->
<!ENTITY reg "&#174;">
<!-- registered sign = registered trade mark sign,
                                  U+00AE ISOnum -->
]>
<spec w3c-doctype="&status-lc;">
<header>
<title>XML Inclusions (XInclude)</title>
<version>Version 1.1</version>
<w3c-designation>xinclude-11-&year;&MMDD;</w3c-designation>
<w3c-doctype>W3C Working Draft</w3c-doctype>
<pubdate>
<day>&day;</day>
<month>&month;</month>
<year>&year;</year>
</pubdate>
<publoc>
<loc href="&XInclude;/">&XInclude;/</loc>
</publoc>
<altlocs>
<loc href="xinclude-11.xml">XML</loc>
<loc href="diff10.html">with color-coded revision indicators from XInclude 1.0</loc>
</altlocs>
<latestloc>
<loc href="http://www.w3.org/TR/xinclude-11/">http://www.w3.org/TR/xinclude-11/</loc>
</latestloc>
<prevlocs>
<loc href="http://www.w3.org/TR/2012/WD-xinclude-11-20121009/">http://www.w3.org/TR/2012/WD-xinclude-11-20121009/</loc>
</prevlocs>
<authlist>
<author>
<name>Jonathan Marsh</name>
<affiliation>Microsoft</affiliation>
<email href="mailto:jmarsh@microsoft.com">jmarsh@microsoft.com</email>
</author>
<author>
<name>David Orchard</name>
<affiliation>BEA Systems</affiliation>
<email href="mailto:dorchard@bea.com">dorchard@bea.com</email>
</author>
<author role="2e">
<name>Daniel Veillard</name>
<!--affiliation>Invited expert</affiliation-->
<email href="mailto:daniel@veillard.com">daniel@veillard.com</email>
</author>
<author role="11">
<name>Norman Walsh</name>
<affiliation>MarkLogic Corporation</affiliation>
<email href="mailto:norman.walsh@marklogic.com">norman.walsh@marklogic.com</email>
</author>
</authlist>
<!--
<copyright>
<p role="copyright">
<loc href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
Copyright</loc>&nbsp; &copy; 2004 <loc-content href="http://www.w3.org/">
<acronym title="World Wide Web Consortium">W3C</acronym>
</loc-content>
<sup>&reg;</sup>
(<loc-content href="http://www.csail.mit.edu/">
<acronym title="Massachusetts Institute of Technology">MIT</acronym>
</loc-content>, <loc-content href="http://www.ercim.org/">
<acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym>
</loc-content>, <loc href="http://www.keio.ac.jp/">Keio</loc>), All Rights Reserved.
W3C <loc href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</loc>,
<loc href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</loc>, and
<loc href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</loc>
rules apply.</p>
</copyright>
-->
<errataloc href="&errataloc;"/>
<translationloc href="&translationloc;"/>

<status>
<p><emph>This section describes the status
of this document at the time of its publication. Other documents may
supersede this document. A list of current W3C publications and the
latest revision of this technical report can be found in the <loc
href="http://www.w3.org/TR/">W3C technical reports index</loc> at
http://www.w3.org/TR/.</emph></p>

<p> This is a Last Call Working Draft of XInclude 1.1
for review by W3C Members and other interested parties.
The Last Call period ends 22 February 2013.</p>

<p>XInclude 1.1 adds some upward-compatible enhancements
to the <loc href="http://www.w3.org/TR/xinclude/">XInclude 1.0 Recommendation</loc
> as discussed in the <loc
href="http://www.w3.org/TR/xinclude-11-requirements/">XInclude 1.1
Requirement and Use Cases</loc> document. The three key enhancements
can be summarized as follows:</p>

<ulist>
<item><p>added support for
a fragment identifier into text/plain content,</p></item>
<item><p>additional processing to allow for “annotating” the post-included
infoset with further information, and</p></item>
<item><p>allow implementations the flexibility to support additional
<att>parse</att> values.</p></item>
</ulist>

<p>This document
has been produced by the <loc href="http://www.w3.org/XML/Core/">W3C
XML Core Working Group</loc> as part of the <loc
href="http://www.w3.org/XML/Activity">XML Activity</loc>. The Working
Group expects to advance this Working Draft to Recommendation Status. </p
><p>Please send comments about this document to the public <loc
href="mailto:&commentlistmailtoloc;">&commentlistmailtoloc;</loc> mailing-list; <loc
href="&commentlistarchiveloc;">archives</loc> are available. </p><p
>Publication as a Working Draft does not imply endorsement by the
W3C Membership. This is a draft document and may be updated, replaced
or obsoleted by other documents at any time. It is inappropriate to
cite this document as other than work in progress.</p><!--
<p>The errata list for this edition is available
at <loc href="&errataloc;">&errataloc;</loc
>.</p>--><!--<p> Known implementations are documented in
the XInclude Implementation Report at <loc
href="&impreploc;">&impreploc;</loc>.  A Test
Suite is maintained at <loc href="&testsuiteloc;"
>&testsuiteloc;</loc> to help in assessing
conformance to this specification. The latest
release of the Test Suite includes new test
cases which implementers can use to check
their conformance to the changes included
in this new edition.</p>--><p> This document was produced by a group
operating under the <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</loc>. W3C maintains a <loc
href="http://www.w3.org/2004/01/pp-impl/18796/status#disclosures"
role="disclosure">public list of any patent disclosures</loc> made
in connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential"
>Essential Claim(s)</loc> must disclose the information in accordance
with <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure"
>section 6 of the W3C Patent Policy</loc>.</p>

</status>
<abstract>
<p>This document specifies a processing model and syntax for general
purpose inclusion.  Inclusion is accomplished by merging a
number of XML information sets into a single composite infoset.
Specification of the XML documents (infosets) to be merged and
control over the merging process is expressed in XML-friendly
syntax (elements, attributes, URI references).</p>
</abstract>
<langusage>
<language id="EN">English</language>
</langusage>
<revisiondesc>
<slist>
<sitem>February 28, 2000: First Working Draft.</sitem>
</slist>
</revisiondesc>
</header>
<body>
<div1 id="intro">
<head>Introduction</head>
<p>Many programming languages provide an inclusion mechanism to
facilitate modularity.  Markup languages also often have need of
such a mechanism.  This specification introduces a generic mechanism
for merging XML documents (as represented by their information sets)
for use by applications that need such a facility.  The syntax
leverages existing XML constructs - elements, attributes, and URI
references.</p>
<div2 id="rel-xlink">
<head>Relationship to XLink</head>
<p>XInclude differs from the linking features described in the
<bibref ref="XLink"/>, specifically links with the
attribute value <code>show="embed"</code>.  Such links provide
a media-type independent syntax for indicating that a resource
is to be embedded graphically within the display of the document.
XLink does not specify a specific processing model, but simply
facilitates the detection of links and recognition of associated
metadata by a higher level application.</p>
<p>XInclude, on the other hand, specifies a media-type specific
(XML into XML) transformation.  It defines a specific processing
model for merging information sets.  XInclude processing occurs
at a low level, often by a generic XInclude processor which makes
the resulting information set available to higher level
applications.</p>
<p>Simple information item inclusion as described in this specification
differs from transclusion, which preserves contextual
information such as style.</p>
</div2>
<div2 id="rel-extent">
<head>Relationship to XML External Entities</head>
<p>There are a number of differences between XInclude and
<bibref ref="XML"/> or <bibref ref="XML11"/> external entities
which make them complementary technologies.</p>
<p>Processing of external entities (as with the rest of DTDs)
occurs at parse time.  XInclude operates on information sets
and thus is orthogonal to parsing.</p>
<p>Declaration of external entities requires a DTD or internal subset.
This places a set of dependencies on inclusion, for instance, the syntax
for the DOCTYPE declaration requires that the document element be named -
orthogonal to inclusion in many cases.  Validating parsers
must have a complete content model defined.  XInclude is orthogonal
to validation and the name of the document element.</p>
<p>External entities provide a level of indirection - the external
entity must be declared and named, and separately invoked.
XInclude uses direct references.  Applications which generate
XML output incrementally can benefit from not having to pre-declare
inclusions.</p>
<p>Failure to load an external entity is normally a fatal error.
XInclude allows the author to provide default content that will be
used if the remote resource cannot be loaded.</p>
<p>The syntax for an internal subset is cumbersome to many authors
of simple well-formed XML documents.  XInclude syntax is based on
familiar XML constructs.</p>
</div2>
<div2 id="rel-dtd">
<head>Relationship to DTDs</head>
<p>XInclude defines no relationship to DTD validation.  XInclude
describes an infoset-to-infoset transformation and not a change
in XML parsing behavior.  XInclude does not define a
mechanism for DTD validation of the resulting infoset.</p>
</div2>
<div2 id="rel-xsd">
<head>Relationship to XML Schemas</head>
<p>XInclude defines no relationship to the augmented infosets
produced by applying an XML schema.  Such an augmented infoset
can be supplied as the input infoset, or such augmentation might
be applied to the infoset resulting from the inclusion.</p>
</div2>
<div2 id="rel-inc">
<head>Relationship to Grammar-Specific Inclusions</head>
<p>Special-purpose inclusion mechanisms have been introduced
into specific XML grammars.  XInclude provides a generic mechanism
for recognizing and processing inclusions, and as such can offer
a simpler overall authoring experience, greater performance, and
less code redundancy.</p>
</div2>
</div1>
<div1 id="terminology">
<head>Terminology</head>
<p>
<termdef id="dt-must" term="Must, May, etc.">The key words
<term>must</term>, <term>must not</term>, <term>required</term>,
<term>shall</term>, <term>shall not</term>, <term>should</term>,
<term>should not</term>, <term>recommended</term>, <term>may</term>,
and <term>optional</term> in this specification are to be interpreted
as described in <bibref ref="RFC2119"/>.</termdef>
</p>
<p>
<termdef id="dt-infoset" term="infoset">The term <term>information
set</term> refers to the output of an <bibref ref="XML"/> or
<bibref ref="XML11"/> processor, expressed as a
collection of information items and properties as defined by the
<bibref ref="XMLIS"/> specification.</termdef>  In this document
the term <emph>infoset</emph> is used as a synonym for
<emph>information set</emph>.</p>
<p>
<termdef id="dt-error" term="fatal error">The term <term>fatal
error</term> refers to the presence of factors that prevent normal
processing from continuing.</termdef>&#32;
<termdef id="dt-resource-error" term="resource error">The term
<term>resource error</term> refers to a failure of an attempt to
fetch a resource from a URL.</termdef>
<termdef id="dt-recoverable-error" term="recoverable error">The term
<term>recoverable error</term> refers to the presence of factors which
are erroneous, but for which this specification prescribes specific
recovery behavior.</termdef>
XInclude
processors <termref def="dt-must">must</termref> stop processing
when encountering
<termref def="dt-error">fatal
errors</termref>;
<termref def="dt-resource-error">resource errors</termref>
<termref def="dt-must">must</termref> be handled as described in
<specref ref="fallback"/>;
<termref def="dt-recoverable-error">recoverable errors</termref>
<termref def="dt-must">must</termref> be handled as specified.
</p>
</div1>
<div1 id="syntax">
<head>Syntax</head>
<p>XInclude defines a namespace associated with the URI
<code>&includensuri;</code>. The XInclude namespace contains two
elements with the local names <code>include</code> and
<code>fallback</code>.  For convenience, within this specification
these elements are referred to as <code>xi:include</code> and
<code>xi:fallback</code> respectively.</p>
<p>The following (non-normative) XML schema <bibref ref="XMLSchemas"/>
illustrates the content model of the <code>xi</code> namespace:</p>
<eg>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xi="http://www.w3.org/2001/XInclude"
           targetNamespace="http://www.w3.org/2001/XInclude"
           finalDefault="extension"&gt;

  &lt;xs:element name="include" type="xi:includeType" /&gt;

  &lt;xs:complexType name="includeType" mixed="true"&gt;
    &lt;xs:choice minOccurs='0' maxOccurs='unbounded' &gt;
      &lt;xs:element ref='xi:fallback' /&gt;
      &lt;xs:any namespace='##other' processContents='lax' /&gt;
      &lt;xs:any namespace='##local' processContents='lax' /&gt;
    &lt;/xs:choice&gt;
    &lt;xs:attribute name="href" use="optional" type="xs:anyURI"/&gt;
    &lt;xs:attribute name="parse" use="optional" default="xml"
                  type="<phrase diff="del">xs:token</phrase><phrase diff="add">xs:string</phrase>" /&gt;
    &lt;xs:attribute name="xpointer" use="optional" type="xs:string"/&gt;
    &lt;xs:attribute name="fragid" use="optional" type="xs:string/&gt;
    &lt;xs:attribute name="encoding" use="optional" type="xs:string"/&gt;
    &lt;xs:attribute name="accept" use="optional" type="xs:string"/&gt;
    &lt;xs:attribute name="accept-language" use="optional" type="xs:string"/&gt;
    &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;
  &lt;/xs:complexType&gt;

  &lt;xs:element name="fallback" type="xi:fallbackType" /&gt;

  &lt;xs:complexType name="fallbackType" mixed="true"&gt;
    &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
      &lt;xs:element ref="xi:include"/&gt;
      &lt;xs:any namespace="##other" processContents="lax"/&gt;
      &lt;xs:any namespace="##local" processContents="lax"/&gt;
    &lt;/xs:choice&gt;
    &lt;xs:anyAttribute namespace="##other" processContents="lax" /&gt;
  &lt;/xs:complexType&gt;

&lt;/xs:schema&gt;</eg>
<div2 id="include_element">
<head>xi:include Element</head>
<p>The <code>xi:include</code> element has the following
attributes:</p>
<glist>
<gitem>
<label>href</label>
<def>
<p>A value which, after appropriate escaping (see <specref ref="IRIs"/>)
has been performed, results in a URI reference or an
<termref def="dt-IRI">IRI reference</termref>
specifying the location of the resource to
include.  The <att>href</att> attribute is optional; the
absence of this attribute is the same as specifying
<att>href=""</att>, that is, the reference is to the same
document.  If the <att>href</att> attribute is absent when
<phrase diff="chg">XML processing is specified</phrase>, the <att>xpointer</att>
or <att>fragid</att> attribute
<termref def="dt-must">must</termref> be present.  Fragment
identifiers <termref def="dt-must">must not</termref> be used;
their appearance is a <termref def="dt-error">fatal error</termref>.
A value that results in a syntactically invalid URI or IRI
<termref def="dt-must">should</termref>
be reported as a <termref def="dt-error">fatal error</termref>, but
some implementations may find it impractical to distinguish this
case from a <termref def="dt-resource-error">resource error</termref>.</p>

<note>
<p>A URI ending in <code>#</code> is considered by <bibref ref="RFC2396"/>
to have an empty fragment identifier.  Such a URI would result in a
<termref def="dt-error">fatal error</termref> as described above.</p>
</note>

<note>
<p diff="del">A key feature of XInclude is that it allows a resource
to be cast to a user-specifed type for inclusion (XML or text). The
returned media type is therefore essentially ignored for the purposes
of inclusion processing, and the syntax of the fragment identifier of
the returned media type will generally not be applicable to the
user-specified type. For <att>parse="xml"</att> inclusions,
sub-resources are identified by a separate <att>xpointer</att>
attribute, which is applied after the casting takes place. While this
does not prevent subresources of XML documents to be identified by URI
(See <loc
href="http://www.w3.org/TR/webarch/#identification">Architecture of
the World Wide Web [Identification]</loc>), it does preclude the use
of these identifiers directly within XInclude.</p>

<p diff="add">A key feature of XInclude is that it allows a resource to
be cast to a user-specifed type for inclusion. The returned
media type is therefore essentially ignored for the purposes
of inclusion processing, and the syntax of the fragment
identifier of the returned media type will generally not
be applicable to the user-specified type.
Therefore, in XInclude, subresources of the included resource
are identified by a separate <code>xpointer</code> or <code>fragid</code> attribute
which is applied after the casting takes place.
</p>
</note>

</def>
</gitem>
<gitem>
<label>parse</label>
<def>
<p diff="del">Indicates whether to include the resource as parsed XML or as
text.  The parse attribute allows XInclude to give the author of
the including document priority over the server of the included
document in terms of how to process the included content.  A value
of "xml" indicates that the resource <termref def="dt-must">must</termref>
be parsed as XML and the infosets merged.  A value of "text" indicates
that the resource <termref def="dt-must">must</termref> be included
as the character information items.  This attribute is optional.
When omitted, the value of "xml" is implied.  Values other than "xml" and "text" are
implementation-defined.</p>

<p diff="add">Indicates how to parse the included resource.
The parse attribute allows XInclude to give the author of
the including document priority over the server of the included
document in terms of how to process the included content.
With two exceptions,
the value of the <att>parse</att> attribute <termref def="dt-must">must</termref>
conform to the requirements of a <em>media type</em>,
see <bibref ref="RFC4288"/>. The exceptions are “<code>xml</code>”
which <termref def="dt-must">must</termref> be treated as
“<code>application/xml</code>” and “<code>text</code>”,
which <termref def="dt-must">must</termref> be treated as
“<code>text/plain</code>”.</p>

<p diff="add">Implementations <termref def="dt-must">must</termref> process
the value of the <att>parse</att> attribute with standard
media type rules: if the media type is recognized, process it as that media type;
if the suffix is recognized, process it in accordance with that suffix; and finally,
if the family is recognized, process it in accordance with that family.</p>

<note diff="add">
<p>In accordance with these rules, a media type of “<code>application/unknown+xml</code>”
will be treated as XML (i.e. <code>application/xml</code>),
whereas a media type of “<code>text/unknown</code>” will
be treated as text (i.e. <code>text/plain</code>).</p>
</note>

<p diff="add">A value of “<code>xml</code>”, “<code>application/xml</code>”,
or a value with the “<code>+xml</code>” suffix
indicates that the resource <termref def="dt-must">must</termref>
be parsed as XML and the infosets merged.  A value of
“<code>text</code>”, “<code>text/plain</code>”, or a value in the
“<code>text</code>” family
indicates
that the resource <termref def="dt-must">must</termref> be included
as the character information items.  This attribute is optional.
When omitted, the value of “<code>application/xml</code>” is implied.
Values that specify neither XML processing nor text processing are
implementation-defined.</p>

<p>Implementations <termref def="dt-must">must</termref> treat
values of the <att>parse</att> attribute that it
does not recognize
as a
<termref def="dt-recoverable-error">recoverable error</termref>
and handle the <code>xi:include</code> element as described in
<specref ref="fallback"/>.
</p>
<note>
<p>For interoperability between validating and non-validating
systems, whitespace <termref def="dt-must">should not</termref>
appear in the parse attribute.</p>
</note>
</def>
</gitem>
<gitem>
<label>xpointer</label>
<def>
<p>When <phrase diff="chg">the <att>parse</att> attribute specifies XML
processing</phrase>, the XPointer (see <bibref ref="XPCore"/>)
contained in the <att>xpointer</att> attribute is evaluated to identify
a portion of the resource to include.</p>
<p>See <specref ref="xpointer-and-fragid"/>
for more information.</p>
</def>
</gitem>
<gitem>
<label>fragid</label>
<def>
<p>The <att>fragid</att> attribute is a generalization of the <att>xpointer</att>
attribute. A <att>fragid</att> may be present regardless of the value of
the <att>parse</att> attribute.
The interpretation of the value of the attribute depends on
the value of <att>parse</att>. For <phrase diff="chg">XML processing</phrase>, the value
is interpreted as an XPointer (see <bibref ref="XPCore"/>); for
<phrase diff="chg">text processing</phrase>,
it is interpreted as a <bibref ref="RFC5147"/> fragment identifier. For other values
of <att>parse</att>, the interpretation is implementation-defined.</p>
<p>See <specref ref="xpointer-and-fragid"/>
for more information.</p>
</def>
</gitem>
<gitem>
<label>encoding</label>
<def>
<p><phrase diff="add">For non-XML processing, the</phrase>
<phrase diff="del">When <att>parse="text"</att>, it is sometimes impossible to
correctly detect the encoding of the text resource.  The</phrase>
<att>encoding</att> attribute specifies how the resource is to
be translated.  The value of this attribute <termref
def="dt-must">should</termref> be a valid encoding name.
The <att>encoding</att> attribute has no effect when
<phrase diff="chg">processing the resource as XML</phrase>.</p>
</def>
</gitem>
<gitem>
<label>accept</label>
<def>
<p>The value of the <att>accept</att> attribute may be used by
the XInclude processor to aid in content negotiation. When the
XInclude processor fetches a resource via HTTP, it
<termref def="dt-must">should</termref> place the
value of the <att>accept</att> attribute, if one exists, in
the HTTP request as an <code>Accept</code> header as
described in section 14.1 of <bibref ref="RFC2616"/>.  Values containing
characters outside the range #x20 through #x7E are disallowed
in HTTP headers, and <termref def="dt-must">must</termref>
be flagged as <termref def="dt-error">fatal errors</termref>.</p>
</def>
</gitem>
<gitem>
<label>accept-language</label>
<def>
<p>The value of the <att>accept-language</att> attribute may be used by
the XInclude processor to aid in content negotiation. When the
XInclude processor fetches a resource via HTTP, it
<termref def="dt-must">should</termref> place the
value of the <att>accept-language</att> attribute, if one exists, in
the HTTP request as an <code>Accept-Language</code> header as
described in section 14.4 of <bibref ref="RFC2616"/>.  Values containing
characters outside the range #x20 through #x7E are disallowed
in HTTP headers, and <termref def="dt-must">must</termref>
be flagged as <termref def="dt-error">fatal errors</termref>.</p>
</def>
</gitem>
</glist>
<p>Attributes other than those listed above <termref def="dt-must">may</termref>
be placed on the <code>xi:include</code> element.  Unprefixed
attribute names are reserved for future versions of this specification,
and <termref def="dt-must">must</termref> be ignored by XInclude 1.0
processors.</p>
<p>The <emph role="infoset-property">children</emph> property of the
<code>xi:include</code> element <termref def="dt-must">may</termref>
include a single <code>xi:fallback</code> element; the appearance of
more than one <code>xi:fallback</code> element, an
<code>xi:include</code> element, or any other element from the
XInclude namespace is a <termref def="dt-error">fatal error</termref>.
Other content (text, processing instructions, comments, elements not
in the XInclude namespace, descendants of child elements) is not
constrained by this specification and is ignored by the XInclude
processor, that is, it has no effect on include processing, and does
not appear in the <emph role="infoset-property">children</emph>
properties of the result infoset. Such content might be used by
applications analyzing a pre-inclusion infoset, or be made available
to an application post-inclusion through means other than the normal
infoset properties.</p>
<p>The following (non-normative) DTD fragment illustrates a sample
  declaration for the <code>xi:include</code> element:</p>
<eg>&lt;!ELEMENT xi:include (xi:fallback?)&gt;
&lt;!ATTLIST xi:include
    xmlns:xi        CDATA       #FIXED    "&includensuri;"
    href            CDATA       #IMPLIED
    parse           <phrase diff="chg">CDATA       "application/xml"</phrase>
    xpointer        CDATA       #IMPLIED
    fragid          CDATA       #IMPLIED
    encoding        CDATA       #IMPLIED
    accept          CDATA       #IMPLIED
    accept-language CDATA       #IMPLIED
&gt;</eg>

<div3 id="xpointer-and-fragid">
<head>The xpointer and fragid attributes</head>

<p>The <att>xpointer</att> and <att>fragid</att> attributes identify a portion
of a resource to include.</p>

<p>If both <att>xpointer</att> and <att>fragid</att> are specified, they
<termref def="dt-must">should</termref> be the same. It is a
<termref def="dt-recoverable-error">recoverable error</termref> if they
are not the same; to recover, if the <att>parse</att> attribute
<phrase diff="chg">specifies XML processing</phrase>,
then the <att>xpointer</att>
attribute is used; otherwise the
<att>fragid</att>
attribute is used.</p>

<p>The <att>xpointer</att>
attribute <termref def="dt-must">must not</termref> be present when
<phrase diff="chg">text processing is specified</phrase>.
It is a <termref def="dt-error">fatal error</termref>
to specify
the <att>xpointer</att> attribute when
<phrase diff="chg">text processing is specified</phrase>.</p>

<p>The <att>xpointer</att> and <att>fragid</att> attribute are optional.
When neither is specified:</p>

<ulist>
<item>
<p>the <att>href</att> attribute <termref def="dt-must">must</termref> be
present and
</p>
</item>
<item>
<p>the entire resource is included.</p>
</item>
</ulist>

<p>It is a <termref def="dt-error">fatal error</termref>
if neither the <att>xpointer</att> nor <att>fragid</att> attributes are present
and the <att>href</att> attribute is not present.</p>

<p>Neither the <att>xpointer</att> nor <att>fragid</att> attributes
contain a URI reference, and %-escaping is not done in XPointers, so '%' is
an ordinary character in the value of the <att>xpointer</att> and
<att>fragid</att> attributes.</p>
</div3>
</div2>

<div2 id="fallback_element">
<head>xi:fallback Element</head>

<p>The <code>xi:fallback</code> element appears as a child
of an <code>xi:include</code> element.  It provides a mechanism
for recovering from missing resources.  When a
<termref def="dt-resource-error">resource error</termref> is
encountered, the <code>xi:include</code> element is replaced
with the contents of the <code>xi:fallback</code> element.
If the <code>xi:fallback</code> element is empty, the
<code>xi:include</code> element is removed from the result.
If the <code>xi:fallback</code> element is missing, a
<termref def="dt-resource-error">resource error</termref> results
in a <termref def="dt-error">fatal error</termref>.</p>

<p>The content of <code>xi:fallback</code> elements is ignored unless a
<termref def="dt-resource-error">resource error</termref> occurs while processing the
surrounding <code>xi:include</code> element. In particular, apparent
<termref def="dt-error">fatal errors</termref> caused by the presence, absence, or
content of elements and attributes inside the <code>xi:fallback</code> element
<termref def="dt-must">must not</termref> be reported in <code>xi:fallback</code>
elements that are ignored.</p>

<p>The <code>xi:fallback</code> element can appear only as a
child of an <code>xi:include</code> element.  It is a
<termref def="dt-error">fatal error</termref> for an <code>xi:fallback</code>
element that is not being ignored to appear
in a document anywhere other than as the direct child
of the <code>xi:include</code> (before inclusion processing on
the contents of the element.)  It is a <termref def="dt-error">fatal error</termref>
for an
<code>xi:fallback</code> element that is not being ignored to
contain any elements from the
XInclude namespace other than <code>xi:include</code>.</p>

<p>Attributes <termref def="dt-must">may</termref>
be placed on the <code>xi:fallback</code> element.  Unprefixed
attribute names are reserved for future versions of this specification,
and <termref def="dt-must">must</termref> be ignored by XInclude 1.0
processors.</p>

<p>The following (non-normative) DTD fragment illustrates a sample
declaration for the <code>xi:fallback</code> element:</p>
<eg>&lt;!ELEMENT xi:fallback ANY&gt;
&lt;!ATTLIST xi:fallback
    xmlns:xi   CDATA   #FIXED   "&includensuri;"
&gt;</eg>
</div2>
</div1>
<div1 id="processing">
<head>Processing Model</head>
<p>Inclusion as defined in this document is a specific type of
<bibref ref="XMLIS"/> transformation.</p>
<p>
<termdef id="dt-source-infoset" term="source infoset">The
input for the inclusion transformation consists of a <term>source
infoset</term>.</termdef>&#32;
<termdef id="dt-result-infoset" term="result infoset">The output, called the <term>result
infoset</term>, is a new infoset which merges the source infoset
with the infosets of resources identified by URI references or IRI references
appearing in <code>xi:include</code> elements.</termdef>  Thus a
mechanism to resolve URIs or IRIs and return the identified resources as
infosets is assumed.  Well-formed XML entities that do not have
defined infosets (e.g. an external entity with multiple
top-level elements) are outside the scope of this specification,
either for use as a <termref def="dt-source-infoset">source
infoset</termref> or the <termref def="dt-result-infoset">result
infoset</termref>.</p>
<p>
<code>xi:include</code> elements in the source infoset serve
as inclusion transformation instructions.
<termdef id="dt-top-level-included-items" term="top-level included items">The
information items located by the <code>xi:include</code> element
are called the <term>top-level included items</term>
</termdef>.
<termdef id="dt-included-items" term="included items">The
<termref def="dt-top-level-included-items">top-level included items</termref>
together with their attributes, namespaces, and descendants,
are called the <term>included items</term>
</termdef>.  The
<termref def="dt-result-infoset">result infoset</termref> is
essentially a copy of the <termref def="dt-source-infoset">source
infoset</termref>, with each <code>xi:include</code> element
and its descendants replaced by its corresponding
<termref def="dt-included-items">included items</termref>.</p>
<div2 id="include-location">
<head>The Include Location</head>
<p>The value of the <att>href</att> attribute, after escaping
according to <specref ref="IRIs"/>, is interpreted as either a
URI reference or an <termref def="dt-IRI">IRI reference</termref>.
The base URI for relative URIs or IRIs is the base URI of the <code>xi:include</code>
element as specified in <bibref ref="XMLBase"/>.
<termdef id="dt-include-location" term="include location">The
URI or IRI resulting from resolution of the normalized value of the
<code>href</code> attribute (or the empty string if no attribute appears)
to absolute URI or IRI form is called the <term>include location</term>.</termdef>
</p>
<p>The absence of a value for the <att>href</att> attribute, either
by the appearance of <att>href=""</att> or by the absence of the
<att>href</att> attribute, represents a case which may be incompatible
with certain implementation strategies.  For instance, an XInclude
processor might not have a textual representation of the
<termref def="dt-source-infoset">source infoset</termref> to include
as <phrase diff="chg">text</phrase>, or it may be unable to access another
part of the document <phrase diff="chg">when
parsing as XML and using an xpointer</phrase> because of streamability concerns.
An implementation
<termref def="dt-must">may</termref> choose to treat any or all
absences of a value for the <att>href</att> attribute as
<termref def="dt-resource-error">resource errors</termref>.
Implementations <termref def="dt-must">should</termref> document
the conditions under which such <termref def="dt-resource-error">resource
errors</termref> occur.</p>
<div3 id="IRIs">
<head>Escaping of <att>href</att> attribute values</head>
<p>The value of this attribute is an XML resource identifer as
defined in <bibref ref="XML11"/> section 4.2.2 "External Entities", which
is interpreted as <termdef id="dt-IRI" term="IRI reference">an IRI Reference as defined in RFC 3987 <bibref ref="RFC3987"/></termdef>,
after the escaping procedure described in <bibref ref="XML11"/> section
4.2.2 is applied. If necessary for the implementation, the value may be
further converted to a URI reference as described in <bibref ref="XML11"/>.</p>
</div3>
<div3 id="content-negotiation">
<head>Using XInclude with Content Negotiation</head>
<p>The use of a mechanism like HTTP <bibref ref="RFC2616"/> content
negotiation introduces an additional level of potential complexity
into the use of XInclude. Developers who use XInclude in situations
where content negotiation is likely or possible should be aware of
the possibility that they will be including content that may differ
structurally from the content they expected, even if that content
is XML.  For example, a single URI or IRI may variously return a raw XML
representation of the resource, an XSL-FO <bibref ref="XSL-FO"/>
representation, or an XHTML <bibref ref="XHTML"/> representation,
as well as versions in different character encodings or languages.</p>

<p>Authors whose XInclude processing depends on the receipt of
a particular vocabulary of XML can use the <att>accept</att>
and <att>accept-language</att> attributes
to increase the probability that the resource is provided in the
expected format.</p>

</div3>
</div2>
<div2 id="xml-included-items">
<head>Included Items when <phrase diff="chg">processing XML</phrase>
</head>
<p>When <phrase diff="chg">processing XML</phrase>, the
<termref def="dt-include-location">include location</termref> is
dereferenced, the resource is fetched, and an infoset is created by
parsing the resource as if the media type were application/xml
(including character encoding determination).</p>
<note>
<p>The specifics of how an infoset is created are intentionally
unspecified, to allow for flexibility by implementations and to
avoid defining a particular processing model for components of
the XML architecture.  Particulars of whether DTD or XML schema
validation are performed, for example, are not constrained by
this specification.</p>
</note>
<note>
<p>The character encodings of the including and included
resources can be different.  This does not affect the resulting
infoset, but might need to be taken into account during any
subsequent serialization.</p>
</note>
<p>Resources that are unavailable for any reason (for example the
resource doesn't exist, connection difficulties or security
restrictions prevent it from being fetched, the URI scheme isn't
a fetchable one, the resource is in an unsupported encoding, or the
resource is determined through implementation-specific mechanisms
not to be XML)
result in a <termref def="dt-resource-error">resource error</termref>.
Resources that contain non-well-formed XML result in a
<termref def="dt-error">fatal error</termref>.</p>
<note>
<p>The distinction between a resource error and a fatal error
is somewhat implementation-dependent.  Consider an include
location returning an HTML document, perhaps as an error page.
One processor might determine that no infoset can be created
from the resource (by examining the media type, for example)
and raise a resource error, enabling fallback behavior.
Another processor with no such heuristics might attempt to
parse the non-XML resource as XML and encounter a
well-formedness (fatal) error.</p>
</note>
<p>
<termdef id="dt-acquired-infoset" term="acquired infoset">
<code>xi:include</code> elements in this infoset are recursively
processed to create the <term>acquired infoset</term>.
For an intra-document reference (via <att>xpointer</att> attribute)
the <termref def="dt-source-infoset">source infoset</termref> is
used as the acquired infoset.</termdef>
</p>
<p>
<termdef id="dt-inclusion-target" term="inclusion target">The portion
of the <termref def="dt-acquired-infoset">acquired infoset</termref> to be
included is called the <term>inclusion target</term>.</termdef>  The
<emph role="info-item">document information item</emph> of the
<termref def="dt-acquired-infoset">acquired infoset</termref> serves
as the <termref def="dt-inclusion-target">inclusion target</termref>
unless the <att>xpointer</att> attribute is present and identifies a
subresource.  XPointers of the forms described in <bibref ref="XPCore"/>
and <bibref ref="XPElement"/>&#x20; <termref def="dt-must">must</termref>
be supported.  XInclude processors optionally support other forms of
XPointer such as that described in <bibref ref="XPointer"/>.  An error
in the XPointer is a <termref def="dt-resource-error">resource
error</termref>.</p>
<p>The <bibref ref="XPointer"/> is not specified in terms of the
<bibref ref="XMLIS"/>, but instead is based on the
<bibref ref="XPath"/> Data Model, because the XML Information Set
had not yet been developed.  The mapping between XPath node
locations and information items is straightforward.  However,
xpointer() assumes that all entities have been expanded.  Thus
it is a <termref def="dt-error">fatal error</termref> to attempt
to resolve an xpointer() scheme on a document that contains
<emph role="info-item">unexpanded entity reference information
items</emph>.</p>
<p>The set of <termref def="dt-top-level-included-items">top-level
included items</termref> is derived from the
<termref def="dt-acquired-infoset">acquired infoset</termref> as
follows.</p>
<div3 id="docii">
<head>Document Information Items</head>
<p>The <termref def="dt-inclusion-target">inclusion target</termref>
might be a <emph role="info-item">document information item</emph>
(for instance, no specified <att>xpointer</att> attribute, or an
XPointer specifically locating the document root.)  In this case,
the set of <termref def="dt-top-level-included-items">top-level
included items</termref> is the <emph role="infoset-property">children</emph>
of the <termref def="dt-acquired-infoset">acquired infoset's</termref>
document information item, except for the
<emph role="info-item">document type declaration information item</emph>
child, if one exists.</p>
<note>
<p>The XML Information Set specification does not provide for
preservation of white space outside the document element.
XInclude makes no further provision to preserve this white
space.</p>
</note>
</div3>
<div3 id="multiple-nodes">
<head>Multiple Nodes</head>
<p>The <termref def="dt-inclusion-target">inclusion target</termref>
might consist of more than a single node.  In this case the set of
<termref def="dt-top-level-included-items">top-level included
items</termref> is the set of information items from the
<termref def="dt-acquired-infoset">acquired infoset</termref>
corresponding to the nodes referred to by the XPointer, in the order
in which they appear in the acquired infoset.</p>
</div3>
<div3 id="ranges">
<head>Range Locations</head>
<p>The <termref def="dt-inclusion-target">inclusion target</termref> might
be a location set that represents a range or a set of ranges.</p>
<p>Each range corresponds to a set of information items in the
<termref def="dt-acquired-infoset">acquired infoset</termref>.
<termdef term="selected" id="dt-selected">An information item is
said to be <term>selected</term> by a range if it occurs after
(in document order) the starting point of the range and before
the ending point of the range.</termdef>&#32;
<termdef term="partially selected" id="dt-partially-selected">An
information item is said to be <term>partially selected</term> by
a range if it contains only the starting point of the range, or
only the ending point of the range.</termdef>  By definition, a
character information item cannot be
<termref def="dt-partially-selected">partially selected</termref>.</p>
<p>The set of <termref def="dt-top-level-included-items">top-level
included  items</termref> is the union, in document order with
duplicates removed, of the information items either
<termref def="dt-selected">selected</termref> or
<termref def="dt-partially-selected">partially selected</termref>
by the range.  The <emph role="infoset-property">children</emph>
property of <termref def="dt-selected">selected</termref>
information items is not modified.  The
<emph role="infoset-property">children</emph> property of
<termref def="dt-partially-selected">partially selected</termref>
information items is the set of information items that are in
turn either <termref def="dt-selected">selected</termref> or
<termref def="dt-partially-selected">partially selected</termref>,
and so on.</p>
</div3>
<div3 id="points">
<head>Point Locations</head>
<p>The <termref def="dt-inclusion-target">inclusion target</termref>
might be a location set that represents a point.  In this case the
set of <termref def="dt-included-items">included items</termref> is
empty.</p>
</div3>
<div3 id="elements">
<head>Element, Comment, and Processing Instruction Information Items</head>
<p>The <termref def="dt-inclusion-target">inclusion target</termref>
might be an element node, a comment node, or a processing instruction
node, respectively representing an <emph role="info-item">element
information item</emph>, a <emph role="info-item">comment information
item</emph>, or a <emph role="info-item">processing instruction information
item</emph>.  In this case the set of
<termref def="dt-top-level-included-items">top-level included items</termref>
consists of the information item corresponding to the element, comment, or
processing instruction node in the <termref def="dt-acquired-infoset">acquired
infoset</termref>.</p>
</div3>
<div3 id="attributes">
<head>Attribute and Namespace Declaration Information Items</head>
<p>It is a <termref def="dt-error">fatal error</termref> for the
<termref def="dt-inclusion-target">inclusion target</termref> to be an
attribute node or a namespace node.</p>
</div3>
<div3 id="loops">
<head>Inclusion Loops</head>
<p>When recursively processing an <code>xi:include</code>
element, it is a <termref def="dt-error">fatal error</termref> to process
another <code>xi:include</code> element with an
<termref def="dt-include-location">include location</termref> and
<att>xpointer</att> attribute value that have already been processed in the
inclusion chain.</p>
<p>In other words, the following are all legal:</p>
<ulist>
<item>
<p>An <code>xi:include</code> element
<termref def="dt-must">may</termref> reference the document
containing the include element, when <phrase diff="chg">processing text</phrase>.</p>
</item>
<item>
<p>An <code>xi:include</code> element
<termref def="dt-must">may</termref> identify a different
part of the same local resource (same <att>href</att>,
different <att>xpointer</att>).</p>
</item>
<item>
<p>Two non-nested <code>xi:include</code> elements
          <termref def="dt-must">may</termref> identify a resource which
          itself contains an <code>xi:include</code> element.</p>
</item>
</ulist>
<p>The following are illegal:</p>
<ulist>
<item>
<p>An <code>xi:include</code> element pointing to itself or any
ancestor thereof, when <phrase diff="chg">processing XML</phrase>.</p>
</item>
<item>
<p>An <code>xi:include</code> element pointing to any include
element or ancestor thereof which has already been processed
at a higher level.</p>
</item>
</ulist>
</div3>
</div2>

<div2 id="attribute-copying">
<head>Attribute Copying when <phrase diff="chg">processing XML</phrase></head>

<p>XInclude can introduce validity errors into a document. In particular, if a resource
containing element information items is included more than once, and if any of those
element information items have attributes of type ID, then the
<termref def="dt-result-infoset">result infoset</termref>
will contain multiple IDs with the same value.</p>

<p>Some applications will want to attempt to resolve these sorts of errors and
different applications will want to do so in different ways. In order to facilitate
this kind of processing, XInclude 1.1 introduces a new feature: attribute copying.</p>

<p>Any namespace qualified attribute that appears on the <code>xi:include</code>
element will be copied onto every
<termref id="dt-top-level-included-items" term="top-level included items">top-level
included item</termref> that is an element information item.</p>

<p>If the element information item already has an attribute with the same qualified
name, its value is changed to the value specified on the <code>xi:include</code>
element.</p>
</div2>

<div2 id="text-included-items">
<head>Included Items when <phrase diff="chg">processing text</phrase>
</head>
<p>When <phrase diff="chg">processing text</phrase>, the <termref def="dt-include-location">include
location</termref> is dereferenced and the resource is fetched
and transformed to a set of character information items.  This
feature facilitates the inclusion of working XML examples, as
well as other text-based formats.</p>
<p>Resources that are unavailable for any reason (for example
the resource doesn't exist, connection difficulties or security
restrictions prevent it from being fetched, the URI scheme isn't
a fetchable one, or the resource is in an unsupported encoding) result in a
<termref def="dt-resource-error">resource error</termref>.</p>
<p>The encoding of such a resource is determined by:</p>
<ulist>
<item>
<p>external encoding information, if available, otherwise</p>
</item>
<item>
<p>if the media type of the resource indicates,
according to XML Media Types <bibref ref="RFC3023"/>, that the
resource is XML, for example <code>text/xml</code> or
<code>application/xml</code> or matches
<code>text/*+xml</code> or <code>application/*+xml</code>, then the
encoding is determined as specified in <bibref ref="XML"/> or
<bibref ref="XML11"/> section 4.3.3, as appropriate, otherwise</p>
</item>
<item>
<p>the value of the <att>encoding</att> attribute if one
exists, otherwise</p>
</item>
<item>
<p>UTF-8.</p>
</item>
</ulist>
<p>Byte sequences outside the range allowed by the encoding are a
<termref def="dt-error">fatal error</termref>.  Characters that are not
permitted in XML documents also are a
<termref def="dt-error">fatal error</termref>.</p>
<p>Each character obtained from the transformation of the resource is
represented in the <termref def="dt-top-level-included-items">top-level
included items</termref> as a <emph role="info-item">character
information item</emph> with the
<emph role="infoset-property">character code</emph> set to the
character code in ISO 10646 encoding, and
the <emph role="infoset-property">element content whitespace</emph> set
to false.</p>
<p>When the first character is U+FEFF and is interpreted as a
Byte-Order Mark, it should be discarded. It is interpreted as a BOM in UTF-8,
UTF-16, and UTF-32 encodings; it is not interpreted as a BOM in the UTF-16LE,
UTF-16BE, UTF-32LE, and UTF-32BE encodings.</p>
<p>The <bibref ref="CharMod"/> discusses normalization of included text.</p>
</div2>

<div2 id="other-included-items">
<head>Included Items for other values of <att>parse</att>
</head>
<p><phrase diff="chg">When processing as neither XML nor text</phrase>,
the<phrase diff="del">the</phrase>
<termref def="dt-include-location">include location</termref>
is dereferenced
and the resource is fetched and transformed into information items through some
implementation-defined process.</p>

<note diff="del"><p>In this draft, there are no constraints specified for other values of
the <att>parse</att> attribute.
The Working Group is considering changes that would require other values to
be MIME content-type values with the proviso that the <att>fragid</att> value
should be consistent with the content-type.</p>
</note>

<p>Resources that are unavailable for any reason (for example
the resource doesn't exist, connection difficulties or security
restrictions prevent it from being fetched, the URI scheme isn't
a fetchable one, or the resource cannot be transformed into information
items for some other reason) result in a
<termref def="dt-resource-error">resource error</termref>.</p>

<p>The interpretation of <att>fragid</att> attributes for other values of <att>parse</att>
is implementation-defined.</p>

<p>Implementations may raise <termref def="dt-error">fatal errors</termref>; the
circumstances that result in such errors are implementation-defined.</p>
</div2>

<div2 id="fallback">
<head>Fallback Behavior</head>
<p>XInclude processors <termref def="dt-must">must</termref> perform
fallback behavior in the event of a
<termref def="dt-resource-error">resource error</termref>, as follows:</p>
<p>If the <emph role="infoset-property">children</emph> of the
<code>xi:include</code> element information item in the
<termref def="dt-source-infoset">source infoset</termref> contain
exactly one <code>xi:fallback</code> element, the
<termref def="dt-top-level-included-items">top-level included items</termref>
consist of the information items corresponding to the result of performing
XInclude processing on the <emph role="infoset-property">children</emph>
of the <code>xi:fallback</code> element.  It is a
<termref def="dt-error">fatal error</termref> if there is zero or more than
one <code>xi:fallback</code> element.</p>
<note>
<p>Fallback content is not dependent on the value of the
<code>parse</code> attribute.  The <code>xi:fallback</code>
element can contain markup even when <phrase diff="chg">processing text</phrase>.
Likewise, it can contain a simple string when <phrase diff="chg">processing XML</phrase>.</p>
</note>
</div2>
<div2 id="creating-result">
<head>Creating the Result Infoset</head>
<p>The result infoset is a copy of the source infoset,
with each <code>xi:include</code> element processed as follows:</p>
<p>The information item for the <code>xi:include</code> element is
found. <termdef id="dt-include-parent" term="include parent">The
<emph role="infoset-property">parent</emph> property of this item
refers to an information item called the <term>include parent</term>.</termdef>
The <emph role="infoset-property">children</emph> property of the
<termref def="dt-include-parent">include parent</termref>
is modified by replacing the <code>xi:include</code> element
information item with the <termref def="dt-top-level-included-items">top-level
included items</termref>. The <emph role="infoset-property">parent</emph>
property of each included item is set to the
<termref def="dt-include-parent">include parent</termref>.</p>
<p>It is a fatal error to attempt to replace an <code>xi:include</code>
element appearing as the document (top-level) element in the source
infoset with something other than a list of zero or more comments,
zero or more processing instructions, and one element.</p>
<p>Some processors may not be able to represent an element's
<emph role="infoset-property">in-scope namespaces</emph> property if
it does not include bindings for all the prefixes bound in its
parent's <emph role="infoset-property">in-scope namespaces</emph>.
Such processors <termref def="dt-must">may</termref> therefore include
additional namespace bindings inherited from the
<termref def="dt-include-parent">include parent</termref> in the
<emph role="infoset-property">in-scope namespaces</emph> of
the <termref def="dt-included-items">included items</termref>.</p>
<p>The inclusion history of each <termref def="dt-top-level-included-items">top-level
included item</termref> is recorded in the extension property
<emph role="infoset-property">include history</emph>.  The
<emph role="infoset-property">include history</emph> property is
a list of <emph role="info-item">element information items</emph>,
representing the <code>xi:include</code> elements for recursive levels
of inclusion.  If an <emph role="infoset-property">include history</emph>
property already appears on a <termref def="dt-top-level-included-items">top-level
included item</termref>, the <code>xi:include</code> element information
item is prepended to the list.  If no <emph role="infoset-property">include
history</emph> property exists, then this property is added with the
single value of the <code>xi:include</code> element information item.</p>
<p>The <termref def="dt-included-items">included items</termref> will all
appear in the result infoset.  This includes <emph role="info-item">unexpanded
entity reference information items</emph> if they are present.</p>
<p>Intra-document references within <code>xi:include</code> elements
are resolved against the source infoset.  The effect of this is that
the order in which <code>xi:include</code> elements are processed
does not affect the result.</p>
<p>In the following example, the second include always points to
the first <code>xi:include</code> element and not to itself,
regardless of the order in which the includes are processed.  Thus
the result of this inclusion is two copies of <code>something.xml</code>,
and does not produce an inclusion loop error.</p>
<eg>&lt;x xmlns:xi="&includensuri;"&gt;
  &lt;xi:include href="something.xml"/&gt;
  &lt;xi:include xpointer="xmlns(xi=&includensuri;)xpointer(x/xi:include[1])"
              parse="<phrase diff="chg">application/xml</phrase>"/&gt;
&lt;/x&gt;</eg>
<p>An XInclude processor <termref def="dt-must">may</termref>, at
user option, suppress <code>xml:base</code> and/or <code>xml:lang</code> fixup.</p>
<div3 id="unparsed-entities">
<head>Unparsed Entities</head>
<p>Any <emph role="info-item">unparsed entity information
item</emph> appearing in the <emph role="infoset-property">references</emph>
property of an attribute on the <termref def="dt-included-items">included
items</termref> or any descendant thereof is added to the
<emph role="infoset-property">unparsed entities</emph>
property of the <termref def="dt-result-infoset">result infoset</termref>'s
<emph role="info-item">document information item</emph>, if
it is not a duplicate of an existing member.  Duplicates do not appear
in the result infoset.</p>
<p>Unparsed entity items with the same
<emph role="infoset-property">name</emph>,
<emph role="infoset-property">system identifier</emph>,
<emph role="infoset-property">public identifier</emph>,
<emph role="infoset-property">declaration base URI</emph>,
<emph role="infoset-property">notation name</emph>, and
<emph role="infoset-property">notation</emph> are
considered to be duplicate.  An application
<termref def="dt-must">may</termref> also be able to detect that
unparsed entities are duplicate through other means.  For instance,
the URI resulting from combining the system identifier
and the declaration base URI is the same.</p>
<p>It is a <termref def="dt-error">fatal error</termref> to
include unparsed entity items with the same name, but which are not
determined to be duplicates.</p>
</div3>
<div3 id="notations">
<head>Notations</head>
<p>Any <emph role="info-item">notation information item</emph>
appearing in the <emph role="infoset-property">references</emph>
property of an attribute in the <termref def="dt-included-items">included
items</termref> or any descendant thereof is added to the
<emph role="infoset-property">notations</emph> property of the
<termref def="dt-result-infoset">result infoset</termref>'s
<emph role="info-item">document information item</emph>, if
it is not a duplicate of an existing member.  Likewise,
any notation referenced by an unparsed entity added as described
in <specref ref="unparsed-entities"/>, is added unless it is
a duplicate.  Duplicates do not appear in the result infoset.</p>
<p>Notation items with the same
<emph role="infoset-property">name</emph>,
<emph role="infoset-property">system identifier</emph>,
<emph role="infoset-property">public identifier</emph>, and
<emph role="infoset-property">declaration base URI</emph> are
considered to be duplicate.  An application <termref def="dt-must">may</termref>
also be able to detect that notations are duplicate through other means.  For
instance, the URI resulting from combining the system identifier
and the declaration base URI is the same.</p>
<p>It is a <termref def="dt-error">fatal error</termref> to
include notation items with the same name, but which are not
determined to be duplicates.</p>
</div3>
<div3 id="references-property">
<head>
<emph role="infoset-property">references</emph> Property Fixup</head>
<p>During inclusion, an <emph role="info-item">attribute information
item</emph> whose <emph role="infoset-property">attribute type</emph>
property is IDREF or IDREFS has a <emph role="infoset-property">references</emph>
property with zero or more element values from the source or included
infosets.  These values <termref def="dt-must">must</termref> be
adjusted to correspond to element values that occur in the result
infoset.  During this process, XInclude also corrects inconsistencies
between the <emph role="infoset-property">references</emph>
property and the <emph role="infoset-property">attribute type</emph>
property, which might arise in the following circumstances:</p>
<ulist>
<item>
<p>A document fragment contains an IDREF pointing to an element
in the included document but outside the part being included.
In this case there is no element in the result infoset that
corresponds to the element value in the original
<emph role="infoset-property">references</emph> property.</p>
</item>
<item>
<p>A document or document fragment is not self-contained.
That is, it contains IDREFs which do not refer to an element within
that document or document fragment, with the intention that these
references will be realized after inclusion.  In this case,
the value of the <emph role="infoset-property">references</emph>
property is unknown or has no value.</p>
</item>
<item>
<p>The result infoset has ID clashes - that is, more than one
attribute with <emph role="infoset-property">attribute type</emph>
ID with the same <emph role="infoset-property">normalized value</emph>.
In this case, attributes with <emph role="infoset-property">attribute
type</emph> IDREF or IDREFS with the same <emph role="infoset-property">
normalized value</emph> might have different values for their
         <emph role="infoset-property">references</emph> properties.</p>
</item>
</ulist>
<p>In resolving these inconsistencies, XInclude takes the
<emph role="infoset-property">attribute type</emph> property as
definitive.  In the result infoset, the value of the
<emph role="infoset-property">references</emph> property of an
<emph role="info-item">attribute information item</emph>
whose <emph role="infoset-property">attribute type</emph> property
is IDREF or IDREFS is adjusted as follows:</p>
<p>For each token in the <emph role="infoset-property">normalized
value</emph> property, the <emph role="infoset-property">references</emph>
property contains an <emph role="info-item">element information
item</emph> with the same properties as the
<emph role="info-item">element information item</emph> in the result
infoset with an attribute with <emph role="infoset-property">attribute
type</emph> ID and <emph role="infoset-property">normalized
value</emph> equal to the token.  The order of the elements in
the <emph role="infoset-property">references</emph> property is
the same as the order of the tokens appearing in the
<emph role="infoset-property">normalize value</emph>.  If for any of the
token values, no element or more than one element is found, the
<emph role="infoset-property">references</emph> property has no value.</p>
</div3>
<div3 id="namespaces">
<head>Namespace Fixup</head>
<p>The <emph role="infoset-property">in-scope namespaces</emph>
property ensures that namespace scope is preserved through inclusion.
However, after inclusion, the <emph role="infoset-property">namespace
attributes</emph> property might not provide the full list of
namespace declarations necessary to interpret qualified names in
attribute or element content in the result. It is therefore not
recommended that XInclude processors expose
<emph role="infoset-property">namespace attributes</emph> in the
result. If this is unavoidable, the implementation
<termref def="dt-must">may</termref> add
<emph role="info-item">attribute information items</emph> to the
<emph role="infoset-property">namespace attributes</emph> property
in order to approximate the information conveyed by
<emph role="infoset-property">in-scope namespaces</emph>.</p>
</div3>
<div3 id="base">
<head>Base URI Fixup</head>
<p>The base URI property of the acquired infoset is not changed as
a result of merging the infoset, and remains unchanged after merging.
Thus relative URI references in the included infoset resolve to the same
URI despite being included into a document with a potentially
different base URI in effect.  <att>xml:base</att> attributes are added
to the result infoset to indicate this fact.</p>
<p>Each <emph role="info-item">element information item</emph> in
the <termref def="dt-top-level-included-items">top-level included
items</termref> which has a different <emph role="infoset-property">base
URI</emph> than its <termref def="dt-include-parent">include parent</termref>
has an <emph role="info-item">attribute information item</emph> added to its
<emph role="infoset-property">attributes</emph> property.  This attribute has the following properties:</p>
<olist>
<item>
<p>A <emph role="infoset-property">namespace name</emph> of
<code>http://www.w3.org/XML/1998/namespace</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">local name</emph> of
<code>base</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">prefix</emph> of
<code>xml</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">normalized value</emph>
equal to either the <emph role="infoset-property">base
URI</emph> of the element, or an equivalent URI reference
relative to the <emph role="infoset-property">base URI</emph>
of the include parent.  The circumstances in which a relative
URI is desirable, and how to compute such a relative URI,
are implementation-dependent.</p>
</item>
<item>
<p>A <emph role="infoset-property">specified</emph> flag
indicating that this attribute was actually specified in the
start-tag of its element.</p>
</item>
<item>
<p>An <emph role="infoset-property">attribute type</emph> of
<code>CDATA</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">references</emph> property
with no value.</p>
</item>
<item>
<p>An <emph role="infoset-property">owner element</emph> of the
information item of the element.</p>
</item>
</olist>
<p>If an <att>xml:base</att> attribute information item is already
present, it is replaced by the new attribute.</p>
</div3>
<div3 id="language">
<head>Language Fixup</head>
<p>While the <code>xml:lang</code> attribute is described as inherited
by XML, the XML Information Set makes no provision for preserving the
inheritance of this property through document composition such as XInclude
provides.  This section introduces a <emph role="infoset-property">language</emph>
property which records the scope of <code>xml:lang</code> information in
order to preserve it during inclusion.</p>
<p>An XInclude processor <termref def="dt-must">should</termref> augment
the <termref def="dt-source-infoset">source infoset</termref> and the
<termref def="dt-acquired-infoset">acquired infoset</termref> by adding
the <emph role="infoset-property">language</emph> property to each
<emph role="info-item">element information item</emph>.  The value of
this property is the <emph role="infoset-property">normalized value</emph>
of the <code>xml:lang</code> attribute appearing on that element if one
exists, with <att>xml:lang=""</att> resulting in no value, otherwise it
is the value of the <emph role="infoset-property">language</emph> property
of the element's parent element if one exists, otherwise the property
has no value.</p>
<p>Each <emph role="info-item">element information item</emph> in the
<termref def="dt-top-level-included-items">top-level included items</termref>
which has a different value of <emph role="infoset-property">language</emph>
than its <termref def="dt-include-parent">include parent</termref> (taking
case-insensitivity into account per <bibref ref="RFC3066"/>), or that has
a value if its <termref def="dt-include-parent">include parent</termref> is
a <emph role="info-item">document information item</emph>, has an
<emph role="info-item">attribute information item</emph> added to its
<emph role="infoset-property">attributes</emph> property.  This attribute
has the following properties:</p>
<olist>
<item>
<p>A <emph role="infoset-property">namespace name</emph> of
<code>http://www.w3.org/XML/1998/namespace</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">local name</emph> of
<code>lang</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">prefix</emph> of <code>xml</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">normalized value</emph> equal to
the <emph role="infoset-property">language</emph> property of the
element.  If the <emph role="infoset-property">language</emph> property
has no value, the normalized value is the empty string.</p>
</item>
<item>
<p>A <emph role="infoset-property">specified</emph> flag indicating
that this attribute was actually specified in the start-tag of its
element.</p>
</item>
<item>
<p>An <emph role="infoset-property">attribute type</emph> of
<code>CDATA</code>.</p>
</item>
<item>
<p>A <emph role="infoset-property">references</emph> property with
no value.</p>
</item>
<item>
<p>An <emph role="infoset-property">owner element</emph> of the
information item of the element.</p>
</item>
</olist>
<p>If an <att>xml:lang</att> attribute information item is already present,
it is replaced by the new attribute.</p>
<note>
<p>The <code>xml:space</code> attribute is not treated specially by
XInclude.</p>
</note>
</div3>
<div3 id="properties">
<head>Properties Preserved by the Infoset</head>
<p>As an infoset transformation, XInclude operates on the logical
structure of XML documents, not on their text serialization.  All
properties of an information item described in <bibref ref="XMLIS"/>
other than those specifically modified by this specification are
preserved during inclusion.  The <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph>
properties introduced in this specification is also preserved.
Extension properties such as
<bibref ref="XMLSchemas"/> Post Schema Validation Infoset (PSVI)
properties are discarded by default.  However, an XInclude
processor <termref def="dt-must">may</termref>, at user option,
preserve these properties in the resulting infoset if they
are correct according to the specification describing the
semantics of the extension properties.</p>
<p>For instance, the PSVI <emph role="infoset-property">validity</emph>
property describes the conditions of ancestors and descendants.
Modification of ancestors and descendants during the XInclude
process can render the value of this property inaccurate.  By
default, XInclude strips this property, but by user option the
property could be recalculated to obtain a semantically accurate
value.  Precisely how this is accomplished is outside the scope
of this specification.</p>
</div3>
</div2>
</div1>
<div1 id="conformance">
<head>Conformance</head>
<div2 id="markup">
<head>Markup Conformance</head>
<p>An <emph role="info-item">element information item</emph> conforms
to this specification if it meets the structural requirements for
include elements defined in this specification.  This specification
imposes no particular constraints on DTDs or XML schemas; conformance
applies only to elements and attributes.</p>
</div2>
<div2 id="application">
<head>Application Conformance</head>
<p>An application conforms to XInclude if it:</p>
<ulist>
<item>
<p>supports <bibref ref="XML"/> and <bibref ref="XMLNS"/>
or <bibref ref="XML11"/> and <bibref ref="XMLNS11"/>,
the <bibref ref="XMLIS"/>, <bibref ref="XMLBase"/>, the
<bibref ref="XPCore"/>, and the <bibref ref="XPElement"/>;</p>
</item>
<item>
<p>stops processing when a <termref def="dt-error">fatal
error</termref> is encountered;</p>
</item>
<item>
<p>observes the mandatory conditions
(<termref def="dt-must">must</termref>) set forth in this
specification, and for any optional conditions
(<termref def="dt-must">should</termref> and
<termref def="dt-must">may</termref>) it chooses to observe,
observes them in the way prescribed; and</p>
</item>
<item>
<p>performs markup conformance testing according to all the
conformance constraints appearing in this specification.</p>
</item>
</ulist>
<p>Support for the <bibref ref="XPointer"/> is not mandatory for
full XInclude conformance.  Authors are advised that use of
xpointer() and other XPointer schemes than element() might not be
supported by all conformant XInclude implementations.</p>
</div2>
<div2 id="infoset">
<head>XML Information Set Conformance</head>
<p>This specification conforms to the <bibref ref="XMLIS"/>.
The following information items <termref def="dt-must">must</termref>
be present in the input infosets to enable correct processing:</p>
<ulist>
<item>
<p>
<emph role="info-item">Document information items</emph> with
<emph role="infoset-property">children</emph> and
<emph role="infoset-property">base URI</emph> properties.</p>
</item>
<item>
<p>
<emph role="info-item">Element information items</emph> with
<emph role="infoset-property">namespace name</emph>,
<emph role="infoset-property">local name</emph>,
<emph role="infoset-property">children</emph>,
<emph role="infoset-property">attributes</emph>,
<emph role="infoset-property">base URI</emph> and
<emph role="infoset-property">parent</emph> properties.</p>
</item>
<item>
<p>
<emph role="info-item">Attribute information items</emph> with
<emph role="infoset-property">namespace name</emph>,
<emph role="infoset-property">local name</emph> and
<emph role="infoset-property">normalized value</emph> properties.</p>
</item>
</ulist>
<p>Additionally, XInclude processing might generate the following
kinds of information items in the result:</p>
<ulist>
<item>
<p>
<emph role="info-item">Character information items</emph> with
            <emph role="infoset-property">character code</emph>,
            <emph role="infoset-property">element content whitespace</emph> and
            <emph role="infoset-property">parent</emph> properties.</p>
</item>
</ulist>
<p>XInclude extends the infoset with the property
<emph role="infoset-property">include history</emph>, which
<termref def="dt-must">may</termref> appear on the following
types of information items in the result:</p>
<ulist>
<item>
<p>
<emph role="info-item">Element information items</emph>.</p>
</item>
<item>
<p>
<emph role="info-item">Processing instruction information items</emph>.</p>
</item>
<item>
<p>
<emph role="info-item">Comment information items</emph>.</p>
</item>
<item>
<p>
<emph role="info-item">Character information items</emph>.</p>
</item>
</ulist>
<p>XInclude also extends the infoset with the property
<emph role="infoset-property">language</emph>, which
<termref def="dt-must">may</termref> appear on
<emph role="info-item">element information items</emph>
in the result.</p>
</div2>
</div1>
</body>
<back>
<div1 id="references">
<head>References</head>
<blist>
<bibl id="RFC2119" key="IETF RFC 2119" href="http://www.ietf.org/rfc/rfc2119.txt">
<titleref href="http://www.ietf.org/rfc/rfc2119.txt">RFC 2119: Key
words for use in RFCs to Indicate Requirement Levels</titleref>.
Internet Engineering Task Force, 1997.</bibl>
<bibl id="RFC3629" key="IETF RFC 3629" href="http://www.ietf.org/rfc/rfc3629.txt">
<titleref href="http://www.ietf.org/rfc/rfc3629.txt">RFC 3629: UTF-8,
a transformation format of ISO 10646</titleref>.
Internet Engineering Task Force, 2003.</bibl>
<bibl id="RFC2396" key="IETF RFC 2396" href="http://www.ietf.org/rfc/rfc2396.txt">
<titleref href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396:
Uniform Resource Identifiers</titleref>. Internet Engineering
Task Force, 1995.</bibl>
<bibl id="RFC2732" key="IETF RFC 2732" href="http://www.ietf.org/rfc/rfc2732.txt">
<titleref href="http://www.ietf.org/rfc/rfc2732.txt">RFC 2732:
Format for Literal IPv6 Addresses in URL's</titleref>.
Internet Engineering Task Force, 1999.</bibl>
<bibl id="RFC3023" key="IETF RFC 3023" href="http://www.ietf.org/rfc/rfc3023.txt">
<titleref href="http://www.ietf.org/rfc/rfc3023.txt">RFC 3023:
XML Media Types</titleref>.
Internet Engineering Task Force, 2001.</bibl>
<bibl id="RFC3987" key="IETF RFC 3987" href="http://www.ietf.org/rfc/rfc3987.txt">
<titleref href="http://www.ietf.org/rfc/rfc3987.txt">RFC 3987:
Internationalized Resource Identifiers (IRIs)</titleref>.
Internet Engineering Task Force, 2005.</bibl>
<bibl diff="add" id="RFC4288" key="IETF RFC 4288" href="http://www.ietf.org/rfc/rfc4288.txt">
<titleref href="http://www.ietf.org/rfc/rfc4288.txt">RFC 4288:
Media Type Specifications and Registration Procedures</titleref>.
Internet Engineering Task Force, 2005.</bibl>
<bibl id="RFC5147" key="IETF RFC 5147" href="http://www.ietf.org/rfc/rfc5147.txt">
<titleref href="http://www.ietf.org/rfc/rfc5147.txt">RFC 5147:
URI Fragment Identifiers for the text/plain Media Type</titleref>.
Internet Engineering Task Force, 2008.</bibl>
<bibl id="Unicode" key="Unicode">The Unicode Consortium.
<titleref href="http://www.unicode.org/unicode/standard/versions/">The
Unicode Standard, Version 4.0.</titleref> Reading, Mass.: Addison-Wesley,
2003, as updated from time to time by the publication of new versions. (See
<loc href="http://www.unicode.org/unicode/standard/versions/">
http://www.unicode.org/unicode/standard/versions/</loc> for the latest version
and additional information on versions of the standard and of the Unicode
Character Database).</bibl>
<bibl id="XML" key="XML 1.0" href="http://www.w3.org/TR/2004/REC-xml-20040204/">
Tim Bray, Jean Paoli, C.M. Sperberg-McQueen, Eve Maler, Fran&#xE7;ois Yergeau, editors.
<titleref href="http://www.w3.org/TR/2004/REC-xml-20040204/">Extensible Markup
Language (XML) 1.0 (Third Edition)</titleref>,
World Wide Web Consortium, 2004.</bibl>
<bibl id="XML11" key="XML 1.1" href="http://www.w3.org/TR/2004/REC-xml11-20040204/">
Tim Bray, Jean Paoli, C.M. Sperberg-McQueen, Eve Maler, Fran&#xE7;ois Yergeau,
John Cowan, editors.
<titleref href="http://www.w3.org/TR/2004/REC-xml11-20040204/">Extensible Markup
Language (XML) 1.1</titleref>,
World Wide Web Consortium, 2004.</bibl>
<bibl id="XMLBase" key="XML Base" href="http://www.w3.org/TR/2001/REC-xmlbase-20010627/">
Jonathan Marsh, editor.
<titleref href="http://www.w3.org/TR/2001/REC-xmlbase-20010627/">XML Base</titleref>.
World Wide Web Consortium, 2001.</bibl>
<bibl id="XMLIS" key="XML Information Set" href="http://www.w3.org/TR/2004/REC-xml-infoset-20040204/">
John Cowan and Richard Tobin, editors.
<titleref href="http://www.w3.org/TR/2004/REC-xml-infoset-20040204/">XML Information
Set (Second Edition)</titleref>. World Wide Web Consortium, 2004.</bibl>
<bibl id="XMLNS" key="Namespaces in XML" href="http://www.w3.org/TR/1999/REC-xml-names-19990114/">
Tim Bray, Dave Hollander, and Andrew Layman, editors.
<titleref href="http://www.w3.org/TR/1999/REC-xml-names-19990114/">Namespaces in XML</titleref>.
World Wide Web Consortium, 1999.</bibl>
<bibl id="XMLNS11" key="Namespaces in XML 1.1" href="http://www.w3.org/TR/2004/REC-xml-names11-20040204/">Tim Bray, Dave Hollander, Andrew Layman, Richard Tobin, editors.
<titleref href="http://www.w3.org/TR/2004/REC-xml-names11-20040204/">Namespaces in XML 1.1</titleref>.
World Wide Web Consortium, 2004.</bibl>
<bibl id="XPCore" key="XPointer Framework" href="http://www.w3.org/TR/2003/REC-xptr-framework-20030325/">
Paul Grosso, Eve Maler, Jonathan Marsh, Norman Walsh, editors.
<titleref href="http://www.w3.org/TR/2003/REC-xptr-framework-20030325/">XPointer Framework</titleref>.
World Wide Web Consortium, 2003.</bibl>
<bibl id="XPElement" key="XPointer element() scheme" href="http://www.w3.org/TR/2003/REC-xptr-element-20030325/">
Paul Grosso, Eve Maler, Jonathan Marsh, Norman Walsh, editors.
<titleref href="http://www.w3.org/TR/2003/REC-xptr-element-20030325/">XPointer element()
Scheme</titleref>.
World Wide Web Consortium, 2003.</bibl>
</blist>
</div1>
<inform-div1 id="nn-refs">
<head>References</head>
<blist>
<bibl id="RFC2616" key="IETF RFC 2616" href="http://www.ietf.org/rfc/rfc2616.txt">
<titleref href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616:
Hypertext Transfer Protocol -- HTTP/1.1</titleref>.
Internet Engineering Task Force, 1999.</bibl>
<bibl id="RFC3066" key="IETF RFC 3066" href="http://www.ietf.org/rfc/rfc3066.txt">
<titleref href="http://www.ietf.org/rfc/rfc3066.txt">RFC 3066:
Tags for the Identification of Languages</titleref>.
Internet Engineering Task Force, 2001.</bibl>
<bibl id="XInclude-note" key="XML Inclusion Proposal" href="http://www.w3.org/TR/1999/NOTE-xinclude-19991123">
Jonathan Marsh, David Orchard, editors.
<titleref href="http://www.w3.org/TR/1999/NOTE-xinclude-19991123">XML
Inclusion Proposal (XInclude).</titleref>
World Wide Web Consortium, 2004.</bibl>
<bibl id="XLink" key="XML Linking Language" href="http://www.w3.org/TR/2001/REC-xlink-20010627/">
Steve DeRose, Eve Maler, David Orchard, and Ben Trafford, editors.
<titleref href="http://www.w3.org/TR/2001/REC-xlink-20010627/">XML Linking Language (XLink).</titleref>
World Wide Web Consortium, 2001.</bibl>
<bibl id="XPointer" key="XPointer xpointer() Scheme" href="http://www.w3.org/TR/2002/WD-xptr-xpointer-20021219/">
Steve DeRose, Ron Daniel, Eve Maler, editors.
<titleref href="http://www.w3.org/TR/2002/WD-xptr-xpointer-20021219/">XPointer
xpointer() Scheme</titleref>.
World Wide Web Consortium, 2002.</bibl>
<bibl id="XPath" key="XPath 1.0" href="http://www.w3.org/TR/1999/REC-xpath-19991116">
James Clark, Steve DeRose, editors.
<titleref href="http://www.w3.org/TR/1999/REC-xpath-19991116">XML Path Language (XPath)
Version 1.0.</titleref>
World Wide Web Consortium, 1999.</bibl>
<!--<bibl id="IRIdraft" key="IRI draft" href="http://www.ietf.org/internet-drafts/draft-duerst-iri-11.txt">
<titleref href="http://www.ietf.org/internet-drafts/draft-duerst-iri-11.txt">Internationalized
Resource Identifiers (IRIs)</titleref>.</bibl>-->
<bibl id="CharMod" key="Character Model" href="http://www.w3.org/TR/charmod-norm/">
Martin J. D&#xFC;rst, Fran&#xE7;ois Yergeau, Misha Wolf, Asmus Freytag, Tex Texin.
<titleref href="http://www.w3.org/TR/charmod-norm/">Character Model for the
World Wide Web 1.0: Normalization</titleref>.
World Wide Web Consortium, 2001.</bibl>
<bibl id="XMLSchemas" key="XML Schemas" href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/">
Henry S. Thompson, David Beech, Murray Maloney, Noah Mendelsohn, editors.
<titleref href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/">XML Schema Part 1:
Structures.</titleref>
World Wide Web Consortium, 2001.</bibl>
<bibl id="XSL-FO" key="XSL-FO" href="http://www.w3.org/TR/2001/REC-xsl-20011015/">
Sharon Adler <emph>et al</emph>.
<titleref href="http://www.w3.org/TR/2001/REC-xsl-20011015/">Extensible Stylesheet
Language (XSL)</titleref>.
World Wide Web Consortium, 2001.</bibl>
<bibl id="XHTML" key="XHTML" href="http://www.w3.org/TR/2002/REC-xhtml1-20020801/">
Steven Pemberton <emph>et al</emph>.
<titleref href="http://www.w3.org/TR/2002/REC-xhtml1-20020801/">XHTML 1.0 The Extensible
HyperText Markup Language (Second Edition)</titleref>.
World Wide Web Consortium, 2002.</bibl>
</blist>
</inform-div1>
<inform-div1 id="examples">
<head>Examples</head>
<div2 id="basic-example">
<head>Basic Inclusion Example</head>
<p>The following XML document contains an <code>xi:include</code> element
which points to an external document.  Assume the base URI of this document is
<code>http://www.example.org/document.xml</code>.</p>
<eg><![CDATA[<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>120 Mz is adequate for an average home user.</p>
  <xi:include href="disclaimer.xml"/>
</document>]]></eg>
<p>disclaimer.xml contains:</p>
<eg><![CDATA[<?xml version='1.0'?>
<disclaimer>
  <p>The opinions represented herein represent those of the individual
  and should not be interpreted as official policy endorsed by this
  organization.</p>
</disclaimer>]]></eg>
<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>120 Mz is adequate for an average home user.</p>
  <disclaimer xml:base="http://www.example.org/disclaimer.xml">
  <p>The opinions represented herein represent those of the individual
  and should not be interpreted as official policy endorsed by this
  organization.</p>
</disclaimer>
</document>]]></eg>
</div2>
<div2 id="text-example">
<head>Textual Inclusion Example</head>
<p>The following XML document includes a "working example" into
a document.</p>
<eg>&lt;?xml version='1.0'?&gt;
&lt;document xmlns:xi="http://www.w3.org/2001/XInclude"&gt;
  &lt;p&gt;This document has been accessed
  &lt;xi:include href="count.txt" parse="<phrase diff="chg">text/plain</phrase>"/&gt; times.&lt;/p&gt;
&lt;/document&gt;</eg>
<p>where count.txt contains:</p>
<eg><![CDATA[324387]]></eg>
<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>This document has been accessed
  324387 times.</p>
</document>]]></eg>
</div2>

<div2 id="xml-as-text-example">
<head>Textual Inclusion of XML Example</head>
<p>The following XML document includes a "working example" into
a document.</p>
<eg>&lt;?xml version='1.0'?&gt;
&lt;document xmlns:xi="http://www.w3.org/2001/XInclude"&gt;
  &lt;p&gt;The following is the source of the "data.xml" resource:&lt;/p&gt;
  &lt;example&gt;&lt;xi:include href="data.xml" parse="<phrase diff="chg">text/plain</phrase>"/&gt;&lt;/example&gt;
&lt;/document&gt;</eg>
<p>data.xml contains:</p>
<eg><![CDATA[<?xml version='1.0'?>
<data>
  <item><![CDATA[Brooks & Shields]]]]><![CDATA[></item>
</data>]]></eg>
<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source of the "data.xml" resource:</p>
  <example>&lt;?xml version='1.0'?&gt;
&lt;data&gt;
  &lt;item&gt;&lt;![CDATA[Brooks &amp; Shields]]&gt;&lt;/item&gt;
&lt;/data&gt;</example>
</document>]]></eg>
</div2>
<div2 id="fragment-example">
<head>Fragment Inclusion Example</head>
<p>The following illustrates the results of including fragments of
another XML document.  Assume the base URI of the document is
<code>http://www.example.com/JoeSmithQuote.xml</code>.</p>
<eg><![CDATA[<?xml version='1.0'?>
<price-quote xmlns:xi="http://www.w3.org/2001/XInclude">
  <prepared-for>Joe Smith</prepared-for>
  <good-through>20040930</good-through>
  <xi:include href="price-list.xml" xpointer="w002-description"/>
  <volume>40</volume>
  <xi:include href="price-list.xml" xpointer="element(w002-prices/2)"/>
</price-quote>]]></eg>
<p>price-list.xml references a DTD which declares the <att>id</att>
attributes as type <code>ID</code>, and contains:</p>
<eg><![CDATA[<?xml version='1.0'?>
<!DOCTYPE price-list SYSTEM "price-list.dtd">
<price-list xml:lang="en-us">
  <item id="w001">
    <description id="w001-description">
      <p>Normal Widget</p>
    </description>
    <prices id="w001-prices">
      <price currency="USD" volume="1+">39.95</price>
      <price currency="USD" volume="10+">34.95</price>
      <price currency="USD" volume="100+">29.95</price>
    </prices>
  </item>
  <item id="w002">
    <description id="w002-description">
      <p>Super-sized widget with bells <i>and</i> whistles.</p>
    </description>
    <prices id="w002-prices">
      <price currency="USD" volume="1+">59.95</price>
      <price currency="USD" volume="10+">54.95</price>
      <price currency="USD" volume="100+">49.95</price>
    </prices>
  </item>
</price-list>]]></eg>
<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<?xml version='1.0'?>
<price-quote xmlns:xi="http://www.w3.org/2001/XInclude">
  <prepared-for>Joe Smith</prepared-for>
  <good-through>20040930</good-through>
  <description id="w002-description" xml:lang="en-us"
               xml:base="http://www.example.com/price-list.xml">
    <p>Super-sized widget with bells <i>and</i> whistles.</p>
  </description>
  <volume>40</volume>
  <price currency="USD" volume="10+" xml:lang="en-us"
         xml:base="http://www.example.com/price-list.xml">54.95</price>
</price-quote>]]></eg>
</div2>
<div2 id="range-example">
<head>Range Inclusion Example</head>
<p>The following illustrates the results of including a range
specified by an XPointer.  Assume the base URI of the document
is <code>http://www.example.com/document.xml</code>.</p>
<eg><![CDATA[<?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>]]></eg>
<p>source.xml contains:</p>
<eg><![CDATA[<chapter>
  <p>Sentence 1.  Sentence 2.</p>
  <p><i>Sentence 3.  Sentence 4.</i>  Sentence 5.</p>
</chapter>]]></eg>
<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<?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>]]></eg>
</div2>

<div2 id="text-example-2">
<head>Textual Inclusion Examples with RFC5147 Fragment Identifiers</head>
<p>The following XML document includes several lines of a code listing.</p>

<eg>&lt;?xml version='1.0'?&gt;
&lt;document xmlns:xi="http://www.w3.org/2001/XInclude"&gt;
&lt;p&gt;This example includes just the ‘use' lines from a Perl script.&lt;/p&gt;
&lt;pre&gt;&lt;xi:include parse="<phrase diff="chg">text/plain</phrase>" frigid="line=2,6" href="code.pl"/&gt;&lt;/pre&gt;
&lt;p&gt;There are four of them.&lt;/p&gt;
&lt;/document&gt;</eg>

<p>where code.pl contains:</p>
<eg><![CDATA[#!/usr/bin/perl -- # --*-Perl-*--

use strict;
use English;
use Getopt::Std;
use vars qw($opt_p $opt_q $opt_u $opt_m);

my $usage = "Usage: $0 [-q] [-u|-p|-m] file [ file ... ]\n";

die $usage if ! getopts('qupm');

die $usage if ($opt_p + $opt_u + $opt_m) != 1;

my $file = shift @ARGV || die $usage;

my $opt = '-u' if $opt_u;
$opt = '-p' if $opt_p;
$opt = '-m' if $opt_m;

while ($file) {
    print "Converting $file to $opt linebreaks.\n" if !$opt_q;
    open (F, "$file");
    binmode F;
    read (F, $_, -s $file);
    close (F);

    s/\r\n/\n/sg;
    s/\r/\n/sg;

    if ($opt eq '-p') {
	s/\n/\r\n/sg;
    } elsif ($opt eq '-m') {
	s/\n/\r/sg;
    }

    open (F, ">$file");
    binmode F;
    print F $_;
    close (F);

    $file = shift @ARGV;
}]]></eg>

<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<document xmlns:xi="http://www.w3.org/2001/XInclude">
<p>This example includes just the ‘use' lines from a Perl script.</p>
<pre>use strict;
use English;
use Getopt::Std;
use vars qw($opt_p $opt_q $opt_u $opt_m);
</pre>
<p>There are four of them.</p>
</document>]]></eg>

<p>This XML document includes a range of characters from the same code listing.</p>

<eg>&lt;?xml version='1.0'?&gt;
&lt;document xmlns:xi="http://www.w3.org/2001/XInclude"&gt;
&lt;p&gt;This example includes a range of characters.&lt;/p&gt;
&lt;pre&gt;&lt;xi:include parse="<phrase diff="chg">text/plain</phrase>" fragid="char=100,200;length=758,UTF-8" href="code.pl"/&gt;&lt;/pre&gt;
&lt;/document&gt;</eg>

<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<document xmlns:xi="http://www.w3.org/2001/XInclude">
<p>This example includes a range of characters.</p>
<pre>_q $opt_u $opt_m);

my $usage = "Usage: $0 [-q] [-u|-p|-m] file [ file ... ]\n";

die $usage if ! ge</pre>
</document>]]></eg>
</div2>

<div2 id="att-copy-example">
<head>Attribute Copying Example</head>
<p>The following XML document includes the same element twice, using attribute
copying to allow a subsequent process to distinguish them.</p>

<eg><![CDATA[<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude"
          xmlns:eg="http://example.org/namespace/example">
<p>This example includes a “definition” paragraph from some document
twice using attribute copying.</p>

<xi:include eg:root="one" href="src.xml" xpointer="element(def)"/>

<xi:include eg:root="two" href="src.xml" xpointer="element(def)"/>

</document>
]]></eg>

<p>where src.xml contains:</p>
<eg><![CDATA[<document>
  <para>Some paragraph.</para>
  <para xml:id="def">Some definition.</para>
  <para>Some other paragraph.</para>
</document>]]></eg>

<p>The infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<document xmlns:xi="http://www.w3.org/2001/XInclude"
          xmlns:eg="http://example.org/namespace/example">
   <p>This example includes a “definition” paragraph from some document
twice using attribute copying.</p>

   <para eg:root="one" xml:id="def">Some definition.</para>

   <para eg:root="two" xml:id="def">Some definition.</para>

</document>]]></eg>
</div2>

<div2 id="fallback-example">
<head>Fallback Example</head>
<p>The following XML document relies on the fallback mechanism to
succeed in the event that the resources <code>example.txt</code> and
<code>fallback-example.txt</code> are not available..</p>
<eg>&lt;?xml version='1.0'?&gt;
&lt;div&gt;
  &lt;xi:include href="example.txt" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude"&gt;
    &lt;xi:fallback&gt;&lt;xi:include href="fallback-example.txt" parse="<phrase diff="chg">text/plain</phrase>"&gt;
        &lt;xi:fallback&gt;&lt;a href="mailto:bob@example.org"&gt;Report error&lt;/a&gt;&lt;/xi:fallback&gt;
      &lt;/xi:include&gt;&lt;/xi:fallback&gt;
  &lt;/xi:include&gt;
&lt;/div&gt;</eg>
<p>If neither <code>example.txt</code> nor <code>fallback-example.txt</code>
are available, the infoset resulting from resolving inclusions on this document
is the same (except for the <emph role="infoset-property">include history</emph>
and <emph role="infoset-property">language</emph> properties)
as that of the following document:</p>
<eg><![CDATA[<?xml version='1.0'?>
<div>
  <a href="mailto:bob@example.org">Report error</a>
</div>]]></eg>
</div2>
</inform-div1>
</back>
</spec>
