更正词汇的命名空间
Correcting the namespace of vocabularies
给出这个(非常人为的)代码片段:
System.out.println(VCARD.uri);
System.out.println(SKOS.uri);
Resource johnSmith = model.createResource("http://somewhere/js")
.addProperty(VCARD.FN, "John Smith")
.addProperty(SKOS.notation, "John Smith");
model.write(System.out);
我们得到
http://www.w3.org/2001/vcard-rdf/3.0#
http://www.w3.org/2004/02/skos/core#
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:j.0="http://www.w3.org/2004/02/skos/core#">
<rdf:Description rdf:about="http://somewhere/js">
<j.0:notation>John Smith</j.0:notation>
<vcard:FN>John Smith</vcard:FN>
</rdf:RDF>
鉴于 SKOS
在 Jena 内部表示,为什么它仍然返回 j.0
符号(但不是 vcard
属性)?我读过类似的问题(例如 this one and this one and this one),但他们似乎指的是人们指的是他们自己的 ontology。鉴于 uri
常量对于 SKOS
是正确的,为什么它在 RDF 表示中发生变化?
该代码使用了来自 SKOS 的 URI,但未在模型上设置前缀。参见 setNsPrefix
。
您可能希望使用漂亮的打印形式输出,默认只有基本的RDF/XML。在 model.write
调用中设置语法名称(有关详细信息,请参阅 javadoc)。
给出这个(非常人为的)代码片段:
System.out.println(VCARD.uri);
System.out.println(SKOS.uri);
Resource johnSmith = model.createResource("http://somewhere/js")
.addProperty(VCARD.FN, "John Smith")
.addProperty(SKOS.notation, "John Smith");
model.write(System.out);
我们得到
http://www.w3.org/2001/vcard-rdf/3.0#
http://www.w3.org/2004/02/skos/core#
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:j.0="http://www.w3.org/2004/02/skos/core#">
<rdf:Description rdf:about="http://somewhere/js">
<j.0:notation>John Smith</j.0:notation>
<vcard:FN>John Smith</vcard:FN>
</rdf:RDF>
鉴于 SKOS
在 Jena 内部表示,为什么它仍然返回 j.0
符号(但不是 vcard
属性)?我读过类似的问题(例如 this one and this one and this one),但他们似乎指的是人们指的是他们自己的 ontology。鉴于 uri
常量对于 SKOS
是正确的,为什么它在 RDF 表示中发生变化?
该代码使用了来自 SKOS 的 URI,但未在模型上设置前缀。参见 setNsPrefix
。
您可能希望使用漂亮的打印形式输出,默认只有基本的RDF/XML。在 model.write
调用中设置语法名称(有关详细信息,请参阅 javadoc)。