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#:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access