Re: Enumerations

Hello Mor,

You can use classes or strings (even mix them in one set!), but I think you prefer the following
implementation example:

<!--------------------------->
<!-- RDF M&S extension -->
<!--------------------------->

<rdfs:ConstraintProperty rdf:ID="literalRange">
  <rdfs:Label> literalRange </rdfs:Label>
  <rdfs:comment>
    This property is introduced to allow the implementation of enumerations, which can
    hardly be seen as classes (the setelements do not have to obey a certain
    classproperty). When property A has literalRange = bag B, then when A gets a value,
    typechecking software should check if this value belongs to the bag B. If so, then
    types match, otherwise return an RDF validation error.
  </rdfs:comment>
  <rdfs:domain rdf:resource="rdfs:#Property"/>
  <rdfs:range rdf:resource="rdfs:#Bag"/>
</rdfs:ConstraintProperty>

<!-------------->
<!-- Example -->
<!-------------->

<!-- my application schema -->

<rdf:Bag rdf:ID="DaySet">
  <rdf:li> Monday </rdf:li>
  <rdf:li> Tuesday </rdf:li>
  <rdf:li> Wednesday </rdf:li>
  <rdf:li> Thursday</rdf:li>
  <rdf:li> Friday </rdf:li>
</rdf:Bag>

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

<rdfs:Property rdf:ID="availableOn">
  <rdfs:domain rdf:resource="#Person">
 <schema_extension:literalRange rdf:resource="#DaySet">
</rdfs:Property>

<!-- my schema instance -->

<s:Person rdf:ID="Mor">
  <s:availableOn> Monday </s:availableOn>
</s:Person>

When tyechecking is needed, the definition of "availableOn" tells us that values of this property
are restricted to the literals in the DaySet bag. The value 'Monday' is in this set, so typechecking
returns OK. This means adding some code to your validation software to support literalRanges (in the
same way that it supports ranges now). As you can see, it doesn't matter what you put in the bag
(literals or classes). Typechecking just comes down to determining if the value belongs to the set.

Greetings,

Tom.

Mor Peleg wrote:

> Hi tom,
>
> Thank you very much for your answer.
>
> I am not clear about one thing: in the Bag, are the different enumerations
> Classes or String Literals?
>
> Thanks very much,
>
> Mor
>

Received on Wednesday, 27 September 2000 06:50:23 UTC