Search code examples
javaxmlrdfjenaapache-jena

Apache Jena RDFWriter.setProperty has no effect


I'm using Jena (apache-jena-libs 3.0.1) in my java application to create RDF model and serialize to RDF/XML. I am using the same way that is documented in 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);

However, the writer ignores any of the properties, they have no effect on the resulting XML. Any ideas?


Solution

  • There is a bug (just record as JENA-1168)

    A workaround is to use

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