繁体   English   中英

如何创建一个新的owl:DatatypeProperty并使用owl API将其添加到现有的本体中?

[英]How to create a new owl:DatatypeProperty and add it at an exisisting ontology with owl api?

我想要创建一个新的owl:DatatypeProperty,如下所示:

<owl:DatatypeProperty rdf:about="http://sisinflab.poliba.it/semanticweb/ontologies/architecturalpatterns#extensibilityRate">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
    <rdfs:label xml:lang="en">extensibilityRate</rdfs:label>
    <rdfs:range>
        <rdfs:Datatype>
            <owl:intersectionOf rdf:parseType="Collection">
                <rdfs:Datatype>
                    <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
                    <owl:withRestrictions rdf:parseType="Collection">
                        <rdf:Description>
                            <xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</xsd:minInclusive>
                        </rdf:Description>
                    </owl:withRestrictions>
                </rdfs:Datatype>
                <rdfs:Datatype>
                    <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
                    <owl:withRestrictions rdf:parseType="Collection">
                        <rdf:Description>
                            <xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">4</xsd:maxInclusive>
                        </rdf:Description>
                    </owl:withRestrictions>
                </rdfs:Datatype>
            </owl:intersectionOf>
        </rdfs:Datatype>
    </rdfs:range>
</owl:DatatypeProperty>

并将其添加到我的猫头鹰本体中,但是我做不到。 有什么建议么?

我正在尝试遵循此处的示例(第235行); Eclipse不会显示编译或运行错误,但是不会更新本体。

您指向的测试方法具有以下内容:

manager.saveOntology(ontology, new StreamDocumentTarget(new ByteArrayOutputStream()));

在这里,本体被写入保存在内存中的字节数组,因此不会有任何更改保存到文件中。 对于要修改的原始文件,您需要删除第二个参数,然后使用

manager.saveOntology(ontology);

如果本体是通过代码创建的,并且从未保存过,则必须传递一个实际的文件输出流(这样才能创建和填充文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM