Sending external variables to eXist. (XML:DB)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending external variables to eXist. (XML:DB)

Daniel E. Renfer
Hello,
        My original question was going to ask if there was any way to declare
external variables when passing an XQuery to eXist, but after looking
at the code quickly, and the fact that it's never used in any of the
examples, I know the answer is: "no".

        My new question is: How hard would it be to pass the input pipes
given to any of the XML:DB processors to exist using
org.exist.xmldb.XQueryService.declareVariable? (or similar/derived) I
tried looking at the code to see what it would take, but alas, I'm not
very familiar with Java yet, and even less familiar with the inner
workings of OPS. I'll give it a try if all of the developers are too
busy, but if someone that knows the system can do this quickly, so
much the better.

Basically, I want to be able to do this:

Instance:
<root>
        <name>World</name>
</root>

Pipeline:
<p:processor name="oxf:xmldb-query">
        <p:input name="datasource" href="datasource.xml"/>
        <p:input name="name" href="document("input:instance")//name"/>
        <p:input name="query">
                <xdb:query collection="/">
                        xquery version "1.0";
                       
                        declare variable $name as xs:string? external;

                        <html>
                                <head><title>Hello in XQuery</title></head>
                                <body>
                                        <p>Hello, {$name}!</p>
                                </body>
                        </html>
                </xdb:query>
        </p:input>
        <p:output name="data" ref="data"/>
</p:processor>

This same example today would require running the query through an
XSLT transformation to use xsl:value-of to drop the data into the
query and then pass it off to oxf:xmldb-query. This would still be
possible, just largely un-needed.

Thank you in advance for looking into this.

Daniel E. Renfer (http://kronkltd.net/)


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sending external variables to eXist. (XML:DB)

Alexander Žaťko
Dan,

There are many processors that one needs to precede with some kind of
XML-generating processor to construct a confix xml snippet if the
content of the config is not static. If I remember correctly, a
proposal to avoid using "pre-processors" was discussed on this list
previously. You might want to search the archive (which has been a
challenge lately as it seems to be impossible to do keyword searches
agains the ops list only).

A.


On Feb 17, 2006, at 11:05 AM, Daniel E. Renfer wrote:

> Hello,
> My original question was going to ask if there was any way to declare
> external variables when passing an XQuery to eXist, but after looking
> at the code quickly, and the fact that it's never used in any of the
> examples, I know the answer is: "no".
>
> My new question is: How hard would it be to pass the input pipes
> given to any of the XML:DB processors to exist using
> org.exist.xmldb.XQueryService.declareVariable? (or similar/derived) I
> tried looking at the code to see what it would take, but alas, I'm not
> very familiar with Java yet, and even less familiar with the inner
> workings of OPS. I'll give it a try if all of the developers are too
> busy, but if someone that knows the system can do this quickly, so
> much the better.
>
> Basically, I want to be able to do this:
>
> Instance:
> <root>
> <name>World</name>
> </root>
>
> Pipeline:
> <p:processor name="oxf:xmldb-query">
> <p:input name="datasource" href="datasource.xml"/>
> <p:input name="name" href="document("input:instance")//name"/>
> <p:input name="query">
> <xdb:query collection="/">
> xquery version "1.0";
>
> declare variable $name as xs:string? external;
>
> <html>
> <head><title>Hello in XQuery</title></head>
> <body>
> <p>Hello, {$name}!</p>
> </body>
> </html>
> </xdb:query>
> </p:input>
> <p:output name="data" ref="data"/>
> </p:processor>
>
> This same example today would require running the query through an
> XSLT transformation to use xsl:value-of to drop the data into the
> query and then pass it off to oxf:xmldb-query. This would still be
> possible, just largely un-needed.
>
> Thank you in advance for looking into this.
>
> Daniel E. Renfer (http://kronkltd.net/)
>
> --
> You receive this message as a subscriber of the
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sending external variables to eXist. (XML:DB)

Daniel E. Renfer
Alexander,

Okay, I'm not quite sure that understood your response, or that you
didn't understand my question. (maybe a little of both) As far as I
understand it (and please correct me if I'm wrong) from reading the
example on writing custom processors, a processor has to have as many
inputs and outputs as are declared using the add(Input|Output)Info
functions in the constructor, plus any number of optional inputs as
are passed to it. If the processor has nothing to do with a given
input, it is simply ignored.

  What I want, in the case of the XML:DB processors, is take the extra
inputs, loop through them, (I assume there is a way to find the names
of all the inputs attached to a processor, even though I haven't been
able to find it yet.) and send them off to the eXist database so they
can be imported for use in my XQuery scripts.

        Exist's mechanism for declaring external variables in Java is via the
function: org.exist.xmldb.XQueryService
.declareVariable(String qname, Object initialValue)

        My best guess on where this should go would be somewhere in:
org.orbeon.oxf.processor.xmldb.XMLDBProcessor

        Am I wrong about this in thinking that something like this could
work, or is there something I'm missing here?

Daniel E. Renfer ( http://kronkltd.net/)

On 2/17/06, Alexander Zatko <[hidden email]> wrote:

> Dan,
>
> There are many processors that one needs to precede with some kind of
> XML-generating processor to construct a confix xml snippet if the
> content of the config is not static. If I remember correctly, a
> proposal to avoid using "pre-processors" was discussed on this list
> previously. You might want to search the archive (which has been a
> challenge lately as it seems to be impossible to do keyword searches
> agains the ops list only).
>
> A.
>
>
> On Feb 17, 2006, at 11:05 AM, Daniel E. Renfer wrote:
>
> > Hello,
> >       My original question was going to ask if there was any way to declare
> > external variables when passing an XQuery to eXist, but after looking
> > at the code quickly, and the fact that it's never used in any of the
> > examples, I know the answer is: "no".
> >
> >       My new question is: How hard would it be to pass the input pipes
> > given to any of the XML:DB processors to exist using
> > org.exist.xmldb.XQueryService.declareVariable? (or similar/derived) I
> > tried looking at the code to see what it would take, but alas, I'm not
> > very familiar with Java yet, and even less familiar with the inner
> > workings of OPS. I'll give it a try if all of the developers are too
> > busy, but if someone that knows the system can do this quickly, so
> > much the better.
> >
> > Basically, I want to be able to do this:
> >
[SNIP]

> >
> > This same example today would require running the query through an
> > XSLT transformation to use xsl:value-of to drop the data into the
> > query and then pass it off to oxf:xmldb-query. This would still be
> > possible, just largely un-needed.
> >
 > > Thank you in advance for looking into this.
> >
> > Daniel E. Renfer (http://kronkltd.net/)


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Sending external variables to eXist. (XML:DB)

Richard Braman
In reply to this post by Daniel E. Renfer
Erik there was never a reply from you guys on this question.  I would
like to know too.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Daniel
E. Renfer
Sent: Friday, February 17, 2006 11:05 AM
To: [hidden email]
Subject: [ops-users] Sending external variables to eXist. (XML:DB)


Hello,
        My original question was going to ask if there was any way to
declare external variables when passing an XQuery to eXist, but after
looking at the code quickly, and the fact that it's never used in any of
the examples, I know the answer is: "no".

        My new question is: How hard would it be to pass the input pipes
given to any of the XML:DB processors to exist using
org.exist.xmldb.XQueryService.declareVariable? (or similar/derived) I
tried looking at the code to see what it would take, but alas, I'm not
very familiar with Java yet, and even less familiar with the inner
workings of OPS. I'll give it a try if all of the developers are too
busy, but if someone that knows the system can do this quickly, so much
the better.

Basically, I want to be able to do this:

Instance:
<root>
        <name>World</name>
</root>

Pipeline:
<p:processor name="oxf:xmldb-query">
        <p:input name="datasource" href="datasource.xml"/>
        <p:input name="name" href="document("input:instance")//name"/>
        <p:input name="query">
                <xdb:query collection="/">
                        xquery version "1.0";
                       
                        declare variable $name as xs:string? external;

                        <html>
                                <head><title>Hello in
XQuery</title></head>
                                <body>
                                        <p>Hello, {$name}!</p>
                                </body>
                        </html>
                </xdb:query>
        </p:input>
        <p:output name="data" ref="data"/>
</p:processor>

This same example today would require running the query through an XSLT
transformation to use xsl:value-of to drop the data into the query and
then pass it off to oxf:xmldb-query. This would still be possible, just
largely un-needed.

Thank you in advance for looking into this.

Daniel E. Renfer (http://kronkltd.net/)




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sending external variables to eXist. (XML:DB)

Erik Bruchez
Administrator
In reply to this post by Daniel E. Renfer
Daniel,

 > My original question was going to ask if there was any way to
 > declare external variables when passing an XQuery to eXist, but
 > after looking at the code quickly, and the fact that it's never used
 > in any of the examples, I know the answer is: "no".

That's correct.

 > My new question is: How hard would it be to pass the input pipes
 > given to any of the XML:DB processors to exist using
 > org.exist.xmldb.XQueryService.declareVariable? (or similar/derived)
 > I tried looking at the code to see what it would take, but alas, I'm
 > not very familiar with Java yet, and even less familiar with the
 > inner workings of OPS. I'll give it a try if all of the developers
 > are too busy, but if someone that knows the system can do this
 > quickly, so much the better.

 > Basically, I want to be able to do this:

[snip]

 > This same example today would require running the query through an
 > XSLT transformation to use xsl:value-of to drop the data into the
 > query and then pass it off to oxf:xmldb-query. This would still be
 > possible, just largely un-needed.

That's right, variables could be, possibly, a better option. Note that
there were talks about making it easier in XPL to perform an XSLT
transformation by allowing embedding them within an input, as you can
do today with a static document.

Now the main questions is: what would the syntax to provide variables
to the processor be? I think that since an obvious goal is to avoid
dynamically generating the main processor configuration, it would
obvsiously be a mistake to introduce the variable values there.

This means that the only other possibility is to provide an additional
input to the processor, such as a "variables" input. What would the
format be? I see two solutions:

o fixed format, like what you proposed:

     <root>
       <name>World</name>
     </root>

     or:

     <variables>
       <variable name="name" select="'World'"/>
     </variables>

     or, if you want to pass more than simple types:

     <variables>
       <variable name="name">World</variable>
     </variables>

o flexible format, where you would provide any document you like but
   would tell the XQuery processor where to find the variables in the
   main configuration:

   <xdb:query collection="/">
     <xdb:variable name="name" path="/root/name" as="xs:string"/>
       ...

Now as of yet, I am not sure that all this would be a huge improvement
over allowing embedding XSLT within <p:input name="query">. The only
drawback of the XSLT way I see, in fact, is that:

1. You are not using XQueryService variables, but what is the impact
    of that? Does the database actually "compile" the XQuery queries?

2. An XSLT transformation is running, which may have a performance
    impact.

On the other hand, using XSLT:

1. Simplifies greatly the processor interface.

2. Is a mechanism that can be used for any processor that takes a
    dynamic configuration.

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sending external variables to eXist. (XML:DB)

Erik Bruchez
Administrator
In reply to this post by Daniel E. Renfer
Daniel E. Renfer wrote:

> Alexander,
>
> Okay, I'm not quite sure that understood your response, or that you
> didn't understand my question. (maybe a little of both) As far as I
> understand it (and please correct me if I'm wrong) from reading the
> example on writing custom processors, a processor has to have as many
> inputs and outputs as are declared using the add(Input|Output)Info
> functions in the constructor, plus any number of optional inputs as
> are passed to it. If the processor has nothing to do with a given
> input, it is simply ignored.
>
>   What I want, in the case of the XML:DB processors, is take the extra
> inputs, loop through them, (I assume there is a way to find the names
> of all the inputs attached to a processor, even though I haven't been
> able to find it yet.) and send them off to the eXist database so they
> can be imported for use in my XQuery scripts.
>
> Exist's mechanism for declaring external variables in Java is via the
> function: org.exist.xmldb.XQueryService
> .declareVariable(String qname, Object initialValue)
>
> My best guess on where this should go would be somewhere in:
> org.orbeon.oxf.processor.xmldb.XMLDBProcessor
>
> Am I wrong about this in thinking that something like this could
> work, or is there something I'm missing here?
No you are absolutely right, this is something can can be done. Now the
real question is: should we do it, as opposed to using the "embedded"
XSLT alternative?

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws