Hello,
I have a String containing an xml document with iso-8859-1 encoding. I would like to transform it without using an xsl but with an XMLFilterImpl.
Then I have the following code :
Transformer transformer_ = new org.apache.xalan.processor.TransformerFactoryImpl().newTransformer(); SAXParserFactory factory_ = new org.apache.xerces.jaxp.SAXParserFactoryImpl().newInstance();
SAXParser saxParser = factory_.newSAXParser(); filter.setParent(saxParser.getXMLReader());
InputSource is = new InputSource(new
ByteArrayInputStream(acXmlConf.getBytes("ISO8859_1")));
is.setEncoding("ISO8859_1");SAXSource source = new SAXSource(filter, is);
//SAXSource source = new SAXSource(is);
logger_.debug("check IS encoding :"+source.getInputSource().getEncoding());ByteArrayOutputStream baos = new ByteArrayOutputStream();
java.io.OutputStreamWriter osw = new
java.io.OutputStreamWriter(baos,"ISO8859_1");
logger_.debug("osw encoding :"+osw.getEncoding());
StreamResult sr = new StreamResult(osw);transformer_.transform(source, sr);
I have for a result an xml with the default encoding UTF-8 instead the one I expect, I mean iso-8859-1. I have the same result even if I don't use the filter (see the commented line).
What have I done wrong ?
Laurent F.
