I followed all the steps you wrote.
my current directory : saxon;
my package : saxon/pkg (contains GenerateId.java and GenerateId.class)
query : source/test.xql
source : source/test.xml
Then I added the path for pkg in the classpath : c:/saxon/pkg

Test.xql :
declare namespace gi = "java:pkg.GenerateId";
    let $node := /*[1]
    <id>  {   gi:generateId($node) }
I get an error : coudln't find a matching 1-argument fucntion named {


----- Message d'origine ----
De : Florent Georges <darkman_spam@yahoo.fr>
À : saxon-help@lists.sourceforge.net
Envoyé le : Jeudi, 1 Juin 2006, 2h56mn 28s
Objet : RE: Re : Re : Re : [saxon] How to generate an Identifer in XQuery

enis enis wrote:


> If I understood well, I have to write :

> [...]

> but I'm not sure about how to write it, compile it,
> declare it and call it from the query file. Things are
> mixed in my mind !

  Maybe the discussion in getting a little bit OT, because
we are speaking of Java basis, IMHO.  But I think it may be
interesting to have such an all-steps-explained message on
the archive of the list.

    > cat pkg/GenerateId.java
    package pkg;

    import net.sf.saxon.om.FastStringBuffer;
    import net.sf.saxon.om.NodeInfo;

    public class GenerateId
        public static String generateId(NodeInfo node) {
            FastStringBuffer buffer = new FastStringBuffer(16);
            return buffer.toString();

    > cat test.xq
    declare namespace gi = "java:pkg.GenerateId";
    let $node := /*[1]
        <id>{ gi:generateId($node) }</id>

    > cat test.xml

    > javac -cp "path/to/saxon8.jar" pkg/GenerateId.java

    > java -cp ".;path/to/saxon8.jar" net.sf.saxon.Query \
          -s test.xml test.xq
    <?xml version="1.0" encoding="UTF-8"?>

  So two things in addition to the usual Java things:

    1/ your extension class has to be in the classpath when
       you invoque Saxon;

    2/ in your query, you declare a namespace whose the URI
       is "java:<your.class.name>", then you access the
       methods by using the prefix, and the method name as
       the local part.

  See the Saxon documentation for further info:


  At the bottom, you have three links:

    - Calling Static Methods in a Java Class
    - Calling Java Constructors
    - Calling Java Instance-Level Methods




Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.

All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
saxon-help mailing list