Page 1 of 1
XSTL and ISO-8859-1 encoding, Regional char gets scrambled
Posted: Wed Dec 12, 2007 11:15 am
by erikhedb
Dear Sir / Madam,
I have a problem when I XSLT:to encoding=ISO-8859-1.
The regional characters ÅÄÖ gets turned info AG;≈ƒ÷ ‰.
When I set output to:
<xsl:output encoding="UTF-16" method="text"/>
The characters turn out fine.
Also I have found that it does not matter what encoding i use on the source file. I did try both UTF-16 and ISO-8859-1.
Ideas anyone?
Thanx /Erik
Posted: Wed Dec 12, 2007 11:46 am
by sorin_ristache
Hello,
I just tested a simple transformation of an input XML file containing the characters ÅÄÖ. These characters are preserved in the output with any combination between output method "text" or "xml", output encoding UTF-8 or ISO-8859-1 and input encoding UTF-8 or ISO-8859-1 for the XML file containing the characters. I used Saxon 6.5. Can you post a simple XML file and a simple XSLT stylesheet for reproducing the problem?
Regards,
Sorin
Sample XML
Posted: Wed Dec 12, 2007 4:12 pm
by erikhedb
Thanx for fast answers:
1. source.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<test xmlns="testSpace">
<text>REFERENCE TEXT</text>
<text>Ã¥</text>
<text>ä</text>
<text>ö</text>
<text>Ã…</text>
<text>Ä</text>
<text>Ö</text>
</test>
2. Tranformer.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:SourceNS="testSpace"
version="2.0">
<xsl:output encoding="ISO-8859-1" method="text"/>
<xsl:template match="SourceNS:test">
<xsl:text>Char:</xsl:text><xsl:value-of select="./SourceNS:text"/>
</xsl:template>
</xsl:stylesheet>
3. output.txt
Char:REFERENCE TEXT � � � � � �
Also I just found that the file look correct on a windows machine but not on my Mac using Oxygen 8.2.
Any idea?
Also
Posted: Wed Dec 12, 2007 4:16 pm
by erikhedb
In the editor window i get the funny carchters but in the "imidiate" window at the bottom I get correct characters.
/erik
Posted: Wed Dec 12, 2007 5:59 pm
by sorin_ristache
Hello,
I set ISO-8859-1 as encoding for non XML files in preferences, I set a a text file name (
test.txt) in the transformation scenario as the transformation result (because you have
method="text" in your XSLT stylesheet) and I applied your stylesheet to your XML sample file. I obtained the following output both in the file
test.txt and in the XML view panel at the bottom of the oXygen window:
Code: Select all
Char:REFERENCE TEXT å ä ö Å Ä Ö
What is the name of the output file that you set in the scenario and what is the encoding for non XML files set in Options -> Preferences -> Global -- Encoding for non XML files? If you save the result in an .xml file the encoding used to try to open the file is the default one, that is UTF-8 because your result file does not declare any explicit encoding with a declaration like:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
The result file cannot be read correctly with UTF-8 and the effect is that you see "funny characters" when the encoding error policy is set to REPLACE or you get an error message that the file cannot be opened with the UTF-8 encoding when the encoding error policy is set to REPORT. You can change the encoding error policy in Options -> Preferences -> Global -- Encoding errors handling.
Regards,
Sorin
Works like a charm
Posted: Wed Dec 12, 2007 8:12 pm
by erikhedb
Yes . did as you suggested and it works perfect. Thanks for quick response.