gpt4 book ai didi

rdf - 无法使用 SPARQL 对层次结构进行前缀

转载 作者:行者123 更新时间:2023-12-05 00:18:49 25 4
gpt4 key购买 nike

我需要在我的 URL 中表示一个层次结构,如下所示:

http://www.me.org/
-----------------root1/
- - - - - - - - - - - -1级/
------------------------------level2/etc

我想定义 PREFIX 并在这样的 SPARQL 查询中使用它们:

前缀 root1:

选择 * 其中 {
?s ?p root1:level1/level2/etc 。
} 限制 100

这将在 ARQ 中失败并出现以下错误:

在第 10 行第 43 列遇到“”/“”/“”。
期待以下之一:
“值(value)观”……
“图”...
...

我应该能够像这样在我的 URL 中表示层次结构,还是 SPARQL 和 PREFIX 的使用仅限于单个级别?

最佳答案

4.1.1.1 Prefixed Names

The PREFIX keyword associates a prefix label with an IRI. A prefixed name is a prefix label and a local part, separated by a colon ":". A prefixed name is mapped to an IRI by concatenating the IRI associated with the prefix and the local part. The prefix label or the local part may be empty. Note that SPARQL local names allow leading digits while XML local names do not. SPARQL local names also allow the non-alphanumeric characters allowed in IRIs via backslash character escapes (e.g. ns:id\=123). SPARQL local names have more syntactic restrictions than CURIEs.



让我们检查一下语法,看看是否 \是假定的非字母数字字符之一:

19.8 Grammar

[169]     PN_LOCAL      ::=   (PN_CHARS_U | ':' | [0-9] | PLX ) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX) )?
[170] PLX ::= PERCENT | PN_LOCAL_ESC
[171] PERCENT ::= '%' HEX HEX
[172] HEX ::= [0-9] | [A-F] | [a-f]
[173] PN_LOCAL_ESC ::= '\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?'

| '#' | '@' | '%' )



果然,我们应该可以通过:

PN_LOCAL → PLX → PN_LOCAL_ESC → '\' '/'



因此,您应该能够编写:
?s ?p root1:level1\/level2\/element .

关于rdf - 无法使用 SPARQL 对层次结构进行前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25547212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com