Well, you're confusing me, because you show both a call of XQuery from the command line, and also a call from your own application XQClass.java.

In your command line call, your class containing your extension function doesn't appear to be on the classpath.

You say "I put the class "Adress" in "C:\CMR\src\..\org.Interface" - which looks a bit odd. I don't know what the ".." means in that path, and it should be org\Interface rather than org.Interface. Anyway, if the compiled code is in c:\CMR\src\org\Interface\Adress.class, then the directory c:\CMR\src\org\Interface should be on your classpath.

Michael Kay
Saxonica

On 01/07/2010 12:03, maha maalej wrote:
Hello again,
 
a) This is my Java class:
 
package org.Interface;
import java.net.InetAddress;
/**
 *
 * @author HP
 */
public class Adress {
   
    private static String adress="";

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

 return adress;
}

}
b) Yes I run from command line, like this:
 
C:\CMR>java -classpath "C:\Program Files\saxonpe9-2-0-6j\saxon9pe.jar;C:\Program Files\saxonpe9-2-0-6j" net.sf.saxon.Query -s:"C:\CMR\SB\dcu\abc.xmi" -q:"C:\CMR\SB\dcu\Transformer_XMI_XML.xquery"
 
I put the query "Transformer_XMI_XML.xquery" in "C:\CMR\SB\dcu\"
I put the class "Adress" in "C:\CMR\src\..\org.Interface"
 
I put the class which does the transformation "XQClass.java" in "C:\CMR\src\..\org.Interface"
with this transformation method:
 
public void XQtransform(String source,String output) throws XQException, XPathException, IOException {
        try {
            final Configuration config = new Configuration();
            final StaticQueryContext sqc = new StaticQueryContext(config);
            sqc.setBaseURI(new File(source).toURI().toString());
            final XQueryExpression exp = sqc.compileQuery(new FileReader("C:/CMR/SB/dcu/Transformer_XMI_XML.xquery"));
            final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
            Properties props = new Properties();
            dynamicContext.setContextItem(sqc.buildDocument(new StreamSource(source)));
 
            final SequenceIterator iter = exp.iterator(dynamicContext);
            props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            props.setProperty(OutputKeys.INDENT, "yes");
 
            FileOutputStream otf = new FileOutputStream(output);
            QueryResult.serializeSequence(iter, config, otf, props);
            otf.close();

            } catch (FileNotFoundException ex) {
            Logger.getLogger(XQJEx.class.getName()).log(Level.SEVERE, null, ex);
        }
}
 
 Thank you very much for your help.
------------------------------------------------------------------------------ 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