<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/XML/2000/06spec/xmlspec-v21.xslt"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification Version 2.0//EN"
                       "/XML/1998/06/xmlspec-v21.dtd" [
<!ENTITY year "2000">
<!ENTITY month "September">
<!ENTITY MM "09">
<!ENTITY day "08">
<!ENTITY MMDD "&MM;&day;">
<!ENTITY internalXMLBase "http://www.w3.org/XML/Group/&year;/&MM;/CR-xmlbase-&year;&MMDD;">
<!ENTITY externalXMLBase "http://www.w3.org/TR/&year;/CR-xmlbase-&year;&MMDD;">
<!ENTITY XMLBase "&externalXMLBase;">
<!ENTITY LatestXMLBase "http://www.w3.org/TR/xmlbase">
<!ENTITY XMLBaseDoC "http://www.w3.org/2000/06/xmlbase-comments-20000607">
]>
<spec w3c-doctype="cr" status="final">
<header>
  <title>XML Base</title>
  <w3c-designation>xml-base-&year;&MMDD;</w3c-designation>
  <w3c-doctype>W3C Candidate Recommendation</w3c-doctype>
  <pubdate><day>&day;</day><month>&month;</month><year>&year;</year></pubdate>
  <publoc>
    <loc href="&XMLBase;">&XMLBase;</loc>
    <loc role="available-format" href="&XMLBase;/Overview.html">HTML</loc>
    <loc role="available-format" href="&XMLBase;/Overview.xml">XML</loc>
  </publoc>
  <prevlocs>
    <loc href="http://www.w3.org/TR/2000/WD-xmlbase-20000607">http://www.w3.org/TR/2000/WD-xmlbase-20000607</loc>
    <loc href="http://www.w3.org/TR/2000/WD-xmlbase-20000221">http://www.w3.org/TR/2000/WD-xmlbase-20000221</loc>
    <loc href="http://www.w3.org/TR/1999/WD-xmlbase-19991220">http://www.w3.org/TR/1999/WD-xmlbase-19991220</loc>
  </prevlocs>
  <latestloc>
    <loc href="&LatestXMLBase;">&LatestXMLBase;</loc>
  </latestloc>
  <authlist>
  <author>
    <name>Jonathan Marsh</name>
    <affiliation>Microsoft</affiliation>
    <email href="mailto:jmarsh@microsoft.com">jmarsh@microsoft.com</email>
  </author>
  </authlist>

  <status>
    <p>This XML Base specification is a <loc href="/Consortium/Process/Process-19991111/process.html#RecsCR">Candidate
    Recommendation</loc> of the <loc href="http://www.w3.org/">World Wide Web
    Consortium</loc>. (For background on this work, please see the <loc href="http://www.w3.org/XML/Activity">XML
    Activity Statement</loc>.) This specification is considered stable by the <loc
    href="http://www.w3.org/XML/Activity#linking-wg">XML Linking Working Group</loc>
    .</p>

    <p>The Working Group invites implementation feedback during this period. Comments
    on this document should be sent to the public mailing list 
    <loc href="mailto:www-xml-linking-comments@w3.org">www-xml-linking-comments@w3.org</loc>
    (<loc href="http://lists.w3.org/Archives/Public/www-xml-linking-comments/">archive</loc>)
    by December 8 2000.
    </p>

    <p>A list of current W3C Recommendations and other technical documents can
    be found at <loc href="http://www.w3.org/TR">http://www.w3.org/TR</loc>.</p>
  </status>

  <abstract>
    <p>This document proposes a facility, similar to that of HTML BASE, 
    for defining base URIs for parts of XML documents.</p>
  </abstract>

  <langusage>
    <language id="EN">English</language>
  </langusage>
  <revisiondesc>
    <slist>
      <sitem>November 11, 1999: Created v0.1.</sitem>
      <sitem>November 18, 1999: v0.2 Changed xml:base to xbase:base.</sitem>
      <sitem>December 2, 1999: v0.3 Changed xbase:base back to xml:base.</sitem>
      <sitem>December 3, 1999: v0.4 Minor editorial changes.</sitem>
      <sitem>February 10, 2000: v0.6 Removed remaining issues.</sitem>
      <sitem>May 24, 2000: v0.7 Integrated Disposition of Comments 
        resolutions, prepared for second Last Call.</sitem>
      <sitem>August 30, 2000: Final modifications requested by W3C
        staff for CR.</sitem>
    </slist>
  </revisiondesc>
</header>

<body>
<div1 id="introduction">
  <head>Introduction</head>

  <p>The XML Linking Language <bibref ref="XLink"/> defines Extensible 
  Markup Language (XML) 1.0 <bibref ref="XML"/> constructs to describe 
  links between resources.  One of the stated requirements on XLink is to support HTML 
  <bibref ref="HTML40"/> linking constructs in a generic way.  The HTML BASE element is 
  one such construct which the XLink Working Group has considered.  BASE allows authors 
  to explicitly specify a document's base URI for the purpose of resolving relative URIs  
  in links to external images, applets, form-processing programs, style sheets, and so 
  on.</p>
  
  <p>This document describes a mechanism for providing base URI services to XLink, but 
  as a modular specification so that other XML applications benefiting from additional 
  control over relative URIs but not built upon XLink can also make use of it.  The 
  syntax consists of a single XML attribute named <att>xml:base</att>.</p>

  <p>The deployment of XML Base is through normative reference by new 
  specifications, for example XLink and the XML Infoset.  Applications 
  and specifications built upon these new technologies will natively 
  support XML Base.  The behavior of <att>xml:base</att> attributes 
  in applications based on specifications that do not have direct or
  indirect normative reference to XML Base is undefined.</p>
</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>The terms <term>base URI</term> and <term>relative URI</term> 
  are used in this specification as they are defined in <bibref ref="RFC2396"/>.</p>
</div1>

<div1 id="syntax">
  <head><att>xml:base</att> Attribute</head>

  <p>The attribute <att>xml:base </att> <termref def="dt-must">may</termref> be inserted in XML documents to 
  specify a base URI other than the base URI of the document or external 
  entity.  The value of this attribute is interpreted as a URI Reference as 
  defined in RFC 2396 <bibref ref="RFC2396"/>, after processing
  according to Section 3.1.</p>
  
  <p>In namespace-aware XML processors, the "xml" prefix is bound to the namespace 
  name <code>http://www.w3.org/XML/1998/namespace</code> as described in Namespaces in XML
  <bibref ref="XMLNS"/>.  Note that <att>xml:base</att> can be still used by 
  non-namespace-aware processors.</p>

  <p>An example of <att>xml:base</att> in a simple document containing
  XLinks follows.  XLink normatively references XML Base for interpretation
  of relative URI references in <att>xlink:href</att> attributes.</p>
  
  <eg><![CDATA[<?xml version="1.0"?>
<doc xml:base="http://example.org/today/"
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <head>
    <title>Virtual Library</title>
  </head>
  <body>
    <paragraph>See <link xlink:type="simple" xlink:href="new.xml">what's
      new</link>!</paragraph>
    <paragraph>Check out the hot picks of the day!</paragraph>
    <olist xml:base="/hotpicks/">
      <item>
        <link xlink:type="simple" xlink:href="pick1.xml">Hot Pick #1</link>
      </item>
      <item>
        <link xlink:type="simple" xlink:href="pick2.xml">Hot Pick #2</link>
      </item>
      <item>
        <link xlink:type="simple" xlink:href="pick3.xml">Hot Pick #3</link>
      </item>
    </olist>
  </body>
</doc>]]></eg>

  <p>The URIs in this example resolve to full URIs as follows:</p>
  <ulist spacing="compact">
    <item><p>"what's new"  resolves to the URI "http://example.org/today/new.xml"</p></item>
    <item><p>"Hot Pick #1"  resolves to the URI "http://example.org/hotpicks/pick1.xml"</p></item>
    <item><p>"Hot Pick #2"  resolves to the URI "http://example.org/hotpicks/pick2.xml"</p></item>
    <item><p>"Hot Pick #3"  resolves to the URI "http://example.org/hotpicks/pick3.xml"</p></item>
  </ulist>
 
<div2>
  <head>URI Reference Encoding and Escaping</head>
  
  <p>The set of characters allowed in <att>xml:base</att> attributes
  is the same as for XML, namely <bibref ref="Unicode"/>. However, some 
  Unicode characters are disallowed from URI references, and thus 
  processors <termref def="dt-must">must</termref> encode and escape these 
  characters to obtain a valid URI reference from the attribute value.</p>

  <p>The disallowed characters include all non-ASCII characters, plus the 
  excluded characters listed in Section 2.4 of <bibref ref="RFC2396"/>, 
  except for the number sign (#) and percent sign (%) characters and the 
  square bracket characters re-allowed in <bibref ref="RFC2732"/>.
  Disallowed characters <termref def="dt-must">must</termref> be escaped as follows:</p>

  <olist>
    <item><p>Each disallowed character is converted to UTF-8 <bibref ref="RFC2279"/>
      as one or more bytes.</p></item>
    <item><p>Any bytes corresponding to a disallowed character are escaped 
      with the URI escaping mechanism (that is, converted to %HH, where HH 
      is the hexadecimal notation of the byte value).</p></item>
    <item><p>The original character is replaced by the resulting character
      sequence.</p></item>
  </olist>
</div2>

</div1>

<div1 id="resolution">
  <head>Resolving Relative URIs</head>

<div2>
  <head>Relation to RFC 2396</head>
  <p>RFC 2396 <bibref ref='RFC2396'/> provides for base URI information to be
  embedded within a document.  The rules for determining the base URI can be 
  summarized as follows (highest priority to lowest):</p>
      
  <olist>
    <item><p>The base URI is embedded in the document's content.</p></item>
    <item><p>The base URI is that of the encapsulating entity (message, 
      document, or none).</p></item>
    <item><p>The base URI is the URI used to retrieve the entity.</p></item>
    <item><p>The base URI is defined by the context of the application.</p></item>
  </olist>
  
  <note><p>The term "entity" in points #2 and #3 above uses the RFC 2396
  meaning of the term.  Elsewhere in this document the term "entity"
  is used in the XML sense.</p></note>
  
  <p>This document specifies the details of rule #1 for embedding
  base URI information in the specific case of XML documents.</p>
</div2>
  
<div2>
  <head>Granularity of base URI information</head>
  
  <p>Relative URIs appearing in an XML document are always resolved 
  relative to either an element, a document entity, or an external
  entity.  There is no provision for finer granularity, such as 
  per-attribute, per-character, or per-entity base information.
  Neither internal entities, whether declared in the internal 
  subset or in an external DTD, nor freestanding text (text not 
  enclosed in an element) in an external entity, are considered 
  to set a base URI separate from the base URI in scope for the 
  entity reference.</p>

  <p>The base URI of a document entity or an external entity is
  determined by RFC 2396 rules, namely, that the base URI is
  the URI used to retrieve the document entity or external 
  entity.</p>
    
  <p>The base URI of an element is:</p>
  
  <olist>
    <item>
      <p>the base URI specified by an <att>xml:base</att> attribute 
      on the element, if one exists, otherwise</p>
    </item>
    <item>
      <p>the base URI of the element's parent element within the 
      document or external entity, if one exists, otherwise</p>
    </item>
    <item>
      <p>the base URI of the document entity or external entity 
      containing the element.</p>
    </item>
  </olist>
</div2>
  
<div2>
  <head>Matching URIs with base URIs</head>

  <p>The base URI corresponding to a given relative URI appearing 
  in an XML document is determined as follows:</p>
  
  <ulist>
    <item>
      <p>The base URI for a URI reference appearing in text content 
      is the base URI of the element containing the text.</p>
    </item>
    <item>
      <p>The base URI for a URI reference appearing in an 
      <att>xml:base</att> attribute is the base URI of the parent 
      element of the element bearing the <att>xml:base</att> 
      attribute, if one exists, otherwise the base URI of the
      document entity or external entity containing the element.</p>
    </item>
    <item>
      <p>The base URI for a URI reference appearing in any other 
      attribute value, including default attribute values, is the 
      base URI of the element bearing the attribute.</p>
    </item>
    <item>
      <p>The base URI for a URI reference appearing in the content 
      of a processing instruction is the base URI of the parent
      element of the processing instruction, if one exists, 
      otherwise the base URI of the document entity or external 
      entity containing the processing instruction.</p>
    </item>
  </ulist>

  <note>
    <p>The presence of <att>xml:base</att> attributes might 
    lead to unexpected results in the case where the attribute value 
    is provided, not directly in the XML document entity, but via a 
    default attribute declared in an external entity. Such 
    declarations   might not be read by software which is based on
    a non-validating XML processor. Many XML applications fail to 
    require validating processors.  For correct operation with 
    such applications, <att>xml:base</att> values 
    <termref def="dt-must">should</termref>
    be provided either directly or via default attributes declared 
    in the internal subset of the DTD.</p>
  </note>

</div2>

</div1>

<div1 id="conformance">
  <head>Conformance</head>
  <p>An application conforms to XML Base if it calculates base URIs
  in accordance with the conditions set forth in this specification.</p>
</div1>

</body>

<back>
<div1>
<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="RFC2279" key="IETF RFC 2279" href="http://www.ietf.org/rfc/rfc2279.txt">
  <titleref href="http://www.ietf.org/rfc/rfc2279.txt">RFC 2279: UTF-8, a transformation format of ISO 10646</titleref>.
  Internet Engineering Task Force, 1998.
</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="Unicode" key="Unicode" href="http://www.unicode.org/unicode/standard/standard.html">
  <titleref href="http://www.unicode.org/unicode/standard/standard.html">The Unicode Standard.</titleref>
  The Unicode Consortium.
</bibl>

<bibl id="XML" key="XML" href="http://www.w3.org/TR/REC-xml">
  Tim Bray, Jean Paoli, and C.M. Sperberg-McQueen, editors. 
  <titleref href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0.</titleref>
  World Wide Web Consortium, 1998.
</bibl> 

<bibl id="XMLNS" key="XML Names" href="http://www.w3.org/TR/REC-xml-names/">
  Tim Bray, Dave Hollander, and Andrew Layman, editors.
  <titleref href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</titleref>.
  Textuality, Hewlett-Packard, and Microsoft. World Wide Web Consortium, 1999.
</bibl>

</blist>
</div1>

<inform-div1>
<head>References</head>

<blist>
<bibl id="HTML40" key="HTML 4.01" href="http://www.w3.org/TR/html4/">
  Dave Raggett, Arnaud Le Hors, Ian Jacobs, editors.
  <titleref href="http://www.w3.org/TR/html4/">HTML 4.01 Specification</titleref>.
  World Wide Web Consortium, 1999.
</bibl> 

<bibl id="XLink" key="XLink" href="http://www.w3.org/TR/xlink/">
  Steve DeRose, Eve Maler, David Orchard, and Ben Trafford, editors. 
  <titleref href="http://www.w3.org/TR/xlink/">XML Linking Language (XLink).</titleref>
  World Wide Web Consortium, 2000.
</bibl>

<bibl id="XMLDT" key="XML Datatypes" href="http://www.w3.org/TR/xmlschema-2/">
  Paul V. Biron, Ashok Malhotra, editors.
  <titleref href="http://www.w3.org/TR/xmlschema-2/">XML Schema Part 2: Datatypes.</titleref>
  World Wide Web Consortium Working Draft.
</bibl>

<bibl id="XHTML" key="XHTML" href="http://www.w3.org/TR/xhtml1/">
  Steven Pemberton, et al.
  <titleref href="http://www.w3.org/TR/xhtml1/">XHTML(TM) 1.0: The Extensible HyperText Markup Language.</titleref>
  World Wide Web Consortium, 2000.
</bibl>

<bibl id="XMLIS" key="XML Infoset" href="http://www.w3.org/TR/xml-infoset">
  John Cowan and David Megginson, editors.
  <titleref href="http://www.w3.org/TR/xml-infoset">XML Information Set</titleref>.
  World Wide Web Consortium, 1999.
</bibl>

<bibl id="XPath" key="XPath" href="http://www.w3.org/TR/xpath">
  James Clark and Steven DeRose, editors.
  <titleref href="http://www.w3.org/TR/xpath">XML Path Language</titleref>
  World Wide Web Consortium, 1999.
</bibl>

<bibl id="XSLT" key="XSLT" href="http://www.w3.org/TR/xslt">
  James Clark, editor.
  <titleref href="http://www.w3.org/TR/xslt">XSL Transformations</titleref>.
  World Wide Web Consortium, 1999.
</bibl>

</blist>
</inform-div1>

<inform-div1>
  <head>Impacts on Other Standards</head>

  <p>XML Base defines a mechanism for embedding base URI information
  within an XML document.  It does not define a mechanism to recognize
  which content or attribute values might contain URIs.  This is only
  known by the specifications or applications assigning semantics to
  the vocabulary.</p>
  
  <p>It is the intention of XML Base that future specifications
  and revisions of XML vocabularies identify which parts of the XML 
  document are considered to be URIs, and provide normative reference 
  to this specification in order to ensure that relative URIs are 
  treated consistently across XML documents.</p>
  
  <p>The impacts of XML Base on other standards (as of the publication date
  of this document) are described below.</p>

  <ulist>
    <item>
      <p>XML 1.0 <bibref ref="XML"/> uses URI references in the system identifiers
      for external entities.  Since these declarations appear outside of the document
      element (in an internal subset or external DTD), the scoping rules for
      <att>xml:base</att> prevent these URIs from being affected by the value of 
      <att>xml:base</att>.</p>
    </item>
    
    <item>
      <p>The XML Infoset <bibref ref="XMLIS"/> defines the base URI property
      of element information items.  The latest Infoset specification 
      supports XML Base for purposes of determining the value 
      of this property.  Interfaces, applications, and specifications
      referencing this infoset property will support XML Base natively.</p>
    </item>
    
    <item>
      <p>Namespaces in XML <bibref ref="XMLNS"/> uses URI references, which as currently
      defined should not be resolved relative to the base URI defined by 
      <att>xml:base</att> for the purposes of namespace identification.  Higher level 
      processes which dereference namespace URIs are not covered by the namespaces specification
      and might at their option specify that <att>xml:base</att> is honored for the 
      purposes of fetching resources at those URIs.</p>
    </item>
    
	  <item>
	    <p>The XPath <bibref ref="XPath"/> data model preserves neither base
	    URI information nor the boundaries of external entities and thus is insufficient 
	    to support resolution of relative URI references within these entities to be 
	    resolved correctly.  This includes relative URI references in <att>xml:base</att> 
	    attributes.</p>
    </item>
    
    <item>
	    <p>The XSLT <bibref ref="XSLT"/> extensions to the XPath data model do provide
	    for base URI information to be retained, but defines this information in a way
	    that precludes support for XML Base.  Future XSLT versions might want to require 
	    support for XML Base.</p>
	  </item>
	  
	  <item>
	    <p>XML Schema Part 2: Datatypes <bibref ref="XMLDT"/> defines a <att>uriReference</att> primitive
	    datatype.  The XML Datatypes specification might want to require that applications 
	    recognizing this datatype and resolving such URIs be aware of XML Base.</p>
	  </item>
	  
	  <item>
	    <p>The XLink <bibref ref="XLink"/> specification requires support for 
	    XML Base.</p>
	  </item>
	  
	  <item>
	    <p>XHTML <bibref ref="XHTML"/> uses URI references beyond those expressible in
	    XLink.  These URI references might be resolved by an application relative to the 
	    base URI defined by XML Base.  The XHTML specification might want to describe 
	    their level of support for XML Base.</p>
	  </item>
	  
	  </ulist>
</inform-div1>

</back>
</spec>
