2

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.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Drux
  • 11,992
  • 13
  • 66
  • 116

1 Answers1

4

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
unor
  • 92,415
  • 26
  • 211
  • 360
  • 1
    +1 Hmm, could this be a case where the older Turtle document (from 2011 that I linked to) and the newer one (from 2013 that you link to) differ and where Jena perhaps still implements the older spec? – Drux Jan 05 '14 at 23:13
  • 1
    All recent Jena versions support the newer specification (and you haven't stated what version you are using), as @unor points out in this answer commas must be escaped to be valid – RobV Jan 06 '14 at 08:27
  • @RobV You can savely assume that I am using the current version (2.0.11). But then I also made a mistake in my escaping, which caused the issue (see update). Sorry for casting doubt on Jena :) – Drux Jan 06 '14 at 14:11
  • @Drux While you may be using the latest release version plenty of people aren't (whether by choice, ignorance or dependency conflicts) so it's always worth verifying which version is being used as otherwise it's easy to end up chasing bugs that already got fixed – RobV Jan 06 '14 at 14:52