[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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. No it's not, as I explained in my previous response. > 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. > Your code looks as if it will work, but it is quite unnecessarily convoluted. Just create the StreamResult to wrap a FileOutputStream. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|