Query regarding execution of multiple xqueries with saxon API

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

Query regarding execution of multiple xqueries with saxon API

Dasgupta, Subhojit (Subhojit)** CTR **
Hi

I am using Saxon B 8.5.1 version and i need to execute multiple xqueries in
my application. I have written a java API that compiles the xqueries that i
have and the library module  in a static context and then execute those
xqueries in a dynamic context.Also it loads the xml file in the dynamic
context. For this i used the standard  functions provided by saxon (like
compileQuery(), evaluateSingle() etc). The issue that i am facing is that
the above works fine when i am using a single xquery.But in my application
i need to execute multiple xqueries from the same  .xq file in the same
context and collect some performance statistics for all those xqueries (viz
execution time for each xquery etc). Also i cannot afford to load the XML
file more than once as it as huge!!.

        With the setup i have as mentioned here, i am unable to execute
multiple xqueries. Does Saxon provide an alternate way of achieving the same
and collect performance data for each and every xquery that i execute?

I am looking forward to some help in this regard as to how multiple xqueries
can be created in saxon without creating  a context for every new query from
the xquery file.

Best Regards
Subhojit



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Query regarding execution of multiple xqueries with saxon API

Dasgupta, Subhojit (Subhojit)** CTR **
Hi

In context of the above query that i posted, i would also like to mention
that currently i am executing all the xqueries as a comma separated List in
the dynamic context.In such a case will it be possible to print the
execution time for each xquery executed in tandem ?.Doesnt work currently
though!!.

Best Regards
Subhojit

>  -----Original Message-----
> From: Dasgupta, Subhojit (Subhojit)** CTR **  
> Sent: Wednesday, November 16, 2005 7:53 PM
> To: '[hidden email]'
> Subject: Query regarding execution of multiple xqueries with saxon
> API
>
> Hi
>
> I am using Saxon B 8.5.1 version and i need to execute multiple xqueries
> in my application. I have written a java API that compiles the xqueries
> that i have and the library module  in a static context and then execute
> those xqueries in a dynamic context.Also it loads the xml file in the
> dynamic context. For this i used the standard  functions provided by saxon
> (like compileQuery(), evaluateSingle() etc). The issue that i am facing is
> that the above works fine when i am using a single xquery.But in my
> application  i need to execute multiple xqueries from the same  .xq file
> in the same context and collect some performance statistics for all those
> xqueries (viz execution time for each xquery etc). Also i cannot afford to
> load the XML file more than once as it as huge!!.
>
> With the setup i have as mentioned here, i am unable to execute
> multiple xqueries. Does Saxon provide an alternate way of achieving the
> same and collect performance data for each and every xquery that i
> execute?
>
> I am looking forward to some help in this regard as to how multiple
> xqueries can be created in saxon without creating  a context for every new
> query from the xquery file.
>
> Best Regards
> Subhojit
>


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Query regarding execution of multiple xqueries with saxon API

Michael Kay
In reply to this post by Dasgupta, Subhojit (Subhojit)** CTR **
I'm not sure where your difficulty lies. Perhaps it would be easier if you
showed your code.

Firstly, I don't understand why you want to create multiple queries from the
same .xq file. Why not create one query and execute it multiple times?

Secondly, if you do need to create multiple queries, there is no difficulty
doing so. You just call compileQuery() more than once. You can either use
the same StaticContext or a different StaticContext for each query.

There's also no problem in parsing the source document once and then using
it repeatedly. Call the buildDocument() method in StaticQueryContext once to
build the DocumentInfo, then supply this DocumentInfo as the context item in
the dynamic context for each query evaluation.

I hope this helps.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Dasgupta, Subhojit (Subhojit)** CTR **
> Sent: 16 November 2005 14:23
> To: '[hidden email]'
> Subject: [saxon] Query regarding execution of multiple
> xqueries with saxon API
>
> Hi
>
> I am using Saxon B 8.5.1 version and i need to execute
> multiple xqueries in
> my application. I have written a java API that compiles the
> xqueries that i
> have and the library module  in a static context and then
> execute those
> xqueries in a dynamic context.Also it loads the xml file in
> the dynamic
> context. For this i used the standard  functions provided by
> saxon (like
> compileQuery(), evaluateSingle() etc). The issue that i am
> facing is that
> the above works fine when i am using a single xquery.But in
> my application
> i need to execute multiple xqueries from the same  .xq file
> in the same
> context and collect some performance statistics for all those
> xqueries (viz
> execution time for each xquery etc). Also i cannot afford to
> load the XML
> file more than once as it as huge!!.
>
> With the setup i have as mentioned here, i am unable to execute
> multiple xqueries. Does Saxon provide an alternate way of
> achieving the same
> and collect performance data for each and every xquery that i execute?
>
> I am looking forward to some help in this regard as to how
> multiple xqueries
> can be created in saxon without creating  a context for every
> new query from
> the xquery file.
>
> Best Regards
> Subhojit
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
> Register for a JBoss Training Course.  Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: RE: Query regarding execution of multiple xqueries with saxon API

Michael Kay
In reply to this post by Dasgupta, Subhojit (Subhojit)** CTR **
I'm sorry, I don't understand. How can you have a comma-separated list of
queries, when a query can contain a comma? And I don't understand why you're
having difficult measuring the execution time: what technique are you using?

You might find it useful to look at the source code of net.sf.saxon.Query.
This has an undocumented option -3, which causes the query to be executed
three times, displaying the timings for each execution.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Dasgupta, Subhojit (Subhojit)** CTR **
> Sent: 16 November 2005 14:50
> To: '[hidden email]'
> Subject: [saxon] RE: Query regarding execution of multiple
> xqueries with saxon API
>
> Hi
>
> In context of the above query that i posted, i would also
> like to mention
> that currently i am executing all the xqueries as a comma
> separated List in
> the dynamic context.In such a case will it be possible to print the
> execution time for each xquery executed in tandem ?.Doesnt
> work currently
> though!!.
>
> Best Regards
> Subhojit
>
> >  -----Original Message-----
> > From: Dasgupta, Subhojit (Subhojit)** CTR **  
> > Sent: Wednesday, November 16, 2005 7:53 PM
> > To: '[hidden email]'
> > Subject: Query regarding execution of multiple xqueries
> with saxon
> > API
> >
> > Hi
> >
> > I am using Saxon B 8.5.1 version and i need to execute
> multiple xqueries
> > in my application. I have written a java API that compiles
> the xqueries
> > that i have and the library module  in a static context and
> then execute
> > those xqueries in a dynamic context.Also it loads the xml
> file in the
> > dynamic context. For this i used the standard  functions
> provided by saxon
> > (like compileQuery(), evaluateSingle() etc). The issue that
> i am facing is
> > that the above works fine when i am using a single xquery.But in my
> > application  i need to execute multiple xqueries from the
> same  .xq file
> > in the same context and collect some performance statistics
> for all those
> > xqueries (viz execution time for each xquery etc). Also i
> cannot afford to
> > load the XML file more than once as it as huge!!.
> >
> > With the setup i have as mentioned here, i am unable to execute
> > multiple xqueries. Does Saxon provide an alternate way of
> achieving the
> > same and collect performance data for each and every xquery that i
> > execute?
> >
> > I am looking forward to some help in this regard as to how multiple
> > xqueries can be created in saxon without creating  a
> context for every new
> > query from the xquery file.
> >
> > Best Regards
> > Subhojit
> >
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
> Register for a JBoss Training Course.  Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: RE: Query regarding execution of multiple xqueries with saxon API

Michael Kay
In reply to this post by Dasgupta, Subhojit (Subhojit)** CTR **
Please don't go off-list! It's important that the answer to the question
should be archived along with the question.

I see what you're doing now: they aren't separate queries, but separate
expressions within a single query.

current-time() is defined to return the same result if called multiple times
within a query (as required to make it a pure function). See

http://www.w3.org/TR/xpath-functions/#func-current-time

and follow the link to "stable".

Even if it weren't stable, your results would be totally unpredictable
because there's no guarantee that the expressions in a list are evaluated
sequentially (although in this example, it's probably fairly safe).

I would normally do measurements from the calling Java code. If you want to
do it this way, try calling System.getTimeInMillis() as an extension
function.

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: Dasgupta, Subhojit (Subhojit)** CTR **
> [mailto:[hidden email]]
> Sent: 17 November 2005 13:03
> To: '[hidden email]'
> Subject: RE: [saxon] RE: Query regarding execution of
> multiple xqueries with saxon API
>
> Hi Michael
>
> Here is how i have placed my queries as a comma separated
> List in the xquery
> file list.xq
>
> let $x := 10 return
> <test>
> {
> fn:current-time(),(q1),fn:current-time(),(q2),fn:current-time(), (q3),
> fn:current-time()
> }
> </test>
>
> The function fn:current() is printing the same execution time
> for all the
> queries and the query result also is coming in one single
> shot (probably
> because i am using evaluateSingle() to execute the List of queries!!).
>
> For example i am getting a result similar to one below :
>
> true() 13:12:10 false() 12:12:10 true() 13:12:10 .
>
> Just to clarify your doubt about commas, there is no comma in
> any of the
> xqueries i am using.I used commas only in the error string
> for each query
> which doesnt impact the xquery as such.
>
> I hope this gives you an idea of how i want to execute the
> queries in tandem
> yet collect execution time for each individual query.
>
> Thanks
> Subhojit
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of
> Michael Kay
> Sent: Thursday, November 17, 2005 5:33 PM
> To: [hidden email]
> Subject: FW: [saxon] RE: Query regarding execution of
> multiple xqueries
> with saxon API
>
>
> Apologies if you get this twice. The original does not seem
> to have reached
> the archives or the originator.
>
> -----Original Message-----
> From: Michael Kay [mailto:[hidden email]]
> Sent: 16 November 2005 18:53
> To: '[hidden email]'
> Subject: RE: [saxon] RE: Query regarding execution of
> multiple xqueries with
> saxon API
>
> I'm sorry, I don't understand. How can you have a
> comma-separated list of
> queries, when a query can contain a comma? And I don't
> understand why you're
> having difficult measuring the execution time: what technique
> are you using?
>
> You might find it useful to look at the source code of
> net.sf.saxon.Query.
> This has an undocumented option -3, which causes the query to
> be executed
> three times, displaying the timings for each execution.
>
> Michael Kay
> http://www.saxonica.com/ 
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of
> > Dasgupta, Subhojit (Subhojit)** CTR **
> > Sent: 16 November 2005 14:50
> > To: '[hidden email]'
> > Subject: [saxon] RE: Query regarding execution of multiple
> > xqueries with saxon API
> >
> > Hi
> >
> > In context of the above query that i posted, i would also
> > like to mention
> > that currently i am executing all the xqueries as a comma
> > separated List in
> > the dynamic context.In such a case will it be possible to print the
> > execution time for each xquery executed in tandem ?.Doesnt
> > work currently
> > though!!.
> >
> > Best Regards
> > Subhojit
> >
> > >  -----Original Message-----
> > > From: Dasgupta, Subhojit (Subhojit)** CTR **  
> > > Sent: Wednesday, November 16, 2005 7:53 PM
> > > To: '[hidden email]'
> > > Subject: Query regarding execution of multiple xqueries
> > with saxon
> > > API
> > >
> > > Hi
> > >
> > > I am using Saxon B 8.5.1 version and i need to execute
> > multiple xqueries
> > > in my application. I have written a java API that compiles
> > the xqueries
> > > that i have and the library module  in a static context and
> > then execute
> > > those xqueries in a dynamic context.Also it loads the xml
> > file in the
> > > dynamic context. For this i used the standard  functions
> > provided by saxon
> > > (like compileQuery(), evaluateSingle() etc). The issue that
> > i am facing is
> > > that the above works fine when i am using a single
> xquery.But in my
> > > application  i need to execute multiple xqueries from the
> > same  .xq file
> > > in the same context and collect some performance statistics
> > for all those
> > > xqueries (viz execution time for each xquery etc). Also i
> > cannot afford to
> > > load the XML file more than once as it as huge!!.
> > >
> > > With the setup i have as mentioned here, i am unable to execute
> > > multiple xqueries. Does Saxon provide an alternate way of
> > achieving the
> > > same and collect performance data for each and every xquery that i
> > > execute?
> > >
> > > I am looking forward to some help in this regard as to
> how multiple
> > > xqueries can be created in saxon without creating  a
> > context for every new
> > > query from the xquery file.
> > >
> > > Best Regards
> > > Subhojit
> > >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the JBoss Inc.  Get
> Certified Today
> > Register for a JBoss Training Course.  Free Certification Exam
> > for All Training Attendees Through End of 2005. For more info visit:
> > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> > _______________________________________________
> > saxon-help mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
> Register for a JBoss Training Course.  Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Query regarding execution of multiple xqueries with saxon API

Michael Kay
In reply to this post by Dasgupta, Subhojit (Subhojit)** CTR **
Could I ask you again - please copy your messages to the list so there is an
archive.

I would suggest you put each of your "queries" into a separate function, and
compile them all as part of a single module. Then have a query parameter
(external global variable) that defines which query you want to execute, and
the main body of your query should test this variable and call one of the
functions as appropriate.


declare variable $q external;
declare function my:q1() {
...
}
declare function my:q2() {
...
}
if ($q="q1") then my:q1()
else if ($q="q2") then my:q2()
...
else error()



Separate compilation of library modules is something I would like to
implement at some stage in the future.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Dasgupta, Subhojit (Subhojit)** CTR **
> [mailto:[hidden email]]
> Sent: 17 November 2005 14:26
> To: '[hidden email]'
> Subject: RE: [saxon] Query regarding execution of multiple
> xqueries with saxon API
>
> Hi Michael
>
> Thanks a lot  for the valuable inputs.I do agree with you on
> this point that
> i have been executing multiple queries as separate
> expressions within a
> single query expressed as a list. Ideally i would like to
> execute individual
> queries one after another against the same xml data file
> which is also huge.
> The issue here is that the xqueries that i have written make
> use of a common
> library module(functions defined in the same module) which i
> imported within
> the xquery file.The reason for this is that i wanted to
> import the module
> once for all the queries in the static context and not load
> it repeatedly
> for all the queries.I apologise if i am getting unclear here.
>
> I can think of a way whereby for each of the xqueries i would
> call compile
> query and then execute them in the dynamic context.But that
> would also need
> the external library to be loaded every time. Please correct
> me if i am
> wrong.I wanted to avoid this totally. I cant think of a way
> whereby i can
> import the library module completely independent of the xquery file!.
>
> So it would be great if you can suggest me some way of importing this
> library module only once for all the queries.Also i would
> like to mention
> that the xml document is being loaded only once using buildDocument().
>
> I appreciate your effort and valuable time spent.
>
> Best Regards
> Subhojit
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of
> Michael Kay
> Sent: Wednesday, November 16, 2005 9:37 PM
> To: [hidden email]
> Subject: RE: [saxon] Query regarding execution of multiple
> xqueries with
> saxon API
>
>
> I'm not sure where your difficulty lies. Perhaps it would be
> easier if you
> showed your code.
>
> Firstly, I don't understand why you want to create multiple
> queries from the
> same .xq file. Why not create one query and execute it multiple times?
>
> Secondly, if you do need to create multiple queries, there is
> no difficulty
> doing so. You just call compileQuery() more than once. You
> can either use
> the same StaticContext or a different StaticContext for each query.
>
> There's also no problem in parsing the source document once
> and then using
> it repeatedly. Call the buildDocument() method in
> StaticQueryContext once to
> build the DocumentInfo, then supply this DocumentInfo as the
> context item in
> the dynamic context for each query evaluation.
>
> I hope this helps.
>
> Michael Kay
> http://www.saxonica.com/ 
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of
> > Dasgupta, Subhojit (Subhojit)** CTR **
> > Sent: 16 November 2005 14:23
> > To: '[hidden email]'
> > Subject: [saxon] Query regarding execution of multiple
> > xqueries with saxon API
> >
> > Hi
> >
> > I am using Saxon B 8.5.1 version and i need to execute
> > multiple xqueries in
> > my application. I have written a java API that compiles the
> > xqueries that i
> > have and the library module  in a static context and then
> > execute those
> > xqueries in a dynamic context.Also it loads the xml file in
> > the dynamic
> > context. For this i used the standard  functions provided by
> > saxon (like
> > compileQuery(), evaluateSingle() etc). The issue that i am
> > facing is that
> > the above works fine when i am using a single xquery.But in
> > my application
> > i need to execute multiple xqueries from the same  .xq file
> > in the same
> > context and collect some performance statistics for all those
> > xqueries (viz
> > execution time for each xquery etc). Also i cannot afford to
> > load the XML
> > file more than once as it as huge!!.
> >
> > With the setup i have as mentioned here, i am unable to execute
> > multiple xqueries. Does Saxon provide an alternate way of
> > achieving the same
> > and collect performance data for each and every xquery that
> i execute?
> >
> > I am looking forward to some help in this regard as to how
> > multiple xqueries
> > can be created in saxon without creating  a context for every
> > new query from
> > the xquery file.
> >
> > Best Regards
> > Subhojit
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the JBoss Inc.  Get
> Certified Today
> > Register for a JBoss Training Course.  Free Certification Exam
> > for All Training Attendees Through End of 2005. For more info visit:
> > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> > _______________________________________________
> > saxon-help mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
> Register for a JBoss Training Course.  Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help