Robin
Robin

Reputation: 247

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

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:

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

<https://www.myURI.com> - 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):

"1234"^^xsd:integer and 1234
"12.34"^^xsd:decimal and 12.34 

Upvotes: 4

Views: 345

Answers (1)

<https://example.com/> refers to the thing denoted by the URI https://example.com/.

"https://example.com/"^^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 <https://en.wikipedia.org/wiki/Moby> .    
:Bob   :wrote "https://en.wikipedia.org/wiki/Moby"^^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.

<https://en.wikipedia.org/wiki/Moby>
  a :WikipediaArticle ;
  :hasCanonicalURL "https://en.wikipedia.org/wiki/Moby"^^xsd:anyURI ;
  :isAbout <https://dbpedia.org/resource/Moby> ;
  :hasAuthor :Alice .

Upvotes: 3

Related Questions