我有一些自定义类型:
[RdfSerializable]
public class Item
{
[RdfProperty(true)]
public string Name { get; set; }
}和一些其他类型,它具有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; } }
}而且,如果我从MyArray中删除CardinalityRestriction属性,OwlGrinder.exe会将其导出为单个项目,而不是项目数组。
有没有其他方法可以定义数组,而不将它们限制在某个元素范围内?
发布于 2009-09-09 14:42:18
ROWLEX OntologyExtractor运行正常(OwlGrinder读取本体并生成程序集。OntologyExtractor读取程序集并输出本体)。根据OWL specifications,如果没有与OWL属性关联的基数限制,则假定其基数为“零或更多”。如果你希望一个属性不是“数组属性”,那么你需要应用基数限制。一个简单的方法是将OWL属性设为functional property,其中基数是0或1。
因此,您所需要做的就是删除CardinalityRestiction(1,100)装饰,您就得到了想要的东西。
编辑:根据我的评论,我复制了您的案例,删除了CardinalityRestriction,OntologyExtractor生成了以下本体:
<?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#">
<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">
<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">
<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>这个本体允许您创建RDF文件,其中您的容器对象具有通过MyArray OWL属性链接的零个或多个项。
https://stackoverflow.com/questions/1241534
复制相似问题