If you must use XQJ, then
 
(1) create an XQConnection
 
(2) do connection.createItemFromDocument() to build the document (using any variant of this method)
 
(3) create an XQPreparedExpression representing the compiled query
 
(4) on the XQPreparedExpression, use bindItem(XQConstants.CONTEXT_ITEM, item) to set the context item to the document built in step (2)
 
(5) run the query
 
(6) repeat steps 3/4/5 ad nauseam.
 
The main thing to beware of is that the XQPreparedExpression holds both the compiled query and its dynamic context, which means it cannot be used in multiple threads. With XQJ, if you want to use the same query in multiple threads you need to compile it once for each one.
 

Regards,

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



From: Geet Gangwar [mailto:geetgangwar@gmail.com]
Sent: 23 March 2010 11:41
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Firing multiple Xquery on a single file

Thanks Michael,

Can you tell me how to achieve the same thing using saxonXQJ api.

Regards

Geet

On Tue, Mar 23, 2010 at 4:37 PM, Michael Kay <mike@saxonica.com> wrote:
Of course. Which API are you using?
 
In s9api:
 
(1) create a Processor
 
(2) create a DocumentBuilder and use it to build the source document (as an XdmNode)
 
(3) create an XQueryCompiler, compile the query, load it, supply the document created in step (2) using XQueryEvaluator.setContextItem(), and run the query
 
(4) repeat step (3) ad nauseam. (Or run the same query multiple times with different parameters).
 

Regards,

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



From: Geet Gangwar [mailto:geetgangwar@gmail.com]
Sent: 23 March 2010 10:29
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Firing multiple Xquery on a single file

Hi,

Is there a way where I can load the XML file once and can fire multiple XQuery thereafter. I am not able to figure out how that can be done. Please help me.

Regards

Geet.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/saxon-help