我在这样的模型中添加了一些资源和属性:
String xyz = "http://www.example.com/xyz";
String creator = "http://www.example.com/Harry";
String email = "http://www.example.com/harry@xyz.com";
Resource creat = m.createResource(creator);
Resource eId = m.createResource(email);
Resource res = m.createResource(xyz).addProperty(DC.creator,creat.addProperty(VCARD.EMAIL, eId));
m.write(System.out);
我得到了这个结果:
<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:dc="http://purl.org/dc/elements/1.1/" >
<rdf:Description rdf:about="http://www.example.com/xyz">
<dc:creator rdf:resource="http://www.example.com/Harry"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.com/Harry">
<vcard:EMAIL rdf:resource="http://www.example.com/harry@xyz.com"/>
</rdf:Description>
</rdf:RDF>
还有其他方法可以获得结果吗:
<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:dc="http://purl.org/dc/elements/1.1/" >
<rdf:Description rdf:about="http://www.example.com/xyz">
<dc:creator rdf:resource="http://www.example.com/Harry"/>
<vcard:EMAIL rdf:resource="http://www.example.com/harry@xyz.com"/>
</rdf:Description>
</rdf:RDF>
答案 0 :(得分:0)
尝试RDF / XML漂亮作者:使用
model.write( .... , "RDF/XML_ABBREV")
或使用Turtle。