Unable to print special (Non-English) characters (Latin, German, etc.,) in XML using XSL

466 Views Asked by At

I have an XML that contains some special (Non-English) characters like š,ý, etc.. How can I handle the special characters in XSL?

When I used encoding as UTF-8 in my program, the XML file got generated but I was unable to open the XML file as it has some junk data in place of special character. Later I change the encoding as ISO_8859-1/ISO-8859-1 and generated the XML, this time I was able to view the XML data but the data/name appeared as "Ale?, Rodý" instead of "Aleš, Rodý".

Letter - "š" was replaced by "?" and "ý" printed correctly.

How can I print the Non-English characters in XML using the XSL?

Note - I have written the XSL code in the (PeopleSoft) Application Package > Application class (PeopleCode) to generate the XML file. I am calling this App class using Transform Application engine program. The XML file is related to Bank Payment file.

1

There are 1 best solutions below

0
On

If the actual encoding of the non-English characters matches the encoding specified in the XML declaration, and if the XML parser you are using supports that encoding, then you shouldn't have any problems at all.

If there's no XML declaration at the start of the file, then you need to tell the XML parser what encoding to assume when parsing the file - which means you need to know the actual encoding.

If the input is miscoded, for example if there's an incorrect XML declaration, or if different characters appear with different encodings, then you need to fix that before you try to process the data using XSLT or any other technology.

First establish what octet sequence is used to represent the characters by looking at a binary/hex dump of the file contents; then establish what this tells you about the file encoding. If the encoding is wrong or inconsistent, trace the data back to its origins to find out how the corruption occurred, and fix the root cause. If you can't fix the root cause, then (and only then) consider writing custom code to repair the damage. This might mean, for example, adding or replacing an XML declaration that declares the encoding of the file correctly.