views:

39

answers:

1

I have some custom type:

[RdfSerializable]
public class Item
{
    [RdfProperty(true)]
    public string Name { get; set; }
}

and some other type that has array of Item:

[RdfSerializable]
public class Container
{
      // ... some code

      // if this attribute is missing, then this property will not be exported as array
      [CardinalityRestriction(1, 100)]     
      [RdfProperty(false)]
      public Item[] MyArray { get { return mMyArray; } }
}

And it is happening that if I remove CardinalityRestriction attribute from MyArray it will be exported by OwlGrinder.exe as single Item and NOT as array of Items.

Is there some other way to define arrays without constraining them to some range of elements?

+1  A: 

ROWLEX OntologyExtractor behaves correctly (OwlGrinder reads ontologies and produce assemblies. OntologyExtractor reads assemblies and spits out ontologies). According to the OWL specifications, if there is no cardinality restriction associated to the OWL property, then its cardinality is assumed "zero or more". Should you want a property be not an "array property" then you need to apply the cardinality restriction. A shorthand for that is making the OWL property a functional property, where the cardinality is 0 or 1.

So all you need to do is remove the [CardinalityRestiction(1,100)] decoration and you have what you want.

[EDIT: responding on the comment] I reproduced your case, removed the CardinalityRestriction, and OntologyExtractor produces the following ontology:

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfschema="http://www.w3.org/2000/01/rdf-schema#"&gt;
    <owl:Ontology rdf:about="http://www.test.com/MyOntology" />
    <owl:Class rdf:about="http://www.test.com/MyOntology#Item" />
    <owl:DatatypeProperty rdf:about="http://www.test.com/MyOntology#Name"&gt;
     <rdfschema:domain rdf:resource="http://www.test.com/MyOntology#Item" />
     <rdfschema:range rdf:resource="http://www.w3.org/2001/XMLSchema#string" />
     <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty" />
    </owl:DatatypeProperty>
    <owl:ObjectProperty rdf:about="http://www.test.com/MyOntology#MyArray"&gt;
     <rdfschema:domain>
      <owl:Class rdf:about="http://www.test.com/MyOntology#Container" />
     </rdfschema:domain>
     <rdfschema:range rdf:resource="http://www.test.com/MyOntology#Item" />
    </owl:ObjectProperty>
</rdf:RDF>

This ontology allows you to create RDF files where your container object has zero or more items linked via MyArray OWL property.

ROWLEX Admin
I want it to behave as cardinality 0..* (zero or more), that is an array. So if I remove "CardinalityRestriction" I get cardinality of "1", i.e. single element, but not an array. That was what I meant. So there is a bug according to OWL specification.
The_Ghost