"myURI.com"^^xsd:anyURI 和 <myURI.com> 之间的区别是什么?

huangapple go评论52阅读模式
英文:

What is the difference between "myURI.com"^^xsd:anyURI and <myURI.com>?

问题

标题已经很好地涵盖了我的问题。我查阅了xsd标准和rdf标准,但没有找到对我的问题的直接答案。我试图理解在两个选项之间是否存在“含义”上的区别:

&quot;https://www.myURI.com&quot;^^xsd:anyURI - 这是一个字符串,但我明确将其类型定义为anyURI。
含义:这个东西是一个URI。

&lt;https://www.myURI.com&gt; - 这是一个URI,没有明确地进行类型定义,但使用<>符号来表示。
含义:这个东西是一个URI。

所以我的问题是:区别在哪里?有区别吗?

例如,在使用SHACL形状验证实例数据或使用SPARQL查询时,这两个相同的URI版本是否会被引擎中的任何一个以不同方式解释?

为了比较,我假设这些也是相同的,并且可以互换使用(在过去在没有查询或SHACL形状产生奇怪结果的情况下已经这样做了):

&quot;1234&quot;^^xsd:integer 和 1234
&quot;12.34&quot;^^xsd:decimal 和 12.34
英文:

The title covers my question pretty well. I've looked into the xsd standard, the rdf standard but found no direct answer to my question. I'm trying to understand whether there is a difference in "meaning" between both options:

&quot;https://www.myURI.com&quot;^^xsd:anyURI - This is a string, but I'm explicitly typing it as a anyURI.
Meaning: This thing is a URI.

&lt;https://www.myURI.com&gt; - This is a URI, without explicitly typing it, but using <> symbols to do so.
Meaning: This thing is a URI.

So my question: Where is the difference? Is there a difference?

For instance, when validating instance data with SHACL shapes, or querying with SPARQL, can one version or another of this same URI be interpreted differently by either engine?

To compare, I assumed these are also the same and can be used interchangeably (and have done so without queries or SHACL shapes giving strange results in the past):

&quot;1234&quot;^^xsd:integer and 1234
&quot;12.34&quot;^^xsd:decimal and 12.34 

答案1

得分: 2

&lt;https://example.com/&gt; 指的是由 URI https://example.com/ 表示的 事物

&quot;https://example.com/&quot;^^xsd:anyURI 指的是 URI https://example.com/

在 RDF 术语中,第一个是 IRI

  • 在 Turtle(等等)中,它可以是三元组的主语、谓语和/或宾语
  • SPARQL 的 isIRI 函数返回 trueisLiteral 返回 false
  • 在 SHACL 中,sh:nodeKind 的值必须为 sh:IRI(或 sh:BlankNodeOrIRI/sh:IRIOrLiteral

在 RDF 术语中,第二个是 literal

  • 在 Turtle(等等)中,它只能是三元组的宾语
  • SPARQL 的 isIRI 函数返回 falseisLiteral 返回 true;您可以使用 strlen 等函数
  • 在 SHACL 中,sh:nodeKind 的值必须为 sh:Literal(或 sh:BlankNodeOrLiteral/sh:IRIOrLiteral

示例 1

:Alice :wrote &lt;https://en.wikipedia.org/wiki/Moby&gt; .    
:Bob   :wrote &quot;https://en.wikipedia.org/wiki/Moby&quot;^^xsd:anyURI .
  • Alice 写了关于 Moby 的维基百科文章
  • Bob 写下了指向维基百科文章的 URI(例如,在一张纸上)

示例 2

以下是一个同时使用两种形式的示例。三元组的主语是 IRI,代表了由该 URI 表示的事物(即,网页/文章)。属性 :hasCanonicalURL 的值是指向该网页的 URI。

&lt;https://en.wikipedia.org/wiki/Moby&gt;
  a :WikipediaArticle ;
  :hasCanonicalURL &quot;https://en.wikipedia.org/wiki/Moby&quot;^^xsd:anyURI ;
  :isAbout &lt;https://dbpedia.org/resource/Moby&gt; ;
  :hasAuthor :Alice .
英文:

&lt;https://example.com/&gt; refers to the thing denoted by the URI https://example.com/.

&quot;https://example.com/&quot;^^xsd:anyURI refers to the URI https://example.com/.

In RDF terms, the first one is an IRI:

  • in Turtle (etc.), it can be the subject, the predicate, and/or the object of a triple
  • SPARQL’s isIRI function returns true, isLiteral returns false
  • in SHACL, the sh:nodeKind value would have to be sh:IRI (or sh:BlankNodeOrIRI/sh:IRIOrLiteral)

In RDF terms, the second one is a literal:

  • in Turtle (etc.), it can only be the object of a triple
  • SPARQL’s isIRI function returns false, isLiteral returns true; you can use strlen etc.
  • in SHACL, the sh:nodeKind value would have to be sh:Literal (or sh:BlankNodeOrLiteral/sh:IRIOrLiteral)

Example 1

:Alice :wrote &lt;https://en.wikipedia.org/wiki/Moby&gt; .    
:Bob   :wrote &quot;https://en.wikipedia.org/wiki/Moby&quot;^^xsd:anyURI .
  • Alice wrote that Wikipedia article about Moby
  • Bob wrote (e.g., on a piece of paper) the URI which points to that Wikipedia article

Example 2

Here is an example where both forms get used. The triple subject is the IRI, which represents the thing denoted by that URI (i.e., the webpage/article). The value of the property :hasCanonicalURL is the URI which points to that webpage.

&lt;https://en.wikipedia.org/wiki/Moby&gt;
  a :WikipediaArticle ;
  :hasCanonicalURL &quot;https://en.wikipedia.org/wiki/Moby&quot;^^xsd:anyURI ;
  :isAbout &lt;https://dbpedia.org/resource/Moby&gt; ;
  :hasAuthor :Alice .

huangapple
  • 本文由 发表于 2023年3月1日 16:43:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75601331.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定