[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL > XSL trans. and Characher Encoding

Subject: XSL > XSL trans. and Characher Encoding
From: "L Rutker" <lrutker@xxxxxxxxxxx>
Date: Tue, 16 Oct 2001 11:12:27 -0400
fileinputstream encoding
Hi,
I am doing an XSL to XSL transform.
In the first xsl I have &#160 in a few places that I expect to be output as a nbsp in the final transform to HTML.
While the &#160 seems to be encoded as a nbsp in the first transform it converts to an  (an a with a hat in case this char doesn?t make it through the email system intact).
I am using Xalan on NT for the transforms. Below is some of my code (I hope no errors were created by ?cut and paste? but the code works).
I initially did not use any encoding but used a PrintWriter to do the output. That led to an ?illegal character? error. The UTF-8 encoding I use below prevented the error but led to the funny  character.
Any help would be appreciated.
Thanks



// code in main() for the first and second transform


FileOutputStream fos=
               new FileOutputStream(new File ("C:\\test_out.xsl"));
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
osw.write(transformBean.transform("C:\\test1.xml", "C:\\test1.xsl"));
osw.close();

FileOutputStream fos=
         new FileOutputStream(new File ("C:\\test_out_2.html") );
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
osw.write(transformBean.transform("C:\\test2.xml", "C:\\test_out.xsl"));
osw.close();

public String transform(String xmlPath, String xslPath)
throws IOException, TransformerConfigurationException, TransformerException {


FileInputStream xmlFis = new FileInputStream(xmlPath);
Reader xmlIn = new BufferedReader(new InputStreamReader(xmlFis, "UTF-8"));
StreamSource xmlSource= new StreamSource(xmlIn);


FileInputStream xslFis = new FileInputStream(xslPath);
Reader xslIn = new BufferedReader(new InputStreamReader(xslFis, "UTF-8"));
StreamSource xslSource= new StreamSource(xslIn);


       return realTransformer(xmlSource, xslSource);
   }


private String realTransformer(StreamSource xmlSource, StreamSource xslSource)
throws IOException, TransformerConfigurationException, TransformerException{


TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(xslSource);


       StringWriter sw=new StringWriter();
       transformer.transform(xmlSource, new StreamResult(sw));
       sw.flush();
       sw.close();
       return sw.toString();
   }


_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.