J
jan00000
Hi,
I'm using Xalan to do some transforming of XML in Java. My problem is:
I have unicode in my XML (i.e., German Umlauts (ä,ö,ü, and since
they trouble me, I did not try out any other unicode characters). When
I do an Identity Transform and output the XMl to a File, the word
'Glättegefahr', for example, will appear in my File (viewed with
XMLSpy Eclipse-PlugIn) as 'Glã³´egefahr' (except that the ? is a box
instead of a ? .
When I output it to System.out, I get: Glättegefahr. (This is also
what I get using XMLSpy directly, except that XMLSpy does not seem to
understand the <xsl:copy-of> tag).
Here is my Java Code for instantiating the transformer.
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
trans.transform(new DOMSource(source.getDocumentElement()),
new StreamResult(new FileWriter(origin)));
//or: new StreamResult(System.out)
The XML-file is shown in Eclipse as encoded with utf-8 and each file
involved (xslt, xml) has set the encoding="UTF-8" attribute specified.
Any Idea on what else I can try will be most welcome. Thanks in
advance.
I'm using Xalan to do some transforming of XML in Java. My problem is:
I have unicode in my XML (i.e., German Umlauts (ä,ö,ü, and since
they trouble me, I did not try out any other unicode characters). When
I do an Identity Transform and output the XMl to a File, the word
'Glättegefahr', for example, will appear in my File (viewed with
XMLSpy Eclipse-PlugIn) as 'Glã³´egefahr' (except that the ? is a box
instead of a ? .
When I output it to System.out, I get: Glättegefahr. (This is also
what I get using XMLSpy directly, except that XMLSpy does not seem to
understand the <xsl:copy-of> tag).
Here is my Java Code for instantiating the transformer.
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
trans.transform(new DOMSource(source.getDocumentElement()),
new StreamResult(new FileWriter(origin)));
//or: new StreamResult(System.out)
The XML-file is shown in Eclipse as encoded with utf-8 and each file
involved (xslt, xml) has set the encoding="UTF-8" attribute specified.
Any Idea on what else I can try will be most welcome. Thanks in
advance.