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 "Ushakov, Sergey N" <us...@int.com.ru> on 2002/02/08 09:09:04 UTC
encoding problem with Xalan-j 2.2
Hello all,
I have a problem with getting the intended output encoding with Xalan-j 2.2
as simple DOM-to-XML selializer.
My wish is to get output XML encoded as "windows-1251". The only results I
could achieve are:
1. Desired output encoding in the output with wrong encoding declaration in
the XML header:
<?xml version="1.0" encoding="UTF-8"?>
2. The desired encoding declaration in the header with this encoding being
really absent in the output (all non-ascii output goes as &#NNNN;):
<?xml version="1.0" encoding="windows-1251"?>
<root><child>Это
тест</child></root>
Do I miss something or is it a bug?
The code fragment is:
TransformerFactory tFactory = TransformerFactory.newInstance ();
Transformer transformer = tFactory.newTransformer ();
// transformer.setOutputProperty (OutputKeys.ENCODING, "windows-1251");
DOMSource source = new DOMSource (document);
FileOutputStream fos = new FileOutputStream ("E:\\test.xml");
OutputStreamWriter out = new OutputStreamWriter (fos, "windows-1251" );
StreamResult result = new StreamResult (out);
transformer.transform (source, result);
With commented line remaining commented I get result #1, with uncommented -
result #2.
My environment is:
- Windows 2000 Prof with Russian locale
- JDK 1.3.1_01
Regards,
Sergey Ushakov
Re: encoding problem with Xalan-j 2.2
Posted by "Ushakov, Sergey N" <us...@int.com.ru>.
Isaac, thank you for your useful hint, but what concerns Xalan - the result
is the same: correct encoding declaration in the header and &#NNNN in the
data :(
Regards,
Sergey
----- Original Message -----
From: "Isaac S." <is...@netvision.net.il>
To: <xa...@xml.apache.org>
Sent: Friday, February 08, 2002 3:55 PM
Subject: Re: encoding problem with Xalan-j 2.2
> Have you tried
>
> > I have a problem with getting the intended output encoding with Xalan-j
> 2.2
> > as simple DOM-to-XML selializer.
> ...
> ...
>
>
> > // transformer.setOutputProperty (OutputKeys.ENCODING, "windows-1251");
>
> Uncomment this line, please.
>
> > FileOutputStream fos = new FileOutputStream ("E:\\test.xml");
> > OutputStreamWriter out = new OutputStreamWriter (fos,
"windows-1251" );
> > StreamResult result = new StreamResult (out);
>
> Try using a FileWriter:
>
> FileWriter fw = new FileWriter("E:\\text.xml");
> StreamResult result = new StreamResult(fw);
>
>
> What did you get now?
>
>
> - Isaac
>
Re: encoding problem with Xalan-j 2.2
Posted by "Isaac S." <is...@netvision.net.il>.
Have you tried
> I have a problem with getting the intended output encoding with Xalan-j
2.2
> as simple DOM-to-XML selializer.
...
...
> // transformer.setOutputProperty (OutputKeys.ENCODING, "windows-1251");
Uncomment this line, please.
> FileOutputStream fos = new FileOutputStream ("E:\\test.xml");
> OutputStreamWriter out = new OutputStreamWriter (fos, "windows-1251" );
> StreamResult result = new StreamResult (out);
Try using a FileWriter:
FileWriter fw = new FileWriter("E:\\text.xml");
StreamResult result = new StreamResult(fw);
What did you get now?
- Isaac