Jonas Arêas
Jonas Arêas

Reputation: 63

Can´t show UTF-8 encoding in generated XML by Apache Jena

I want that Apache Jena generates an XML with

<?xml version="1.0" encoding="UTF-8"?>

My code:

RDFWriter writer = myJenaModel.getWriter("RDF/XML-ABBREV");
writer.setProperty("showXmlDeclaration", "true");
FileOutputStream fos = new FileOutputStream(filepath);
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
writer.write(myJenaModel, osw, null);

only generates

<?xml version="1.0"?>

But, if I change

OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); 

to

OutputStreamWriter osw = new OutputStreamWriter(fos, "ISO-8859-1");

it generates

<?xml version="1.0" encoding="ISO-8859-1"?>

as expected.

I tried to follow the instruction in Jena documentation, but had no success.

Does anyone know how can I make Jena generate my RDF/XML with the UTF-8 encoding declaration?

Upvotes: 4

Views: 595

Answers (1)

AndyS
AndyS

Reputation: 16700

encoding="UTF-8" is the default for XML so it is not necessary.

Upvotes: 5

Related Questions