W3C home > Mailing lists > Public > www-tag@w3.org > September 2007

abbreviatedURIs-56: Differences betwee XML QNAMEs and SPARQL Prefixed Names

From: Williams, Stuart (HP Labs, Bristol) <skw@hp.com>
Date: Thu, 6 Sep 2007 17:42:05 +0100
Message-ID: <C4B3FB61F7970A4391A5C10BAA1C3F0DD351B3@sdcexc04.emea.cpqcorp.net>
To: "W3C-TAG" <www-tag@w3.org>

I have an outstanding action [1] to "Look at the difference between

Strictly SPARQL does not use QNAMEs [4], however it defines a
syntactically similar construct called a prefixed name [3].

Syntactic differences
1) Either or both of the prefix and local part of a SPARQL prefixed name
can be 'empty' ie, both ":local" and "ex:" are valid SPARQL prefixed
   XML QNAMEs are composed of either of two NCNAMEs separated by a ':'
or  a single localname NCNAME component. Each NCNAME is at least one
character long.
   ":local", "ex:" and ":" are all valid SPARQL prefixed names subject
to appropriate prefix declarations.
2) The local part of a SPARQL prefixed name is allowed to begin with a

3) The prefix part of a SPARQL prefixed name may *not* begin with an '_'
(although an anonymous variable name can).

Non-initial character constraints for prefix and local parts between XML
QNAME and SPARQL appear to be identical.

Semantic Differences
Strictly, a QNAME in XML is a syntactic abbreviation for an expanded
name comprising {<namespaceURI>, <localname>} where <namespaceURI> is
obtained by namespace expansion of the prefix component of a QNAME.

SPARQL prefixed names are abbreviations for an IRI formed by the direct
concatenation of <prefixExpansionURI><localName> where prefix expansion
resolves a prefix to an absolute IRI. A SPARQL 
prefixed name is ill-formed if the corresponding IRI is not
syntactically valid.

It should be noted that SPARQL is not an XML based syntax, ie. prefixed
names do not appear enclosed in either angle brackets or quotes. 

The Turtle syntax for RDF [6] has a similar construct to SPARQL and a
comparison is available at [7].

Finally it may be worth noting the following warning from the current
SPARQL CR draft [5]:

"At-Risk Feature: Not all Prefixed Names are XML QNames
The Prefixed Name representation for IRIs is derived from the syntax for
XML QNames. This practice first appeared in the RDF/XML specification,
in which it is used to express statement predicates. However, the
constraints XML stipulates for QNames rule out certain otherwise
convenient character strings, such as isbn:0752820907 or rfc:0822.txt.
The issue in these particular cases is that the local name (the part
following the colon) must be an XML NCName, which may not have leading

Earlier drafts of the SPARQL Query Language restricted the grammar of
Prefixed Names to always be valid QNames. The Working Group decided in
May 2007 to relax this restriction, so that the examples posed above are
now allowed. This extension is being marked as a feature at-risk because
of its late addition to the specification, and because existing software
(e.g. RDF-XML serializers) may rely on Prefixed Names being
transparently expressible as QNames."


Stuart Williams
[1] http://www.w3.org/2001/tag/group/track/actions/34 (Tracker:
[2] http://www.w3.org/TR/2007/CR-rdf-sparql-query-20070614/
[3] http://www.w3.org/TR/rdf-sparql-query/#rPrefixedName
[4] http://www.w3.org/TR/xml-names11/#NT-QName
[5] http://www.w3.org/TR/2007/CR-rdf-sparql-query-20070614/#notXmlQNames
[6] http://www.dajobe.org/2004/01/turtle/#sec-qnames
[7] http://jena.hpl.hp.com/wiki/Syntax_Comparison_of_N3_and_Turtle
Hewlett-Packard Limited registered Office: Cain Road, Bracknell, Berks
RG12 1HN
Registered No: 690597 England
Received on Thursday, 6 September 2007 16:44:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:47:47 GMT