1. This style of external call is not supported in Saxon HE, only in PE or EE.

2. You've got the namespace URI wrong: it should be "java:org.Interface.Adress"

3. Because getAdress() is an instance-level method rather than a static method, you'll need to supply an argument which is the Adress object on which you want the method invoked.

For full details of writing and calling "reflexive" Java extension methods please see

http://www.saxonica.com/documentation/extensibility/functions.html

Michael Kay
Saxonica

On 28/06/2010 14:26, maha maalej wrote:

Hello

I'm using saxon9he for compilating my xquery into my java application.

I have an XQUERY query that work well until I add an external function call. This function is written in java.  

 

This is the Java function: 

 

package org.Interface;
import java.net.InetAddress;

public class Adress {  
    private String adress;

    public String getAdress() {
        try {
            InetAddress iadr = InetAddress.getLocalHost();        
            adress = iadr.getHostAddress();        
        }catch(Exception exp) {
            exp.printStackTrace();
        }

 return adress;
} }

 

and this is the Java function call in my query (with saving this query in the same folder as the Java function):

 

declare namespace xfn="org.Interface";

 

I tried this too for the namespace but no result:

 

declare namespace xfn="java:Adress?path=file:///C:/CMR/src/org/Interface/";

and this too

declare namespace xfn="java:org.Interface";

 

<adresse>

{xfn:getAdress()

}

</adresse>

 

 However , I get this error

 

XPST0017: Cannot find a matching 0-argument function named

  {java:org.Interface}getAdress()

; SystemID: file:/C:/CMR/DCU/test.xmi; Line#: 98; Column#: -1

net.sf.saxon.trans.XPathException: Cannot find a matching 0-argument function named {java:org.Interface}getAdress()

        at net.sf.saxon.query.UnboundFunctionLibrary.bindUnboundFunctionCalls(UnboundFunctionLibrary.java:114)

        at net.sf.saxon.query.QueryModule.bindUnboundFunctionCalls(QueryModule.java:1059)

        at net.sf.saxon.instruct.Executable.fixupQueryModules(Executable.java:557)

        at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:114)

        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:484)

        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:518)

 

Thank you in advance for any help.

 

With best regards.

 

------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help