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 Pavel Ausianik <Pa...@epam.com> on 2002/09/24 17:51:09 UTC

RE: Transformer uses correct encoding, but does not write UTF-8 m arker into file

Hello, 

as many suggested it is not really required, however if you really need
this, you may create FileOutputStream, write leading bytes here, and then
use stream to construct StreamResult.

Best regards,
Pavel

> -----Original Message-----
> From: Thomas Borkel [mailto:tb@ap-ag.com]
> Sent: Tuesday, September 24, 2002 11:19 AM
> To: Xalan Mailinglist
> Subject: Transformer uses correct encoding, but does not 
> write UTF-8 marker into file
> 
> 
> HI!
> 
> I am writing an XML DOM to a file, using UTF-8 encoding. The 
> encoding is OK, the XML declaration is there, but the leading 
> UTF-8 markers are missing in the file. Is this a bug or how 
> can this be achieved? Thanks!
> 
> This is the code:
> 
>     TransformerFactory tFactory;
>     Transformer transformer;
>     StreamResult streamResult;
>     
>     tFactory = TransformerFactory.newInstance();
>     transformer = tFactory.newTransformer();      
>     transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
>     streamResult = new StreamResult(file);
>     transformer.transform(new DOMSource(node), streamResult); 
> 
> 
> Regards,
> Thomas
> 
>