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

I have an outstanding action [1] to "Look at the difference between
QNAME in XML and SPARQL".

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
names. 
   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
digit.

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
digits.

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."

regards

Stuart Williams
--
[1] http://www.w3.org/2001/tag/group/track/actions/34 (Tracker:
ACTION-34, ISSUE-56)
[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 UTC