You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Engin Ertilav <en...@kocbank.com.tr> on 2005/01/12 16:52:16 UTC

xsl transformation encoding problem with unix

Hi,

 

we are using this code to perform transform. (it is changed from sample
code UseStylesheetPI)

 

it simply gets stylesheet from xml and performs transform. In addition
to that we are working on turkish files and so it changes 

charset encoding for input and output xml files. 

 

This works fine on Windows2000 but on Solaris Unix it ignores new
charset and result xml file contains char codes like &#287; &#350;

 

Is there a solution for that? Or is it a bug? XALAN version is 2.6.0. 

 

Thanks in advance. 

 

public static void main(String[] args)

              throws TransformerException,
TransformerConfigurationException

            {

              String media= null , title = null, charset = null;

              try

              {        

                 TransformerFactory tFactory =
TransformerFactory.newInstance();

             Source stylesheet = tFactory.getAssociatedStylesheet

                         (new StreamSource("x.xml"),media, title,
charset);

        

             Transformer transformer =
tFactory.newTransformer(stylesheet);

          

             //create input stream with special encoding

             FileInputStream fi = new FileInputStream("x.xml");

             InputStreamReader i = new
InputStreamReader(fi,"ISO8859_9");

             StreamSource so = new StreamSource(i);

             

             //create output stream with special encoding

             FileOutputStream   f = new FileOutputStream("xout.xml");

             OutputStreamWriter o = new
OutputStreamWriter(f,"ISO8859_9");

             StreamResult s = new StreamResult(o);

        

             transformer.transform(so, s);

             

             fi.close();

             i.close();

             o.close();

             f.close();

 

              }

              catch (Exception e)

              {

                e.printStackTrace();

              }

  }   

 

This is my xsl header : 

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

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xslt">

    <xsl:output method="xml" indent="yes" encoding="ISO-8859-9"
xalan:indent-amount="3"/>

 

and this is my xml header : 

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

<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>