Jena 模型将我的 RDF 类型显式声明转换为隐式声明并弄乱了格式

Jena Model converts my RDF type explicit declaration to implicit and messes with the format

我有以下代码可以创建具有某些设置属性的 RDF 资源并将其打印在控制台上。

    String uri = "http://krweb/";
    String name = "Giorgos Georgiou";
    String phone = "6976067554";
    String age = "27";
    String department = "ceid";
    String teaches = "java";

    Model model = ModelFactory.createOntologyModel();
    model.setNsPrefix("krweb", uri);

    Resource giorgosgeorgiou = model.createResource(uri+name.toLowerCase().replace(" ", ""), model.createResource(uri+"Professor"));

    Property has_name = model.createProperty(uri+"has_name");
    Property has_phone = model.createProperty(uri+"has_phone");
    Property has_age = model.createProperty(uri+"has_age");
    Property member_of = model.createProperty(uri+"member_of");
    Property teach = model.createProperty(uri+"teaches");

    giorgosgeorgiou.addProperty(teach, model.createResource(uri+teaches));
    giorgosgeorgiou.addProperty(member_of, model.createResource(uri+department));
    giorgosgeorgiou.addProperty(has_age,age);
    giorgosgeorgiou.addProperty(has_phone,phone);
    giorgosgeorgiou.addProperty(has_name,name);
   //giorgosgeorgiou.addProperty(RDF.type, model.createResource(uri+"Professor"));
    model.write(System.out,"RDF/XML");

我想要以这种格式打印的模型:

<rdf:Description rdf:about="http://krweb/giorgosgeorgiou">
    <rdf:type rdf:resource="http://krweb/Professor"/>
    <krweb:has_name>Giorgos Georgiou</krweb:has_name>
    <krweb:has_phone>6976067554</krweb:has_phone>
    <krweb:has_age>27</krweb:has_age>
    <krweb:member_of rdf:resource="http://krweb/ceid"/>
    <krweb:teaches rdf:resource="http://krweb/java" />
</rdf:Description>

相反,我得到了这个:

  <krweb:Professor rdf:about="http://krweb/giorgosgeorgiou">
    <krweb:has_name>Giorgos Georgiou</krweb:has_name>
    <krweb:has_phone>6976067554</krweb:has_phone>
    <krweb:has_age>27</krweb:has_age>
    <krweb:member_of rdf:resource="http://krweb/ceid"/>
    <krweb:teaches rdf:resource="http://krweb/java"/>
  </krweb:Professor>

不知何故,rdf 类型 属性 被转换为一些隐式声明,并以我认为的 "pretty" 格式呈现。有没有办法绕过这个?

在内部,RDF 数据保存为三元组 - 不知道它们在输入时是如何格式化的。

默认输出很漂亮RDF/XML。

要获得简单的平面格式,请使用 RDFFormat.RDFXML_PLAIN

RDFDataMgr.write(System.out, model, RDFFormat.RDFXML_PLAIN);