gpt4 book ai didi

java - Apache Jena RDFWriter.setProperty 无效

转载 作者:行者123 更新时间:2023-11-30 07:26:16 25 4
gpt4 key购买 nike

我在我的 java 应用程序中使用 Jena (apache-jena-libs 3.0.1) 来创建 RDF 模型并序列化为 RDF/XML。我使用的方法与 https://jena.apache.org/documentation/io/rdfxml_howto.html 中记录的方法相同。

FileOutputStream out = new FileOutputStream( new File(dir, filename + ".xml") );
RDFWriter rdfWriter = notificationModel.getWriter("RDF/XML-ABBREV");
rdfWriter.setProperty("showXmlDeclaration", "true");
rdfWriter.setProperty("showDoctypeDeclaration", "true");
rdfWriter.write(notificationModel, out, null);

但是,编写者会忽略任何属性,它们对生成的 XML 没有影响。有什么想法吗?

最佳答案

有一个错误(只需记录为JENA-1168)

解决方法是使用

RDFWriter rdfWriter = new org.apache.jena.rdfxml.xmloutput.impl.Abbreviated() ;

关于java - Apache Jena RDFWriter.setProperty 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36769664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com