Hi all, I try to use translets within a web application. My environment is tomcat 5.5 and jdk 1.5, I wrote a small JSP page and try to load compiled translet class in to an input source and execute the transformation. Then I got following error message.
(Location of error unknown) org.apache.xerces.impl.io.MalformedByteSequenceException : Invalid byte 2 of 2-byte UTF-8 sequence. Here I have attached all required code for this example (here I used absolute paths, but i tried for relative paths also). Further, when I try same example as standalone application (with a main method), it worked nicely and produce the output also. Can some one help me to solve this? Thanks Sagara // JSP page // String transletName = "e:/person.xsl"; String transletName = "e:/person.class"; String documentURI = "e:/person.xml"; try { if ((transletName == null) || (documentURI == null)) { out.println("<h1>XSL transformation error</h1>"); out.println("The parameters <b><tt>class</tt></b> and " + "<b><tt>source</tt></b> must be specified"); } else { TransformerFactory tf = TransformerFactory.newInstance(); try { tf.setAttribute("use-classpath", Boolean.TRUE); } catch (IllegalArgumentException iae) { System.err.println( "Could not set XSLTC-specific TransformerFactory " + "attributes. Transformation failed."); } Transformer t = tf.newTransformer(new StreamSource(transletName)); // Start the transformation final long start = System.currentTimeMillis(); t.transform(new StreamSource(documentURI), new StreamResult(out)); final long done = System.currentTimeMillis() - start; out.println("<!-- transformed by XSLTC in "+done+"msecs -->"); } } catch (Exception e) { out.println("<h1>Error</h1>"); out.println(e.toString()); } <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <head><h1 align="center"> Person Database</h1></head> <table align="center"> <tr> <th bgcolor="yellow">Name</th> <th bgcolor="yellow">Email</th> <th bgcolor="yellow">Phone</th> </tr> <xsl:for-each select="Persons/Person"> <tr> <!--xsl:variable name="tempName" select="concat(Title,' ',First,' ',Last,' ')"/--> <td bgcolor="pink"> <xsl:value-of select="Title"/> </td> <td bgcolor="pink"> <xsl:value-of select="Email"/> </td> <td bgcolor="pink"> <xsl:value-of select="Phone"/> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>