Hello
Thank you for answering my question.
I use now the SaxonPE as you told me in 1).
I correct the namespace URI of the java class. 
However, I didn't understood how to invoke an instance-level method. 
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.
So, I did this:
 
 <adresse>
{
adr:getAdress(adr:new())
}
</adresse>
 
Is that correct?
 
Thank you in advance for any help.
2010/6/28 saxon-help-request@lists.sourceforge.net
 
Message: 2
Date: Mon, 28 Jun 2010 15:49:13 +0100
From: Michael Kay <mike@saxonica.com>
Subject: Re: [saxon] External Java function call
To: saxon-help@lists.sourceforge.net
Message-ID: <4C28B669.50109@saxonica.com>
Content-Type: text/plain; charset="iso-8859-1"
 
 
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
 
-------------- next part --------------
An HTML attachment was scrubbed...
 
------------------------------