other register

Tuesday, May 06, 2008

Encoding in XSLT

If you have an xml document which contains German or French characters, then in your xml declarations, you should write:

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

Don't put "UTF-8" for it. It will not work

When using Java to write an xml fie, do the following:

File f = new File("newFile.xml");
FileOutputStream fos = new FileOutputStream(f);
OutputStreamWriter osw = new OutputStreamWriter(fos, Charset.forName("ISO-8859-1"));

// Begin to write an xml file.

Otherwise, if use the FileWriter instead of OutputStreamWriter, the programme will use the system default encoding which cause problems if the xml file contains German or French characters.

No comments: