Re: [xsl] Saxon custom extensions problem

Subject: Re: [xsl] Saxon custom extensions problem
From: "Gustaf Liljegren" <gustaf.liljegren@xxxxxx>
Date: Tue, 16 Oct 2001 18:39:10 +0200
From: "Joerg Pietschmann" <joerg.pietschmann@xxxxxx>:

> I'd actually bet it's a class path issue, check whether the
> class file of your extension class is available in the class
> path (you might have to include ".", the current directory,
> or something).

Since I have the class file in the same directory as the stylesheet, and
that is the current directory, I don't think that should be needed. Even the
first cup of Java says that "one of the places java tries to find your
bytecode file is your current directory." And some freaks says you shouldn't
use CP at all, so I'm still in the darkness about some seemingly fundamental
things about Java... :-|

I usually run saxon from a batch file, with only the saxon class path, as
in:

java -cp e:\saxon\saxon.jar com.icl.saxon.StyleSheet %1 %2 > %3

To be on the safe side, I added both the current directory and "." (the
same).

-cp e:\saxon\saxon.jar;e:\test;.

Alltogether, it looks like this:

E:\test>java -cp e:\saxon\saxon.jar;e:\test;. com.icl.saxon.StyleSheet
toupper.xml toupper.xsl > out.xml
java.lang.NullPointerException
        at
com.icl.saxon.StandardErrorListener.getExpandedMessage(StandardErrorL
istener.java:174)
        at
com.icl.saxon.StandardErrorListener.error(StandardErrorListener.java:
110)
        at
com.icl.saxon.StandardErrorListener.fatalError(StandardErrorListener.
java:136)
        at com.icl.saxon.Controller.transform(Controller.java:926)
        at com.icl.saxon.StyleSheet.processFile(StyleSheet.java:508)
        at com.icl.saxon.StyleSheet.doMain(StyleSheet.java:330)
        at com.icl.saxon.StyleSheet.main(StyleSheet.java:62)

To minimize the risks, I do this with an even smaller example than last
time:

class ToUpperCase {
  public static String toUpper(String source) {
    return source.toUpperCase();
  }
}


I've seen the Java app work when it's called from another Java app.

Source:

<?xml version="1.0"?>
<text>Polly wants a cracker!</text>

Stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:my="java:ToUpperCase"
  extension-element-prefixes="my">
  <xsl:template match="text">
    <out><xsl:value-of select="my:toUpper(.)"/></out>
  </xsl:template>
</xsl:stylesheet>

Note that when I call a function in 'my:' that does not exist, Java says:

  No method matching toUppe with 1 parameter found in class ToUpperCase
Transformation failed: run-time errors were reported

I was close to say, hope this helps... :-)

Gustaf Liljegren



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


Current Thread