Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] how can we pass previously built documents into FLWOR exprs in Saxon?

From: "Michael Kay" <mike@--------.--->
To: <manavaputra@-----.--->,<xml-dev@-----.---.--->
Date: 2/4/2006 9:12:00 AM
Generic XQuery questions are probably best asked on the xquery-talk list at
xquery.com, and Saxon-specific questions on the saxon-help list or forum at
SourceForge.net. This one falls somewhere in between.

There are three main ways you can pass input documents to a Saxon query:
using the context item; as the value of a named external variable; or using
the doc() function. The obvious way to do it in this case is using an
external variable (or parameter). Declare

declare variable name="doc1" as="document-node()" external;

in the query prolog, and pass the document node as the value of the
parameter at run-time from the Java API, which in Saxon's case means calling
setParameter("doc1", documentNode) on the DynamicQueryContext object. In the
body of the query you can then access the document as $doc1.

Another approach which may work better when you have a variable number of
documents is to write your own URIResolver, so when the doc() function
requests a particular URI, your URIResolver responds by passing the
pre-built document.

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

 
> -----Original Message-----
> From: manavaputra@y... [mailto:manavaputra@y...] 
> Sent: 04 February 2006 01:40
> To: xml-dev@l...
> Subject: [xml-dev] how can we pass previously built documents 
> into FLWOR exprs in Saxon?
> 
> I am at the moment testing the SAXON Xpath/XQuery API.
> Most of the time, we work with only one document, but
> there are cases when we work with more than one
> document. The dynamic query context in saxon allows us
> to set only one context node which could be the root
> node of the document. This works fine for FLWOR exprs
> involving a single document and they dont even have to
> use doc() function in their exprs. But if we have,
> say, two documents that the FLWOR exprs are querying,
> then from the API documentation, it appears as though
> we will have to use doc("uri or filepath") function
> calls in which case saxon loads them automatically. My
> problem is that i have to load both the documents
> anyway in my code using the api call to
> StaticQueryContext.buildDocument(StreamSource) and i
> dont want to load them again in FLWOR exprs, because
> it is just a waste of memory considering that large
> xml files do consume a lot of memory. Is there any way
> to pass previously build document root nodes into the
> FLWOR exprs.
> 
> I realize this is xquery/xpath specific question and
> more so specially for saxon. If there are other lists
> dedicated for this purpose, please do let me know.
> 
> Thanks
> Manava
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent