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] |
Hi, I am doing an XSL to XSL transform. In the first xsl I have   in a few places that I expect to be output as a nbsp in the final transform to HTML. While the   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
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |