[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] NCName, QName and colons


Subject: Re: [xsl] NCName, QName and colons
From: Liam R E Quin <liam@xxxxxx>
Date: Fri, 05 Feb 2010 22:40:03 -0500

On Sat, 2010-02-06 at 13:34 +1030, Justin Johansson wrote:

> Running an XSLT identity transform over the following source document
> with Saxon 9b produces the error underneath:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> 
> <:a:apple xmlns:a="foo">
>     <banana/>
> </:a:apple>
> 
> Error on line 3 column 25 of foo.xml:
>   SXXP0003: Error reported by XML parser: The prefix ":a" for element 
> ":a:apple" is not bound.TransformerException: 
> net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException: The 
> prefix ":a" for element ":a:apple" is not bound.
> 
> Obviously the source document is not valid XML but the error message
> is confusing.

Well, you have xmlns:a="foo" not xmlns::a="foo".

> 
> Since when was
> 1) a colon character allowed to start an NCName which a prefix is, and
> 2) a QName allowed to contain 2 colon characters
> which the error message suggests?

When we first published the XML spec, the colon was reserved for
experiments with namespaces... and at that time we thought we
might use :: or a leading colon.  So there are things that are
well-formed XML but not namespace-well-formed.

So if you look at the production for NameStartChar in XML,
http://www.w3.org/TR/REC-xml/#NT-NameStartChar
you'll see it includes the colon; but if you go to the
namespaces spec, you'll see that a prefixed name
http://www.w3.org/TR/xml-names/#NT-PrefixedName
is a prefx followed by : followed by loaclpart,
and that prefix and localpats are ncnames (no-colon names,
informally),
http://www.w3.org/TR/xml-names/#NT-NCName

So, xmllint gives a message,
a.xml:1: namespace error : Failed to parse QName ':a:apple'
saying it's a namespace error, not an XML error.

It would be nice if we had the resources to make a single XML
specification that combined XML, Namespaces, xml:base, xml:id,
XInclude and the XML Information Set (and any others I've
forgotten that are implemented by an XML processor as part
of parsing).  But it would be more work than it seems, because
every sentence in every one of those specs would need to
be carefully checked so that no new errors were introduced;
it's a lot of work for relatively little gain.

Liam



-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org


Current Thread
Keywords