Re: Constraining Containers

Pierre-Antoine CHAMPIN wrote:
> 
> > As I understand it; if a property has LinearStrings as
> its range, it
> > can also be a container with LinearStrings.
> 
> technically, this won't work :
> 
> <rdf:Property ID="myprop">
>     <rdfs:range
> rdf:resource="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222#Literal"/>
> </rdf:Property>
> <rdf:Description about="http://somwhere/something">
>     <myprop>
>         <rdf:Seq>
>             <rdf:li> Item 1 </rdf:li>
>             <rdf:li> Item 2 </rdf:li>
>             <rdf:li> Item 3 </rdf:li>
>         </rdf:Seq>
>     </myprop>
> </rdf:Description>
> 
> because range of myprop is rdf:Literal, and its value has
> type rdf:Seq.

That is a matter of interpretation. My Schema editor works in that
way. But I guess that many RDF parsers doesen't do it. There must be
many sorts of inference rules in RDF.




But there is a difference between allowing a bag as a value and
allowing just a literal. One way to make all this explicit would be to
create a schema. This would allow either a Literal or a bag of
Literals. In fact, it would let you specify what type of literal to
allow:

<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

<rdfs:Class rdf:ID="MyComposite"/>

<rdfs:Class rdf:ID="MyString">
  <rdfs:subClassOf
rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>
  <rdfs:subClassOf rdf:resource="#MyComposite"/>
</rdfs:Class>

<rdfs:Class rdf:ID="MySeq">
  <rdfs:subClassOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag"/>
  <rdfs:subClassOf rdf:resource="#MyComposite"/>
</rdfs:Class>

<rdfs:Class rdf:ID="MyStringContainerMembershipProperty">
  <rdfs:subClassOf
rdf:resource="http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty"/>
</rdfs:Class>

<MyStringContainerMembershipProperty rdf:ID="_1">
  <rdfs:subPropertyOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#_1"/>
  <rdfs:range rdf:resource="#MyString"/>
  <rdfs:domain rdf:resource="#MySeq"/>
</MyStringContainerMembershipProperty>

<MyStringContainerMembershipProperty rdf:ID="_2">
  <rdfs:subPropertyOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#_2"/>
  <rdfs:range rdf:resource="#MyString"/>
  <rdfs:domain rdf:resource="#MySeq"/>
</MyStringContainerMembershipProperty>

<MyStringContainerMembershipProperty rdf:ID="_3">
  <rdfs:subPropertyOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#_3"/>
  <rdfs:range rdf:resource="#MyString"/>
  <rdfs:domain rdf:resource="#MySeq"/>
</MyStringContainerMembershipProperty>

<rdf:Property ID="myprop">
  <rdfs:range rdf:resource="#MyComposite"/>
</rdf:Property>


<rdf:Description about="http://somwhere/something">
  <myprop>
    <MySeq>
      <_1> Item 1 </_1>
      <_2> Item 2 </_2>
      <_3> Item 3 </_3>
    </MySeq>
  </myprop>
</rdf:Description>

</rdf:RDF>


... But I would prefere to magicaly let the range always include the
Container class.  

That could maby be done explicitly by constructing a new
ConstraintProperty containerRange. So if you wanted the range of
myprop to always be a sequence of literals, you could say:


<rdf:Property ID="myprop">
  <rdfs:range
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq"/>
  <containerRange
rdf:resource="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222#Literal"/>
</rdf:Property>



... and if you would like to allow both a container and a literal:

<rdfs:Class rdf:ID="SeqOrLiteral"/>

<rdf:Description
rdf:about="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq">
  <rdfs:subClassOf rdf:resource="#SeqOrLiteral"/>
</rdf:Description>

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

<rdf:Property ID="myprop">
  <rdfs:range rdf:resource="SeqOrLiteral"/>
  <containerRange
rdf:resource="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222#Literal"/>
</rdf:Property>



This seems simpler than the longer first version.

And the definition of containerRange would be:

<rdfs:ConstraintProperty rdf:ID="containerRange">
   <rdfs:range
rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
   <rdfs:domain
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
</rdfs:ConstraintProperty>

For the above example to work, the presence of a containerRange
constraint will not constrain the object of the property to containers.


-- 
/ Jonas  -  http://paranormal.se/myself/cv/index.html

Received on Friday, 21 April 2000 06:59:22 UTC