qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Qexo-general] How to use fn:input()


From: Phil Shaw
Subject: RE: [Qexo-general] How to use fn:input()
Date: Thu, 30 Jan 2003 11:59:33 -0800




I've also been fumbling with how to apply an XQuery to a
set of documents from Java.

I.e. I'd like to write a Java method of the form:

        String evalXQuery(String query, String[]docs) {
        // Evaluate the "query", somehow making the "docs"
        // available to it.

        }


Here's a rough idea:


        
        String evalXQuery(String query, String[]docs) {
           XQuery xq = new XQuery();
           for (int i=0; i<docs.length; i++) {
              xq.setInput(docs[i]);
           }
           xq.eval(query,...);

        }


Then the "query" would reference the N "docs" as:

        fn:input()[i]

Here's another variant:

        
        String evalXQuery(String query, String[]docs) {
           XQuery xq = new XQuery();
           for (int i=0; i<docs.length; i++) {
              xq.setDocument("document"+i, docs[i]);
           }
           xq.eval(query,...);

        }

I.e. the first parameter of "setDocument" would specify
a URI for the second parameter.  The "query" would then
reference the first of the "docs" as:

        fn:document("document:1")

etc.  This version would allow the Java method to "cache"
documents referenced by URLs, and also to make up URIs
(e.g. "document:1") for local documents.

All of this is similar to the Java JDBC facility for
invoking SQL expressions from Java.    The idea is to 
evaluate an expression in anotehr language, and first
specify the arguments that the expression will reference.

There is a Java Community Process activity for "JAXQ" 
to define a similar facility to invoke XQuery from Java, 
which will eventually specify facilities.  That effort
is having trouble getting started, due to lawyer
wrangling, so implementations will have to work out
ad hoc facilities in the meantime.

 
Phil Shaw

P.S.   I'm new to this forum, and I'm not sure the
       proper way to send a note, so let me know
       if email to "address@hidden" is the
       wrong approach.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]