Binding Prefixes to URIs
Each prefix in a qualified name must be associated with a URI. For
example, all XSLT elements are associated with the http://www.w3.org/1999/XSL/Transform
URI.
The customary prefix xsl
is used
in place of the longer URI http://www.w3.org/1999/XSL/Transform
.
Tip
You can’t use the URI in the name directly. For one
thing, the slashes in most URIs aren’t legal characters in XML
names. However, it’s occasionally useful to refer to the full name
without assuming a particular prefix. One convention used on many
XML mailing lists and in XML documentation is to enclose the URI
in curly braces and prefix it to the name. For example, the
qualified name xsl:template
might be written as the full name {http://www.w3.org/1999/XSL/Transform}template
.
Another convention is to append the local name to the namespace
name after a sharp sign so that it becomes a URI fragment
identifier. For example, http://www.w3.org/1999/XSL/Transform#template
.
However, both forms are only conveniences for communication among
human beings when the URI is important but the prefix isn’t.
Neither an XML parser nor an XSLT processor will accept or
understand the long forms.
Prefixes are bound to namespace URIs by attaching an xmlns
:prefix
attribute to the prefixed element or one of its ancestors. (The
prefix
should be replaced by the actual
prefix used.) For example, the xmlns:rdf
attribute of this rdf:RDF
element binds the prefix rdf
to the namespace URI http://www.w3.org/TR/REC-rdf-syntax#
:
Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.