How can we limit the Literal type:

<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>

To just integers (using XML/RDF notation)?

I tried:

<rdfs:range rdf:int/>

But it doesn't work.

有帮助吗?

解决方案

You have to set the range on a property. The integer is defined in XMLSchema. For instance:

<rdf:Property rdf:ID="testRelation">
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>       
</rdf:Property>

Note that this is not a true restriction. As you should know in RDF anyone can say anything about everything. That means that one person can decide that the range also includes doubles and then this will be true as well.

If you are looking at some kind of sanity check then you will have to do this outside rdf (or use an inferences to spot inconsistencies).

其他提示

To specifically answer your question, you use xsd:int as the value of the range assertion, as @JoshuaTaylor indicated. But that does not mean what you think it means; rdfs:range doesn't restrict values of the property to the value specified in the range, nor does it 'forbid' values outside of the stated range.

Range is used to infer information about the value of the property. For example, you can say the range of some property p is both A and B. Then if you have an assertion of the form :s :p :o a reasoner which knows about range will infer that o is both an A and a B. There is nothing to prevent you from also asserting that o is a C (:o a :C), this just means that, when combined with the previous assertion, that o is an A, B, and C.

You can't really use RDFS, or OWL, for validation, at least not out of the box. There's been work in this area, and recently a workshop to look at how some vendors are supporting validation and see what might be a reasonable approach for standardizing.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top