Problem with non-ascii characters 2003-04-29 - By Allen Brookes
Hi,
I'm having a problem using Xalan with documents with non-ascii characters.
I do the following where args[0] is a stylesheet with no templates and args[1] is a simple XML document with encoding="Shift_JIS and a two character shift-jis string:
transformFactory_ = TransformerFactory.newInstance(); stylesheet_ = transformFactory_.newTemplates(new StreamSource(args[0]));
errorHandler_ = new XsltErrorListener(); transformFactory_.setErrorListener(errorHandler_); Reader stream = new FileReader(args[0]); Transformer processor = stylesheet_.newTransformer();
processor.setErrorListener(new XsltErrorListener());
StringWriter writer = new StringWriter();
processor.transform(new StreamSource(args[1]), new StreamResult(writer));
System.out.println(writer.getBuffer().toString());
The resulting string has question marks (??) for the shift-jis string.
If I process this with org.apache.xalan.xslt.Process I get the shift-jis string correctly encoded as UTF-8. As far as I can tell I'm doing the same thing that the Process class is doing.
Is there something that I'm doing wrong?
Thanks, Allen
|
|