dcsimg
how to set the character encoding using XmlDocument and XSLT Transformer
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Becky_Givner
Posted On:   Tuesday, August 7, 2001 01:28 PM

I have a program that creates an instance of


and then passes the XmlDocument object and an XSL stylesheet to
in order to produce an HTML page


The program calls the method XmlDocument.write(Writer out, String encoding) with encoding ISO-8859-1


However, the encoding in the HTML page is always:





How do I enforce the encoding that I want?

Re: how to set the character encoding using XmlDocument and XSLT Transformer

Posted By:   Arunkumar_Murthy  
Posted On:   Wednesday, August 8, 2001 10:18 PM

i have done the same thing what u did and it works for me..try this out..


XmlDocument xdoc = (XmlDocument) xD;


try {

res.setContentType("text/xml");
//xdoc.write
(response.getOutputStream());

xout = new OutputStreamWriter(res.getOutputStream());

xdoc.getDocumentElement().normalize();


xdoc.write (new FileOutputStream("LoginServletOp.xml")); //after normalising writing to a file

xdoc.write(xout, "ISO-8859-1"); //browser output

xout.write("
");

xout.flush();

}catch(Exception e){some msg}

Re: how to set the character encoding using XmlDocument and XSLT Transformer

Posted By:   Becky_Givner  
Posted On:   Tuesday, August 7, 2001 01:33 PM

make sure you set the encoding in the HTTP response header


for example:


res.setContentType("text/html;charset=ISO-8859-1");

About | Sitemap | Contact