xmlrdfjenaturtle-rdfqnames

How to represent commas inside QNames (esp. in Turtle documents)


Can one form QNames from URIs such as http://dbpedia.org/resource/Jesuit_Church,_Mannheim? Dbpedia lists this as dbpedia:Jesuit_Church,_Mannheim, but when I run this QName e.g. through Jena's Turtle parser, I get the following exception:

Not a valid token for an RDF term: [COMMA]

This makes sense under the Turtle specification, which apparently excludes commas from QNames. However the Namespaces in XML 1.0 specification apparently allows "any Unicode character, excluding the surrogate blocks, FFFE, and FFFF" inside them.

So which specification is "correct" and how (if at all) could I use such URIs in abbreviated form inside Turtle documents? I've tried percent encoding but in this case Jena's turtle parser apparently returns a model which retains the escaped URIs, i.e. http://dbpedia.org/resource/Jesuit_Church%2C_Mannheim instead of http://dbpedia.org/resource/Jesuit_Church,_Mannheim, and which causes later string comparisons (in my code) to fail.

UPDATE I must have made an error with my escaping. As is pointed out in the accepted answer it is indeed possible to use dbpedia:Jesuit_Church\,_Mannheim, e.g. with Jena 2.11.0.


Solution

  • In a note in Turtle (CR) it says:

    Prefixed names are a superset of XML QNames. They differ in that the local part of prefixed names may include:

    • leading digits, e.g. leg:3032571 or isbn13:9780136019701
    • non leading colons, e.g. og:video:height
    • reserved character escape sequences, e.g. wgs:lat\-long

    Reserved character escape sequences

    […] consist of a '\' followed by one of ~.-!$&'()*+,;=/?#@%_ and represent the character to the right of the '\'.

    So it should be possible to use:

    dbpedia:Jesuit_Church\,_Mannheim