XML Base (Second Edition) code { font-family: monospace; }
div.constraint, div.issue, div.note, div.notice { margin-left: 2em; }
ol.enumar { list-style-type: decimal; } ol.enumla { list-style-type: lower-alpha; } ol.enumlr { list-style-type: lower-roman; } ol.enumua { list-style-type: upper-alpha; } ol.enumur { list-style-type: upper-roman; }
div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} div.exampleOuter {border: 4px double gray; margin: 0em; padding: 0em} div.exampleInner { background-color: #d5dee3; border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; border-bottom-width: 4px; border-bottom-style: double; border-bottom-color: #d3d3d3; padding: 4px; margin: 0em } div.exampleWrapper { margin: 4px } div.exampleHeader { font-weight: bold; margin: 4px} This version: http://www.w3.org/TR/2009/REC-xmlbase-20090128/ Latest version: http://www.w3.org/TR/xmlbase/ Previous versions: http://www.w3.org/TR/2001/REC-xmlbase-20010627/ http://www.w3.org/TR/2008/PER-xmlbase-20080320/ Editors: Jonathan Marsh, Microsoft <[email protected]> Richard Tobin, University of Edinburgh <[email protected]> Please refer to the errata See also translations This document is also available in these non-normative formats: HTML with diff markup XML Copyright W3C ® MIT ERCIM Keio liability trademark document use This document describes 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 W3C technical reports index This document has been produced by the W3C XML Core Working Group W3C XML Activity http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlbase This document is an Edited Recommendation of the W3C. It supersedes the previous W3C Recommendation of 27 June 2001 http://www.w3.org/2001/06/xmlbase-errata http://www.w3.org/XML/2006/11/xmlbase-2e/Overview.html http://www.w3.org/TR/2006/PER-xmlbase-20061220/ appendix Please report errors in this document to the public mailing list [email protected] archives There is no implementation report or test suite for this specification, but there is a document describing methods of testing XML Base conformance This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web. This document is governed by the 24 January 2002 CPP W3C Patent Policy Transition Procedure public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy 1 Introduction Terminology xml:base Attribute URI Reference Encoding and Escaping Resolving Relative URIs Relation to RFC 3986 Granularity of base URI information Matching URIs with base URIs Interpretation of same-document references Conformance A References References Impacts on Other Standards Changes since the first edition The XML Linking Language [XLink] [XML] [HTML 4.01] 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 xml:base 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 xml:base This specification does not attempt to specify which text strings in a document are to be interpreted as URIs. That is the responsibility of each XML vocabulary. The question addressed by this specification is: given a relative URI in an XML document, what base URI is it resolved against? It is expected that a future RFC for XML Media Types will specify XML Base as the mechanism for establishing base URIs in the media types it defines. [ Definition must must not required shall shall not should should not recommended may optional [RFC 2119] The terms base URI relative URI [RFC 3986] xml:base The attribute xml:base may a Legacy Extended IRI (LEIRI) as defined in the W3C Note "Legacy extended IRIs for XML resource identification" [LEIRI] In namespace-aware XML processors, the "xml" prefix is bound to the namespace name http://www.w3.org/XML/1998/namespace [XML Names] xml:base An example of xml:base xlink:href <?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> The URIs in this example resolve to full URIs as follows: "what's new" resolves to the URI "http://example.org/today/new.xml" "Hot Pick #1" resolves to the URI "http://example.org/hotpicks/pick1.xml" "Hot Pick #2" resolves to the URI "http://example.org/hotpicks/pick2.xml" "Hot Pick #3" resolves to the URI "http://example.org/hotpicks/pick3.xml" Note: This specification does not give the xml:base attribute any special status as far as XML validity is concerned. In a valid document the attribute must be declared in the DTD, and similar considerations apply to other schema languages. The value of an xml:base xml:base In accordance with the principle that percent-encoding must occur as late as possible in the processing chain, applications which provide access to the base URI of an element should In the example below, the base URI of element e2 <?xml version="1.0"?> <e1 xml:base="http://example.org/wine/"> <e2 xml:base="rosé"/> </e1> RFC 3986 [RFC 3986] The base URI is embedded in the document's content. The base URI is that of the encapsulating entity (message, document, or none). The base URI is the URI used to retrieve the entity. The base URI is defined by the context of the application. Note: The term "entity" in points #2 and #3 above uses the RFC 3986 This document specifies the details of rule #1 for embedding base URI information in the specific case of XML documents. 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. The base URI of a document entity or an external entity is determined by RFC 3986 The base URI of an element is: the base URI specified by an xml:base the base URI of the element's parent element within the document entity the base URI of the document entity or external entity containing the element. Note: It follows that the base URI specified by an xml:base xml:base The base URI of an element bearing an xml:base The base URI corresponding to a given relative URI appearing in an XML document is determined as follows: The base URI for a URI reference appearing in text content is the base URI of the element containing the text. The base URI for a URI reference appearing in an xml:base xml:base 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. 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 within the document entity or external entity, otherwise the base URI of the document entity or external entity containing the processing instruction. Note: The presence of xml:base xml:base should RFC 3986 defines certain relative URI references, in particular the empty string and those of the form #fragment same-document references xml:base xml:base="" Note: Some existing processors do xml:base An application conforms to XML Base if it calculates base URIs in accordance with the conditions set forth in this specification. RFC 2119: Key words for use in RFCs to Indicate Requirement Levels Internet Engineering Task Force, 1997. RFC 3986: Uniform Resource Identifier (URI): Generic Syntax Internet Engineering Task Force, 2005. Legacy extended IRIs for XML resource identification World Wide Web Consortium. Extensible Markup Language (XML) 1.0. World Wide Web Consortium. Namespaces in XML 1.0. World Wide Web Consortium. HTML 4.01 Specification World Wide Web Consortium, 1999. XML Linking Language (XLink). World Wide Web Consortium, 2000. XML Schema Part 2: Datatypes. World Wide Web Consortium Working Draft. XHTML(TM) 1.0: The Extensible HyperText Markup Language. World Wide Web Consortium, 2000. XML Information Set World Wide Web Consortium, 1999. XML Path Language World Wide Web Consortium, 1999. XSL Transformations World Wide Web Consortium, 1999. This section has been deleted. The published errata (see http://www.w3.org/2001/06/xmlbase-errata The definition of URI reference has been switched from RFC2396 to 3986; The xml:base attribute has been redescribed as a Legacy Extended IRI, but this does not change its syntax (the December 2006 PER used the term "XML Resource Identifier" which was to be defined in an XLink revision, but that plan has been superseded by the definition of LEIRI in the W3C Note); Implementations are now encouraged to return base “URIs” without escaping non-URI characters; The meanings of xml:base="" and xml:base="#frag" have been clarified; The expected reference to XML Base in the forthcoming XML Media Types RFC (“son of 3023”) has been noted; It has been clarified that normal validity rules apply to the xml:base attribute; The out-of-date appendix describing effects on other standards has been removed; Various minor editorial changes have been made.