This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question with xalan, java, utf8



>I'm trying to output HTML using UTF-8 characters. When I use Instant
>Saxon with my xml and xsl file, all if well. But if I try to do this
>through Java I've had multiple problems!

Hi Gail,
      That is a Saxon bug.   We had a multiple problems with this (still
love Saxon, Mr. Kay!).  The following is what we did to perform our
transforms.  It made sure that each character would be written out at
UTF-8.

Hope it helps.
Matt

TransformerFactoryImpl tfi = new TransformerFactoryImpl();
Templates templates = tfi.newTemplates(new StreamSource(new File(getXslFile
())));
Transformer transformer = templates.newTransformer();

//Source file - style sheet
source = new StreamSource(new File(inputFile));

baos = new java.io.ByteArrayOutputStream();
result = new StreamResult(baos);

//Rock and roll
transformer.transform(source, result);

fos = new FileOutputStream(getMassagingFinishedFile());
osw = new OutputStreamWriter(fos, getOutputFileEncoding());

String s = new String(baos.toByteArray(), "utf-8");
osw.write(s);











 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]