• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSL Transformation is failing to convert XML with special characters

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


XSL Transformation is failing to convert XML with special characters.

My application is on Websphere 4.0 on AIX.

My XML element and data looks like below.


<?xml version="1.0" encoding="iso-8859-1"?>
<MAIN>
<SUMMARY>The IBM 6645 NetVista S40 Series of personal systems is designed to be the central point for all of your computing needs. Model Abstract 6645-P1A:� The IBM 6645 Model P1A NetVista S40 Series has a 133/733MHz Pentium III processor, 256KB cache, 128MB-100MHz memory, Windows 2000 software preload,
</SUMMARY>
</MAIN>

It has special characters in following words "Abstract 6645-P1A:� " in SUMMARY element.


My XSL looks like below.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl utput method="html" indent="yes" encoding="iso-8859-1"/>
<xsl:stylesheet>
<xsl:template match="MAIN">
<xsl:value-of select="HitlistCount"/>
</xsl:template>
</xsl:stylesheet>
I am using xalan and xerces combination to transform XML to HTML ie: using XERCES java transformation API. My application is a servlet application.


My java code looks like below :

PrintWriter out =response.getWriter();
OutputFormat format = new OutputFormat("xhtml", "ISO-8859-1", true);
format.setPreserveSpace(true);
format.setDoctype(
"-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd");
format.setOmitXMLDeclaration(true);
SerializerFactory factory = SerializerFactory.getSerializerFactory("xml");
Serializer serializer = factory.makeSerializer(out, format);
serializer.setOutputFormat(format);
XSLTProcessor xsltProc = XSLTProcessorFactory.getProcessor();

xsltProc.process(
new XSLTInputSource("xmlFile"),
new XSLTInputSource("xslFile"),
new XSLTResultTarget(out));


I am getting the following exception during the transformation:

showHTML : caught Exception = [ javax.xml.transform.TransformerException: SAX Exception
at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1542)
at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1507)
at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:531)


I am able to view the XML properly on my local adding the XSL link to XML.
<?xml-stylesheet type="text/xsl" href="abc.xsl" ?>
Do I need to change anything in my XSL or in Java transformation API

Thanks in advance
Shekar
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic