可以从 URI 形成 QName,例如 http://dbpedia.org/resource/Jesuit_Church,_Mannheim
? Dbpedia将此列为 dbpedia:Jesuit_Church,_Mannheim
,但是当我运行这个 QName 时,例如通过Jena的 Turtle 解析器,我得到以下异常:
Not a valid token for an RDF term: [COMMA]
这在 Turtle specification 下是有意义的,这显然从 QName 中排除了逗号。然而Namespaces in XML 1.0 specification显然允许其中包含“任何 Unicode 字符,不包括代理 block 、FFFE 和 FFFF”。
那么哪个规范是“正确的”以及我如何(如果有的话)在 Turtle 文档中以缩写形式使用此类 URI?我试过percent encoding但在这种情况下,Jena 的海龟解析器显然返回一个保留转义 URI 的模型,即 http://dbpedia.org/resource/Jesuit_Church%2C_Mannheim
而不是http://dbpedia.org/resource/Jesuit_Church,_Mannheim
,这会导致稍后的字符串比较(在我的代码中)失败。
更新我的转义一定犯了错误。正如已接受的答案中所指出的,确实可以使用 dbpedia:Jesuit_Church\,_Mannheim
,例如与耶拿 2.11.0。
最佳答案
在 Turtle (CR) 的注释中 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
orisbn13: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 '\'.
所以应该可以使用:
dbpedia:Jesuit_Church\,_Mannheim
关于xml - 如何在 QName 中表示逗号(尤其是在 Turtle 文档中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20930758/