2

I have my own java static function in a class:

package com.test;

public class A {

    public static void returnSameNodes(Object nodes){
        return nodes;
    }


}

I tried to bind this function to XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:ext="java:com.test.A" >
    <xsl:template match="root">
        <xsl:apply-templates select="ext:returnSameNodes(//child::*)"></xsl:apply-templates>
    </xsl:template>
</xsl:stylesheet>

, but with the following error:

Cannot find a matching 1-argument function named etc.

I know what I'm doing wrong - I have to tell saxon(9B) that my class is in particular location, but I don't know how to do this. Any suggestions?? Including for example Math.sqrt() works great. Thanks

EDIT: The problem is setting up Java class path,anybody knows how to do this for this particular case? There is a note in a following link about setting a classpath variable, but how? http://www.saxonica.com/documentation/extensibility/functions.xml Thank you for suggestions

13
  • WOW! Let me think for a while Commented Nov 28, 2011 at 21:22
  • Can you provide me with some details (API reference, etc.) on how to write custom functions for XSLT in Java? I have never heard of a such possibility in Saxon. Commented Nov 28, 2011 at 21:24
  • All right! help is really appreciated Commented Nov 28, 2011 at 21:26
  • Are you referring to this? saxonica.com/documentation/extensibility/functions.xml Commented Nov 28, 2011 at 21:27
  • cafeconleche.org/books/xmljava/chapters/ch17s03.html nice article but:) Commented Nov 28, 2011 at 21:27

1 Answer 1

1

If you're running from the command line, then

(a) use the -TJ option to get better diagnostics on problems with extension functions

(b) ensure the class containing your method is on the classpath, for example

java -cp mycode;saxon9ee.jar net.sf.saxon.Transform -TJ -xsl:xxx.xsl -s:yyy.xml

where mycode is the directory containing your compiled class

(c) ensure you are using a Saxon release that supports reflexive extension functions (Saxon-HE does not).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.