Search code examples
rdfrdfs

Necessity of using rdfs:Datatype in RDF code


In a text book (A Developer’s Guide to the Semantic Web by Yu, Liyang), in page 143, it suggests that, "it is always useful to clearly declare that a given URI represents a datatype, as shown here:". Then it shows the following code:

<rdf:Property
    rdf:about1⁄4"http://www.liyangyu.com/camera#model">
<rdfs:domain rdf:resource="#Camera"/>
<rdfs:range
    rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</rdf:Property>
<rdfs:Datatype
    rdf:about="http://www.w3.org/2001/XMLSchema#string"/>

I fail to understand the necessity of the last two lines. As far as my knowledge goes, XMLSchema#string will be good for any string. And as is delineated here, rdfs:Datatype is "the class of datatypes".

What do we lose if we do not use the last two lines?


Solution

  • All primitive types differ, though reasoners may or might think in the opposite way.

    The supertype (⊆) of all the primitive types is rdfs:Literal, which is not to be confused with rdf:PlainLiteral, and which is analogous to xsd:anySimpleType.

    The type (∈) of all the primitive types is rdfs:Datatype.

    In the previous edition (2011), Liyang Yu wrote right after the piece you quote:

    The next example will show that using rdfs:Datatype is not only a good practice, but also necessary in some cases.

    I believe, this example wasn't excluded in 2014 edition.