|
|
|||
2.9.4 XQuery ModulesMonetDB/XQuery has support for modules. It helps XQuery users to structure their query code, but are also the instrument for MonetDB/XQuery to implement prepared queries (see next section). All XRPC requests benefit from the prepared query mechanism. The below shows a simple example of an XQuery module module namespace test = "http://monetdb.cwi.nl/XQuery/Documentation/Language/Modules/";
declare function test:countDescendants($doc as xs:string) as xs:integer
{
count(doc($doc)//*)
};
You may type import module namespace test = "http://monetdb.cwi.nl/XQuery/Documentation/Language/Modules/"
at "http://monetdb.cwi.nl/XQuery/Documentation/Language/Modules/test.xq";
test:countDescendants("http://monetdb.cwi.nl/xmark/auctions.xml")
which basically does the same as the ad-hoc query, namely counting how many nodes the XMark document has: count(doc("http://monetdb.cwi.nl/xmark/auctions.xml")//*)
Warning: while highly similar, the module feature as implemented by MonetDB/XQuery deviates in the following respects from the XQuery formal semantics:
|
||||
|
|
||||
| © 1994-2010 CWI | Contact us Legal HG web Bugs TestWeb PermaStore | |||