简体   繁体   English

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

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

I' d like to create a new owl:DatatypeProperty like this: 我想要创建一个新的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>

and add it to my owl ontology, but I can't do it. 并将其添加到我的猫头鹰本体中,但是我做不到。 Any suggestions? 有什么建议么?

I'm trying to follow the example here (row 235); 我正在尝试遵循此处的示例(第235行); Eclipse does not show compile or running errors, but the ontology is not updated. Eclipse不会显示编译或运行错误,但是不会更新本体。

The test method that you pointed at has the following: 您指向的测试方法具有以下内容:

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

Here the ontology is written to a byte array that's held in memory, so no changes will be saved to file. 在这里,本体被写入保存在内存中的字节数组,因此不会有任何更改保存到文件中。 For the original file to be modified, you need to remove the second argument and just use 对于要修改的原始文件,您需要删除第二个参数,然后使用

manager.saveOntology(ontology);

If the ontology was created from code and never saved before, you'll have to pass an actual file output stream instead (so that the file can be created and populated. 如果本体是通过代码创建的,并且从未保存过,则必须传递一个实际的文件输出流(这样才能创建和填充文件。

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

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