@page { size: A4
portrait; margin: 2cm} @media screen { body {width: 20cm;
margin-left: auto; margin-right: auto} } body {font-size: 12pt}
pre.code {font-family: monospace} pre {margin-left: 0em} ul.nolabel
{ margin: 0; margin-left: -2.5em} ul.naked li { list-style-type:
none } ol ol {list-style-type: lower-alpha} div.ndli {
margin-bottom: 1ex } .math {font-family: 'Arial Unicode MS',
'Lucida Sans Unicode', serif} .sub {font-size: 80%; vertical-align:
sub} .termref {text-decoration: none; color: #606000} div.toc h2
{font-size: 120%; margin-top: 0em; margin-bottom: 0em} div.toc h4
{font-size: 100%; margin-top: 0em; margin-bottom: 0em; margin-left:
1em} div.toc h1 {font-size: 140%; margin-bottom: 0em} div.toc ul
{margin-top: 1ex} .byline {font-size: 120%} div.figure
{margin-left: 2em} div.caption {font-style: italic; font-weight:
bold; margin-top: 1em} i i {font-style: normal} Default Prefix
Declaration
Default Prefix Declaration
Henry S. Thompson
18 Nov 2009
The ideas behind the proposal presented here are neither
particularly new nor particularly mine. I've made the effort to
write this down so anyone wishing to refer to ideas in this space
can say "Something along the lines of [this posting]" rather than
"Something, you know, like, uhm, what we talked about, prefix
binding, media-type-based defaulting, that stuff".
Criticism of
XML namespacesas an
appropriate mechanism for enabling distributed extensibility for
the Web typically targets two issues:
- Syntactic complexity
- API complexity
Of these, the first is arguably the more significant, because
the number of authors exceeds the number of developers by a large
margin. Accordingly, this proposal attempts to address the first
problem, by providing a defaulting mechanism for namespace prefix
bindings which covers the 99% case.
-
Binding
- Define a trivial XML language which provides a means to
associate prefixes with namespace names (URIs);
-
Invoking from
HTML
- Define a link relation
dpdfor use in the (X)HTML header;
-
Invoking from
XML
- Define a processing instruction
xml-dpdand/or an attribute
xml:dpdfor use at the top of XML documents;
-
Defaulting by Media Type
- Implement a registry which maps from media types to a published
dpd file;
-
Semantics
- Define a precedence, which operates on a per-prefix basis,
namely xmlns: >> explicit invocation >> application
built-in default >> media-type-based default, and a semantics
in terms of
namespace information itemsor appropriate data-model equivalent
on the document element.
XML namespaces provide two essentially distinct mechanisms for
'owning' names, that is, preventing what would otherwise be a name
collision by associating names in some way with some additional
distinguishing characteristic:
- By prefixing the name, and binding the prefix to a particular
URI;
- By declaring that within a particular subtree,
unprefixed names are associated with a particular URI.
In XML namespaces as they stand today, the association with a
URI is done via a
namespace
declarationwhich takes the form of an attribute, and whose
impact is scoped to the subtree rooted at the owner element of that
attribute.
Liam Quin
has proposedan additional, out-of-band and defaultable,
approach to the association for
unprefixed names, using patterns to identify the subtrees
where particular URIs apply. I've borrowed some of his ideas about
how to connect documents to prefix binding definitions.
The approach presented here is similar-but-different, in that
its primary goal is to enable out-of-band and defaultable
associations of namespaces to names
withprefixes, with whole-document scope. The advantages of
focussing on prefixed names in this way are:
-
Ad-hocextensibility mechanisms typically use prefixes. The
HTML5 specification already has at least two of these:
aria-and
data-;
- Prefixed names are more robust in the face of arbitrary
cut-and-paste operations;
- Authors are used to them: For example XSLT stylesheets and W3C
XML Schema documents almost always use explicit prefixes
extensively;
- Prefix binding information can be very simple: just a set of
pairs of prefix and URI.
Provision is also made for optionally specifying a binding for
the default namespace at the document element, primarily for the
media type registry case, where it makes sense to associate a
primary namespace with a media type.
If this proposal were adopted, and a dpd document for use in
HTML 4.01 or XHTML1:
<dpd ns="http://www.w3.org/1999/xhtml">
<pd p="xf" ns="http://www.w3.org/2002/xforms"/>
<pd p="svg" ns="http://www.w3.org/2000/svg"/>
<pd p="ml" ns="http://www.w3.org/1998/Math/MathML"/>
</dpd>
was registered against the
text/htmlmedia type, the following would result in a
DOM with
htmland
bodyelements in the XHTML namespace and an
inputelement in the XForms namespace:
<html>
<body>
<xf:input ref="xyzzy">...</xf:input>
</body>
</html>