Project

Profile

Help

Java Extension

Added by Anonymous about 18 years ago

Legacy ID: #3910940 Legacy Poster: Nilesh (pragprog)

Hello I am facing a problem using a very simple Java extension in XSLT. I have gone through mailing list and forum archive and found similar problems earlier but none of the solutions seem to help me. So just wanted to post the details here and see if anyone can help me to figure out problem in my configuration / program Here are the details: JDK: 1.5.0_08 Saxon: Tried with saxonb8-6, saxonb8-8j, and saxonsa8-8j Java code in xslextension.java: public class xslextension { public static String say() { return "hello"; } } XSL in sample.xsl: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="java:xslextension" extension-element-prefixes="java" version="2.0"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body bgcolor="#FFFFFF"> <h3><xsl:value-of select="java:say()"/></h3> </body> </html> </xsl:template> </xsl:stylesheet> Java Run command: java -classpath saxon8-dom.jar;xsltextension.jar -jar saxon8.jar -TJ sample-xml.xml sample.xsl AND java -classpath .\xsltextension.jar -jar saxon8.jar -TJ sample-xml.xml sample.xsl Error I get each time: Loading xslextension No Java class xslextension could be loaded Error at xsl:value-of on line 15 of file:/sample.xsl: XPST0003: XPath syntax error at char 10 on line 15 in {java:say()}: Cannot find a matching 0-argument function named {java:xslextension}say() Failed to compile stylesheet. 1 error detected. Thanks


Replies (2)

RE: Java Extension - Added by Anonymous about 18 years ago

Legacy ID: #3910994 Legacy Poster: Michael Kay (mhkay)

When you use the -jar option on the command line, the classpath is ignored. If you want the classpath to be available for dynamic loading, you must run Saxon using "java net.sf.saxon.Transform".

RE: Java Extension - Added by Anonymous about 18 years ago

Legacy ID: #3911017 Legacy Poster: Nilesh (pragprog)

I did not know that. Thanks a lot! That worked.

    (1-2/2)

    Please register to reply