From georg.piewald at siemens.com Tue Sep 2 09:57:12 2008 From: georg.piewald at siemens.com (Piewald, Georg) Date: Mon Sep 1 23:57:53 2008 Subject: [xquery-talk] Changing the content of an XML document Message-ID: Another beginner's question: In my application, the client requests an XML document from the server. Since the document is rather big (and there are actually a few different ones), I'd like to keep it as a separate file on the server (not part of the Xquery file). This means, in the script I load the XML file into a local variable using the doc() function and return the result to the client. But now, occationally some of the content of the file has to be altered. Is there any possiblility to do this except placing the entire file inside the script? Thanks for answers, Georg PS: I'm using eXist Database 1.2.4 From wolfgang at exist-db.org Tue Sep 2 10:39:14 2008 From: wolfgang at exist-db.org (Wolfgang) Date: Tue Sep 2 00:39:49 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: References: Message-ID: <48BCEDA2.9030009@exist-db.org> > This means, in the script I load the XML file into a > local variable using the doc() function and return the result to the > client. > > But now, occationally some of the content of the file has to be altered. I'm not sure I completely understand the question. Is the document stored in the db or do you load it from the filesystem? And do you only need to temporarily change some content of that file (in which case I would probably call an XSLT) or permanently (use XQuery update extensions)? Wolfgang From georg.piewald at siemens.com Tue Sep 2 10:59:18 2008 From: georg.piewald at siemens.com (Piewald, Georg) Date: Tue Sep 2 00:59:54 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <48BCEDA2.9030009@exist-db.org> References: <48BCEDA2.9030009@exist-db.org> Message-ID: > Wolfgang [mailto:wolfgang@exist-db.org] wrote: > > > This means, in the script I load the XML file into a > > local variable using the doc() function and return the result to the > > client. > > > > But now, occationally some of the content of the file has > to be altered. > > I'm not sure I completely understand the question. Is the document > stored in the db or do you load it from the filesystem? And > do you only > need to temporarily change some content of that file (in which case I > would probably call an XSLT) or permanently (use XQuery > update extensions)? Actually I can reduce my question to the following: Assuming I have a variable which stores a node-tree like that let $tree := some text In reality $tree is the entire XML file which I want to send back to the client. Now, depending on some conditions I want to change the content of "some text" to "some other text", before sending it. I don't actually want to alter the file in the database, just the message that I'm sending. If I placed the XML-file inside the script, I would write something like { if ($condition) then "some text" else "some other text" } But since I have a couple of not too small XML files I fear that this will get a bit overcrwoded. Do you understand what I mean? Best, Georg From wolfgang at exist-db.org Tue Sep 2 11:26:51 2008 From: wolfgang at exist-db.org (Wolfgang) Date: Tue Sep 2 01:27:26 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: References: <48BCEDA2.9030009@exist-db.org> Message-ID: <48BCF8CB.2080809@exist-db.org> > Actually I can reduce my question to the following: Assuming I have a > variable which stores a node-tree like that > > let $tree := > > > some text > > > > In reality $tree is the entire XML file which I want to send back to the > client. Now, depending on some conditions I want to change the content > of "some text" to "some other text", before sending it. I > don't actually want to alter the file in the database, just the message > that I'm sending. Ok, I see. If you just need to filter out or change a few nodes, I would probably write a simple transformation function, e.g.: declare function f:filter-entry($node as node(), $newText as xs:string) { typeswitch ($node) case $subnode as element(subnode) return {$newText} case $elem as element() return element { node-name($elem) } { $elem/@*, for $child in $elem/node() return f:filter-entry($child, $newText) } default return $node }; Wolfgang From cschlaefcke at wms-network.de Tue Sep 2 12:03:26 2008 From: cschlaefcke at wms-network.de (Christian Schlaefcke) Date: Tue Sep 2 02:03:30 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: References: <48BCEDA2.9030009@exist-db.org> Message-ID: <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> Hi Georg, take a look at this thread: http://www.stylusstudio.com/xquerytalk/200808/002828.html I had a similar problem exept I wanted to delete certain nodes instead of replacing them. Espacially the "identity transform" (http://en.wikipedia.org/wiki/Identity_transform) hint was very helpful and it sounds as it could help you with your problem too. Best regards, Christian >> Wolfgang [mailto:wolfgang@exist-db.org] wrote: >> >> > This means, in the script I load the XML file into a >> > local variable using the doc() function and return the result to the >> > client. >> > >> > But now, occationally some of the content of the file has >> to be altered. >> >> I'm not sure I completely understand the question. Is the document >> stored in the db or do you load it from the filesystem? And >> do you only >> need to temporarily change some content of that file (in which case I >> would probably call an XSLT) or permanently (use XQuery >> update extensions)? > > Actually I can reduce my question to the following: Assuming I have a > variable which stores a node-tree like that > > let $tree := > > > some text > > > > In reality $tree is the entire XML file which I want to send back to the > client. Now, depending on some conditions I want to change the content > of "some text" to "some other text", before sending it. I > don't actually want to alter the file in the database, just the message > that I'm sending. > > If I placed the XML-file inside the script, I would write something like > > > > { > if ($condition) > then "some text" > else "some other text" > } > > > > But since I have a couple of not too small XML files I fear that this > will get a bit overcrwoded. > Do you understand what I mean? > > Best, > Georg From john.snelson at oracle.com Tue Sep 2 12:02:18 2008 From: john.snelson at oracle.com (John Snelson) Date: Tue Sep 2 03:02:53 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> Message-ID: <48BD0F2A.1020300@oracle.com> Hi Georg, The identity transform will work, and is essentially the same as the transformation function that Wolfgang suggests. However I think a transform expression is easier to understand if eXist supports XQuery Update: copy $a := $tree modify replace value of node $a//subnode with if($condition) then "some text" else "some other text" return $a John Christian Schlaefcke wrote: > Hi Georg, > > take a look at this thread: > http://www.stylusstudio.com/xquerytalk/200808/002828.html > > I had a similar problem exept I wanted to delete certain nodes instead of > replacing them. > > Espacially the "identity transform" > (http://en.wikipedia.org/wiki/Identity_transform) hint was very helpful > and it sounds as it could help you with your problem too. > > Best regards, > > Christian > > >>> Wolfgang [mailto:wolfgang@exist-db.org] wrote: >>> >>>> This means, in the script I load the XML file into a >>>> local variable using the doc() function and return the result to the >>>> client. >>> > >>> > But now, occationally some of the content of the file has >>> to be altered. >>> >>> I'm not sure I completely understand the question. Is the document >>> stored in the db or do you load it from the filesystem? And >>> do you only >>> need to temporarily change some content of that file (in which case I >>> would probably call an XSLT) or permanently (use XQuery >>> update extensions)? >> Actually I can reduce my question to the following: Assuming I have a >> variable which stores a node-tree like that >> >> let $tree := >> >> >> some text >> >> >> >> In reality $tree is the entire XML file which I want to send back to the >> client. Now, depending on some conditions I want to change the content >> of "some text" to "some other text", before sending it. I >> don't actually want to alter the file in the database, just the message >> that I'm sending. >> >> If I placed the XML-file inside the script, I would write something like >> >> >> >> { >> if ($condition) >> then "some text" >> else "some other text" >> } >> >> >> >> But since I have a couple of not too small XML files I fear that this >> will get a bit overcrwoded. >> Do you understand what I mean? >> >> Best, >> Georg > > > > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk -- John Snelson, Oracle Corporation http://snelson.org.uk/john Berkeley DB XML: http://oracle.com/database/berkeley-db/xml XQilla: http://xqilla.sourceforge.net From wolfgang at exist-db.org Tue Sep 2 13:10:54 2008 From: wolfgang at exist-db.org (Wolfgang) Date: Tue Sep 2 03:11:29 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <48BD0F2A.1020300@oracle.com> References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> <48BD0F2A.1020300@oracle.com> Message-ID: <48BD112E.8010905@exist-db.org> > The identity transform will work, and is essentially the same as the > transformation function that Wolfgang suggests. However I think a > transform expression is easier to understand if eXist supports XQuery > Update: > > copy $a := $tree > modify replace value of node $a//subnode with > if($condition) then "some text" else "some other text" > return $a Right now, updates are only supported on documents stored in the db (we directly modify the persistent dom). To use this approach, the document fragment would need to be saved first, which is probably too much overhead for a one-time use. Wolfgang From andrew.j.welch at gmail.com Tue Sep 2 12:22:50 2008 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Tue Sep 2 03:23:21 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <48BD0F2A.1020300@oracle.com> References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> <48BD0F2A.1020300@oracle.com> Message-ID: <74a894af0809020322o6089071em9e198e65924b9480@mail.gmail.com> > The identity transform will work, and is essentially the same as the > transformation function that Wolfgang suggests. However I think a transform > expression is easier to understand The XSLT 2.0 identity transform is perhaps a little more intuitive: XQuery and XSLT should compliment each other - and the task of modifying sections of a single document in a single pass is definitely a job for XSLT. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/ From georg.piewald at siemens.com Tue Sep 2 13:58:24 2008 From: georg.piewald at siemens.com (Piewald, Georg) Date: Tue Sep 2 03:58:58 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <48BD112E.8010905@exist-db.org> References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> <48BD0F2A.1020300@oracle.com> <48BD112E.8010905@exist-db.org> Message-ID: Wolfgang [mailto:wolfgang@exist-db.org] wrote: > >> The identity transform will work, and is essentially the >> same as the >> transformation function that Wolfgang suggests. However I think a >> transform expression is easier to understand if eXist >> supports XQuery >> Update: >> >> copy $a := $tree >> modify replace value of node $a//subnode with >> if($condition) then "some text" else "some other text" >> return $a > > Right now, updates are only supported on documents stored in > the db (we > directly modify the persistent dom). To use this approach, > the document > fragment would need to be saved first, which is probably too much > overhead for a one-time use. > Ok, XQuery Update looks most convenient to me and I don't mind if I actually do alter the files stored in the db. But I still can't get it to work, as I don't really understand the required syntax (as described at http://exist.sourceforge.net/update_ext.html). I tried the following, which is obviously wrong: declare function local:alter() { let $myfile := doc('/db/myfile.xml') return update value $myfile/subnode/text() with 'some other text' }; I'm neither sure how to specify the document I want to alter (the doc() function is surely wrong since it loads the file into memory) nor how to select the textnode using XPath (is /text() required here?). Thanks for all the good answers so far! Georg From john.snelson at oracle.com Tue Sep 2 13:17:15 2008 From: john.snelson at oracle.com (John Snelson) Date: Tue Sep 2 04:17:53 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <74a894af0809020322o6089071em9e198e65924b9480@mail.gmail.com> References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> <48BD0F2A.1020300@oracle.com> <74a894af0809020322o6089071em9e198e65924b9480@mail.gmail.com> Message-ID: <48BD20BB.6050300@oracle.com> Andrew Welch wrote: >> The identity transform will work, and is essentially the same as the >> transformation function that Wolfgang suggests. However I think a transform >> expression is easier to understand > > The XSLT 2.0 identity transform is perhaps a little more intuitive: > > > > XQuery and XSLT should compliment each other - and the task of > modifying sections of a single document in a single pass is definitely > a job for XSLT. I disagree. As in this case I see lot of people saying "I want to change X in this document", and XQuery Update's transform expression gives them a way to write "change X". Doing the same in XSLT requires an understanding of how the identity transform will copy an entire document, and how you can introduce exceptions to what is copied. That's at least one level of abstraction away from the user's requirements. John -- John Snelson, Oracle Corporation http://snelson.org.uk/john Berkeley DB XML: http://oracle.com/database/berkeley-db/xml XQilla: http://xqilla.sourceforge.net From wolfgang at exist-db.org Tue Sep 2 14:18:22 2008 From: wolfgang at exist-db.org (Wolfgang) Date: Tue Sep 2 04:19:01 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> <48BD0F2A.1020300@oracle.com> <48BD112E.8010905@exist-db.org> Message-ID: <48BD20FE.1050102@exist-db.org> > I tried the following, which is obviously wrong: > > declare function local:alter() { > let $myfile := doc('/db/myfile.xml') > return update value $myfile/subnode/text() with > 'some other text' > }; No, that's basically ok. Just make sure that $myfile/subnode/text() returns something. I guess you may need $myfile//subnode/text() instead. Note: eXist's update syntax is still based on some old proposals (the implementation nevertheless works very well). The first XQuery update drafts were published later and I had no time to adopt this stuff yet (it doesn't have the highest priority for me personally). > I'm neither sure how to specify the document I want to alter (the doc() > function is surely wrong since it loads the file into memory) nor how to > select the textnode using XPath (is /text() required here?). doc("/db/myfile.xml") doesn't "load" the document into memory (it is a persistent document whose nodes reside on disk). It just returns a reference to that document. Wolfgang From georg.piewald at siemens.com Tue Sep 2 14:51:18 2008 From: georg.piewald at siemens.com (Piewald, Georg) Date: Tue Sep 2 04:51:43 2008 Subject: [xquery-talk] Changing the content of an XML document In-Reply-To: <48BD20FE.1050102@exist-db.org> References: <48BCEDA2.9030009@exist-db.org> <59616.80.85.196.22.1220346206.squirrel@www.wms-network.de> <48BD0F2A.1020300@oracle.com> <48BD112E.8010905@exist-db.org> <48BD20FE.1050102@exist-db.org> Message-ID: > Wolfgang [mailto:wolfgang@exist-db.org] wrote: > >> I tried the following, which is obviously wrong: >> >> declare function local:alter() { >> let $myfile := doc('/db/myfile.xml') >> return update value $myfile/subnode/text() with >> 'some other text' >> }; > > No, that's basically ok. Just make sure that $myfile/subnode/text() > returns something. I guess you may need > $myfile//subnode/text() instead. > > Note: eXist's update syntax is still based on some old proposals (the > implementation nevertheless works very well). The first XQuery update > drafts were published later and I had no time to adopt this stuff yet > (it doesn't have the highest priority for me personally). > > > I'm neither sure how to specify the document I want to > alter (the doc() > > function is surely wrong since it loads the file into > memory) nor how to > > select the textnode using XPath (is /text() required here?). > > doc("/db/myfile.xml") doesn't "load" the document into memory > (it is a > persistent document whose nodes reside on disk). It just returns a > reference to that document. Great, now it works perfectly fine! Just one thing that I find a bit strange: the entire "update value ..." expression doesn't seem to actually return anything (though the file in the db is altered as expected). So instead I had to introduce a dummy-variable like this: let $myfile := doc('/db/myfile.xml') let $dummy := update value $myfile//subnode/text() with 'some other text' return $myfile Is it supposed to be like that? However, I'm happy with the current solution, thanks a lot for helping! Georg From p.vijayasekar at gmail.com Thu Sep 4 12:42:55 2008 From: p.vijayasekar at gmail.com (Vijayasekar Palaniswamy) Date: Wed Sep 3 23:12:47 2008 Subject: [xquery-talk] XQuery Try Catch Message-ID: Hello, Does XQuery support Try & Catch Block? or any way to create error pages? Thanks. -- Regards, Vijayasekar. P, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080904/a8ee95fb/attachment.htm From james.fuller.2007 at gmail.com Thu Sep 4 09:27:52 2008 From: james.fuller.2007 at gmail.com (James Fuller) Date: Wed Sep 3 23:27:36 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: References: Message-ID: no, but XQuery does have the ability to throw an error using the error() function. also, some XQuery implementations have extension instructions to enable try/catch like behavior. hth, Jim Fuller On Thu, Sep 4, 2008 at 8:12 AM, Vijayasekar Palaniswamy wrote: > Hello, > > Does XQuery support Try & Catch Block? or any way to create error pages? > > Thanks. > > -- > Regards, > > Vijayasekar. P, > > > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk > From matthias.brantner at 28msec.com Thu Sep 4 11:54:48 2008 From: matthias.brantner at 28msec.com (Matthias Brantner) Date: Thu Sep 4 01:54:37 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: References: Message-ID: Hello, as far as I know, there will be a try-catch feature in an evolving XQuery recommendation. The Zorba XQuery Processor already implements the latest try-catch proposal. The grammar and some examples can be found on Zorba's webpage at: http://www.zorba-xquery.com/doc/zorba-0.9.2/zorba/html/trycatch.html Regards, Matthias On 04.09.2008, at 08:12, Vijayasekar Palaniswamy wrote: > Hello, > > Does XQuery support Try & Catch Block? or any way to create error > pages? > > Thanks. > > -- > Regards, > > Vijayasekar. P, > > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk From james.fuller.2007 at gmail.com Thu Sep 4 12:04:54 2008 From: james.fuller.2007 at gmail.com (James Fuller) Date: Thu Sep 4 13:05:17 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: References: Message-ID: On Thu, Sep 4, 2008 at 10:54 AM, Matthias Brantner wrote: > Hello, > > as far as I know, there will be a try-catch feature in an evolving XQuery > recommendation. I think you are speaking about working drafts, not recommendations ;) > The Zorba XQuery Processor already implements the latest try-catch proposal. > > The grammar and some examples can be found on Zorba's webpage at: > > http://www.zorba-xquery.com/doc/zorba-0.9.2/zorba/html/trycatch.html good stuff, will take a look at this processor. cheers, Jim Fuller From michael.reiche at oracle.com Thu Sep 4 14:20:44 2008 From: michael.reiche at oracle.com (Michael Reiche) Date: Thu Sep 4 13:21:48 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: References: Message-ID: <20080904132044312.00000001852@mreiche05> Oracle Data Service Integrator (formerly BEA Aqualogic Data Services Platform) has a try/catch statement in XQSE. http://e-docs.bea.com/aldsp/docs30/xquery/xqse.html#wp1026739 It also has fail-over and time-out functions in Xquery. http://e-docs.bea.com/aldsp/docs30/xquery/extensions.html#wp1301838 Mike From matthias.brantner at 28msec.com Thu Sep 4 13:35:14 2008 From: matthias.brantner at 28msec.com (Matthias Brantner) Date: Thu Sep 4 13:38:57 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: <555522.27836.qm@web23008.mail.ird.yahoo.com> References: <555522.27836.qm@web23008.mail.ird.yahoo.com> Message-ID: >> The grammar and some examples can be found on Zorba's webpage at: > >> http://www.zorba-xquery.com/doc/zorba-0.9.2/zorba/html/trycatch.html > > The grammar looks weird. I guess: > > TryCatchExpr ::= CatchClause+ > > should rather be: > > TryCatchExpr ::= TryClause CatchClause+ Thanks! I've fixed the page. Matthias From ron.hitchens at marklogic.com Thu Sep 4 14:45:30 2008 From: ron.hitchens at marklogic.com (Ron Hitchens) Date: Thu Sep 4 13:44:24 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: References: Message-ID: <62EC9CB4-FF1F-4027-AC57-43CD99DCE0F9@marklogic.com> Mark Logic has had try/catch for years. Customizable error page handlers (which let you tailor an error response without changing the code that throws the exception) are planned for our upcoming release. On Sep 3, 2008, at 11:12 PM, Vijayasekar Palaniswamy wrote: > Hello, > > Does XQuery support Try & Catch Block? or any way to create error > pages? > > Thanks. > > -- > Regards, > > Vijayasekar. P, > > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk --- Ron Hitchens {ron.hitchens@marklogic.com} 650-655-2351 From lists at fgeorges.org Thu Sep 4 13:26:45 2008 From: lists at fgeorges.org (Florent Georges) Date: Thu Sep 4 14:32:18 2008 Subject: [xquery-talk] XQuery Try Catch In-Reply-To: Message-ID: <555522.27836.qm@web23008.mail.ird.yahoo.com> Matthias Brantner wrote: Hi >The grammar and some examples can be found on Zorba's webpage at: >http://www.zorba-xquery.com/doc/zorba-0.9.2/zorba/html/trycatch.html The grammar looks weird. I guess: TryCatchExpr ::= CatchClause+ should rather be: TryCatchExpr ::= TryClause CatchClause+ ;-) Regards, --drkm From mike at saxonica.com Mon Sep 8 13:25:06 2008 From: mike at saxonica.com (Michael Kay) Date: Mon Sep 8 04:25:07 2008 Subject: [xquery-talk] Need some theory help Message-ID: <835A3C3322A74A71BE251BBA87E0CC08@Sealion> I've asked this in the past on other lists without success; in the hope that this list is a better place to find some theoreticians, I'll ask it again here. Given general expressions E,F,G, I believe it is true that the following two expressions are equivalent: E/F union E/G <=> E/(F union G) (That is, union distributes through "/") But this is not true for "except". $a/descendant::*/child::b except $a/descendant::*/(child::c/child::b) is not the same as a/descendant::*/(child::b except child::c/child::b) (easily seen because child::c/child::b will not select any nodes that are selected by child::b). Questions: (a) How would you prove that "union" distributes through "/" and "except" does not? (Assuming my conjecture is correct, of course) (b) What about "intersect": does it distribute or not? (c) Is there a restricted class of path expressions for which "except" does distribute through "/" (for example, path expressions that only use the child axis)? How large can you make that class? Clearly these questions are all directly relevant to the expression rewrites that an optimizer can perform safely. Michael Kay Saxonica From lists at fgeorges.org Mon Sep 8 15:08:53 2008 From: lists at fgeorges.org (Florent Georges) Date: Mon Sep 8 05:09:30 2008 Subject: [xquery-talk] Need some theory help In-Reply-To: <835A3C3322A74A71BE251BBA87E0CC08@Sealion> Message-ID: <236755.36200.qm@web23002.mail.ird.yahoo.com> Michael Kay wrote: Hi Michael, > Given general expressions E,F,G, I believe it is true that > the following two expressions are equivalent: > E/F union E/G <=> E/(F union G) > (That is, union distributes through "/") > But this is not true for "except". > $a/descendant::*/child::b except $a/descendant::*/(child::c/child::b) > is not the same as > a/descendant::*/(child::b except child::c/child::b) > (easily seen because child::c/child::b will not select any > nodes that are selected by child::b). I am not really a theoretician, but I feel this problem is related to the descendant axis rather than the set operations (union, except...) Intuitively, I would say that "E//F x E//G" (for some operator x) is not the same as "E//(F x G)" because in the later "F x G" is 'anchored' at particular nodes, where in the former two sequences are built then the operator is applied. For the union, I guess this leads into the same result (intuitively again), but it doesn't with the difference (the except operator.) Maybe using only a subset of axises to try to prove your assertions could help find the way? Regards, --drkm From davidc at nag.co.uk Mon Sep 8 14:19:31 2008 From: davidc at nag.co.uk (David Carlisle) Date: Mon Sep 8 05:20:08 2008 Subject: [xquery-talk] Need some theory help In-Reply-To: <835A3C3322A74A71BE251BBA87E0CC08@Sealion> (mike@saxonica.com) References: <835A3C3322A74A71BE251BBA87E0CC08@Sealion> Message-ID: <200809081219.m88CJVI1015337@edinburgh.nag.co.uk> > (b) What about "intersect": does it distribute or not? I think not, for the same reason that except does not. $a/descendant::*/child::b intersect $a/descendant::*/(child::c/child::b) is $a/descendant::*/(child::c/child::b) but a/descendant::*/(child::b intersect child::c/child::b) is empty, because > (easily seen because child::c/child::b will not select any nodes that are > selected by child::b). > (a) How would you prove that "union" distributes through "/" and "except" > does not? (Assuming my conjecture is correct, of course) something along the lines of semantics of E/F is Union{f(e) | e in E} where you think of F as a function from a single item e in E to a node set so E/F union E/G is Union{f(e) | e in E} union Union{g(e) | e in E} wheras E/(F union G) is Union{fug(e) | e in E} where fug is the function from a node to a node set defined by fug(e) = f(e) union g(e). then some general mutterings about union distributing over union. (this is using xpath 1 node set terminology, but xpath2 sequence + implied removal of duplicates for path operators is supposed to model set semantics here. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________ From int19h at gmail.com Mon Sep 8 19:11:14 2008 From: int19h at gmail.com (Pavel Minaev) Date: Mon Sep 8 07:11:48 2008 Subject: [xquery-talk] Type system extensions: best syntax for foreign generic types In-Reply-To: References: Message-ID: Hi, I'm working on a conforming XQuery implementation for the .NET platform. Naturally, to be useful, it would require first-class interop with .NET libraries, both stock and third-party. I've seen the way Saxon does it, but I'd rather have the entire .NET type system available for use in XQuery - so that you could not just call a .NET method, but declare an XQuery function that takes a reference to a .NET object, and so on. It seems that XQuery spec gives specific permission to do this sort of thing: "An XQuery implementation may augment the type system of [XQuery/XPath Data Model (XDM)] with additional types that are designed to facilitate exchange of data with host programming languages, or it may provide mechanisms for the user to define such types. For example, a type might be provided that encapsulates an object returned by an external function, such as an SQL database connection. These additional types, if defined, are considered to be derived by restriction from xs:anyAtomicType." So far, so good. Initially, I wanted to map .NET namespaces directly to XML namespaces (using the same "clr-namespace" URI schema that Microsoft uses for XAML for the same purpose), .NET types directly to xs:anyAtomicType-derived final XML Schema types, and methods to functions by prefixing their names with class name and dot. An example of such mapping would be: declare namespace sys = "clr-namespace:System;assembly=mscorlib"; declare function local:foo(s as sys:String) { sys:String.ToLower(s) }; This seems to work fine and look nice, but problems begin when generic types are brought into the picture. XQuery has its own set of what are effectively parametrized types (e.g., element(...)), but it is a closed, non-extensible set. I considered a language extension, something along these lines: (: The corresponding .NET type is System.Func :) declare function local:foo(fun as generic-instance(sys:Func, sys:String, sys:Int32)) { ... }; The problem is that there is nothing in XQuery spec to guarantee that this won't clash with any future language developments. Nor does it seem to be possible to namespace-qualify "generic-instance" here in an extensible way (who's to say that a future XQuery version won't allow something like xs:integer(1, 100) as a type?). And I would really like to stay within the boundaries permitted, either explicitly or implicitly, by the standard. It seems that a more "proper" way to handle this is via "declare option". Perhaps something along the lines of: (: Instantiate and bind to name :) declare option my:generic-instance "local:FuncOfStringToInt32 = sys:Func(sys:String, sys:Int32)"; (: Use the bound name :) declare function local:foo(fun as local:FuncOfStringToInt32) { ... }; However, this seems to be a particularly verbose and ugly way of doing it. I'm also considering just dropping the idea of mapping namespaces altogether, and requiring fully qualified names for everything, all mapped to a single namespace such as "clr". Some name mangling could be devised for generics, as well. For example: declare namespace clr = "urn:uuid:..."; declare function local:foo(fun as clr:System.Action-of-System.String-and-System.Int32) as clr:System.Object { ... } Also verbose, but still (IMO) easier to understand than the mapping. Which approach would you recommend? Is one of the methods outlined above preferrable, or perhaps there is some other more intuitive schema? Or, perhaps some extensibility hooks in XQuery spec that I've missed that allow me to do what I want? From mike at saxonica.com Mon Sep 8 17:04:24 2008 From: mike at saxonica.com (Michael Kay) Date: Mon Sep 8 08:04:59 2008 Subject: [xquery-talk] Type system extensions: best syntax for foreigngeneric types In-Reply-To: References: Message-ID: <1482D79CD6904AD693C5C955209E2839@Sealion> > I'm working on a conforming XQuery implementation for the > .NET platform. Naturally, to be useful, it would require > first-class interop with .NET libraries, both stock and > third-party. I've seen the way Saxon does it, but I'd rather > have the entire .NET type system available for use in XQuery > - so that you could not just call a .NET method, but declare > an XQuery function that takes a reference to a .NET object, > and so on. Saxon can in fact do this. But it doesn't yet handle generics. > An example of such > mapping would be: > > declare namespace sys = "clr-namespace:System;assembly=mscorlib"; > declare function local:foo(s as sys:String) { > sys:String.ToLower(s) > }; For method calling, Saxon maps an XML namespace to each .NET class, not to each external package or namespace. And for the name of the type, it uses a single namespace http://saxon.sf.net/clitype. So this would be (without generics) declare namespace dotnet="http://saxon.sf.net/clitype"; declare namespace System.String = "clitype:System.String?asm=mscorlib"; declare function local:foo(s as dotnet:System.String) { System.String:ToLower(s) }; This can potentially lead to a lot of namespaces; but it that's the case, then I think you are over-using the facility for calling extension functions and should reexamine your application design. > > This seems to work fine and look nice, but problems begin > when generic types are brought into the picture. Agreed, there's no easy answer to this. I think my preferred solution is to not bring them into the picture. Mappings to external type systems are never going to be perfect. Alternatively, I would be inclined to use "declare option" to declare a local name for an external type: declare option saxon:type-alias "my:listOfString = System.Collections.List"; declare function local:foo(s as my:listOfString) { ... } or perhaps even to define some kind of mapping language that contains these type mappings in an external file, which can then be imported. XSD 1.1 allows user-defined primitive types, so that could provide the basis of a mechanism. > I considered a language extension, something along these lines: > > (: The corresponding .NET type is System.Func System.Int32> :) declare function local:foo(fun as > generic-instance(sys:Func, sys:String, sys:Int32)) { ... }; There seems to be an attitude among XQuery implementors that extending the syntax is OK. Personally I regard it as very undesirable. It's not possible for Saxon in any case, because I am implementing XSLT as well as XQuery, and private syntax in XSLT is both banned by the spec, and considered unacceptable by the user community. > > The problem is that there is nothing in XQuery spec to > guarantee that this won't clash with any future language > developments. Which is one reason why XSLT bans it... > Michael Kay http://www.saxonica.com/ From int19h at gmail.com Tue Sep 9 23:15:39 2008 From: int19h at gmail.com (Pavel Minaev) Date: Tue Sep 9 11:14:02 2008 Subject: [xquery-talk] Type system extensions: best syntax for foreigngeneric types In-Reply-To: <1482D79CD6904AD693C5C955209E2839@Sealion> References: <1482D79CD6904AD693C5C955209E2839@Sealion> Message-ID: On Mon, Sep 8, 2008 at 7:04 PM, Michael Kay wrote: >> .NET platform. Naturally, to be useful, it would require >> first-class interop with .NET libraries, both stock and >> third-party. I've seen the way Saxon does it, but I'd rather >> have the entire .NET type system available for use in XQuery >> - so that you could not just call a .NET method, but declare >> an XQuery function that takes a reference to a .NET object, >> and so on. > > Saxon can in fact do this. But it doesn't yet handle generics. Actually, it is half-way there. This works on Saxon 9.1 for .NET: declare namespace nul = "clitype:System.Nullable`1[System.Int32]"; let $x := nul:new(123) return nul:HasValue($x) though there is still no way to use generic type name on its own in a declaration or a cast. > For method calling, Saxon maps an XML namespace to each .NET class, not to > each external package or namespace. And for the name of the type, it uses a > single namespace http://saxon.sf.net/clitype. So this would be (without > generics) > > declare namespace dotnet="http://saxon.sf.net/clitype"; > declare namespace System.String = "clitype:System.String?asm=mscorlib"; > declare function local:foo(s as dotnet:System.String) { > System.String:ToLower(s) > }; Ah, I do apologize; I was aware of the function/method mapping from my past experience with Saxon XSLT (it proved to be very handy back then), but I was not aware about the types, probably because they aren't really all that useful on their own. > This can potentially lead to a lot of namespaces; but it that's the case, > then I think you are over-using the facility for calling extension functions > and should reexamine your application design. Well, let me explain why I want the feature in the first place, and why it is an important one for the scenarios considered. I'm not merely trying to write yet another XQuery implementation in .NET; what I want is to come up with an implementation that is an (almost) first-class .NET citizen, with XQuery modules being statically compiled to .NET assemblies with straightforward mapping, XDM types mapped to .NET types where possible, and so on. The intended use case is to refactor complex XML processing into XQuery modules, which are compiled to .NET classes that are immediately usable from C#/VB/... - so you could write this: module namespace foo = "clr-namespace:Acme.Foo"; import schema namespace mytypes = "mytypes.xsd"; declare function foo:Bar($customer as schema-element(mytypes:customer)) as xs:int { ... }; and then use it like this: using Acme.Foo; XmlDocument doc = new XmlDocument(); doc.Load("customer.xml"); doc.Schemas.Add(null, "mytypes.xsd"); doc.Validate(); Module foo = new Module(); int bar = foo.Bar(doc.DocumentElement); With this approach, it's much more common for foreign code to call into XQuery code than vice versa. However, it would be a typical scenario to have XQuery functions that would take raw or typed XML nodes, parse or otherwise process them, and build object graphs from the data, e.g.: declare namespace acme = "clr-namespace:Acme"; declare function parse-customer($cust as element(Customer)) as acme:Customer? { ... }; and this requires an expressive way to use arbitrary .NET types in function signatures. > There seems to be an attitude among XQuery implementors that extending the > syntax is OK. Personally I regard it as very undesirable. That was the main reasoning behind my post. No matter what, I consider compliance to the spec first priority; therefore, while I would like an easy way out, I'm not going to take one that is not permissible within the boundaries of the spec. I was just wondering whether I indeed correctly understood their restrictiveness. By the way, it seems rather strange to me that there are explicit extensibility points for some elements of the language - "declare option" for global stuff, and expression-scope pragmas - but no similar mechanisms to decorate type references, or function declarations. Is it a deliberate design decision, or just something that was not considered because of the (then) seeming lack of need of such a thing? From rob at koberg.com Tue Sep 9 21:58:42 2008 From: rob at koberg.com (Robert Koberg) Date: Tue Sep 9 17:57:00 2008 Subject: [xquery-talk] cross implementation XQuery Message-ID: <8A8763F1-F500-4007-9D2E-AA0C4F6F48F6@koberg.com> Hi, How do you write XQuery in a cross processor/implementation way? It seems (to me) that you need extension functions. For example, you want to write a XQuery based webapp that might be be used by 2 or more processors/XMLDBs. Do you keep webapp logic out of your XQuery? Is there a cross processor equivalent to XSL's function-available()? Do you create generic functions mapping to various impl specific functions, place those in impl specific import modules, and use a custom URIResolver to resolve imports based on the impl? Do implementations have a standard way to assign these resolvers? Other ways? best, -Rob From rob at koberg.com Tue Sep 9 22:01:36 2008 From: rob at koberg.com (Robert Koberg) Date: Tue Sep 9 17:59:50 2008 Subject: [xquery-talk] FLOR or FLWOR Message-ID: <889FFFD6-3BBB-435A-A9B3-679797354799@koberg.com> Hi, Where would you use 'where' that couldn't be handled by XPath? In other words, why is there a where? best, -Rob From mike at saxonica.com Wed Sep 10 09:53:16 2008 From: mike at saxonica.com (Michael Kay) Date: Wed Sep 10 00:51:39 2008 Subject: [xquery-talk] FLOR or FLWOR In-Reply-To: <889FFFD6-3BBB-435A-A9B3-679797354799@koberg.com> References: <889FFFD6-3BBB-435A-A9B3-679797354799@koberg.com> Message-ID: > > Where would you use 'where' that couldn't be handled by > XPath? In other words, why is there a where? > Because people coming from the world of SQL and other database query languages (e.g. OQL) thought that anything that calls itself a query language ought to have a WHERE clause. Apparently people who have spent years writing SQL not only find it easy to bundle together all the search conditions into one humungous boolean expression, they actually come to believe it is a good idea. Historically, remember that early proposals for XQuery (based on XQL etc) didn't build on XPath, they were developed independently. Michael Kay http://www.saxonica.com/ From mike at saxonica.com Wed Sep 10 09:59:02 2008 From: mike at saxonica.com (Michael Kay) Date: Wed Sep 10 00:57:20 2008 Subject: [xquery-talk] cross implementation XQuery In-Reply-To: <8A8763F1-F500-4007-9D2E-AA0C4F6F48F6@koberg.com> References: <8A8763F1-F500-4007-9D2E-AA0C4F6F48F6@koberg.com> Message-ID: <145E6E5A315A431E893E20BD2DA5CA64@Sealion> Personally, I don't think you should try to write entire applications in XQuery. You should use XQuery for tasks that it is good at, and then integrate the application using some other level of technology, for example a pipeline processor. This way I think there is far less need to do anything platform-dependent in the XQuery logic, and you end up with XQuery code that is much more versatile and reusable. Perhaps the main reason for this view is the absence of any dynamic despatch mechanism in XQuery. This makes it very hard to write XQuery code that is capable of doing more than one job, or of doing the same job in different circumstances. I've seen it done by compile-time manipulation of "import module" in the way you suggest, but it's no fun. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: talk-bounces@x-query.com > [mailto:talk-bounces@x-query.com] On Behalf Of Robert Koberg > Sent: 10 September 2008 01:59 > To: talk@x-query.com > Subject: [xquery-talk] cross implementation XQuery > > Hi, > > How do you write XQuery in a cross processor/implementation > way? It seems (to me) that you need extension functions. For > example, you want to write a XQuery based webapp that might > be be used by 2 or more processors/XMLDBs. > > Do you keep webapp logic out of your XQuery? > > Is there a cross processor equivalent to XSL's function-available()? > > Do you create generic functions mapping to various impl > specific functions, place those in impl specific import > modules, and use a custom URIResolver to resolve imports > based on the impl? Do implementations have a standard way to > assign these resolvers? > > Other ways? > > best, > -Rob > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk From timothymarc at freenet.de Wed Sep 10 12:02:27 2008 From: timothymarc at freenet.de (timothymarc@freenet.de) Date: Wed Sep 10 02:08:31 2008 Subject: [xquery-talk] FLOR or FLWOR Message-ID: Hey Rob, i have had a situation in where the XPath predicate selection does not fit my requirements. I think it was something concerning a query, that combines to sequences, but i'm not sure. It is a long time ago and i can't find the example. But the where is essential in some case. But you're right, most of the selections can be done with XPath. HTH Timothy ----- original Nachricht -------- Betreff: [xquery-talk] FLOR or FLWOR Gesendet: Mi 10 Sep 2008 03:02:44 CEST Von: "Robert Koberg" > Hi, > > Where would you use 'where' that couldn't be handled by XPath? In > other words, why is there a where? > > best, > -Rob > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk > --- original Nachricht Ende ---- From remi at gide.net Wed Sep 10 12:35:05 2008 From: remi at gide.net (=?UTF-8?Q?R=C3=A9mi_Dewitte?=) Date: Wed Sep 10 02:33:20 2008 Subject: [xquery-talk] FLOR or FLWOR In-Reply-To: References: Message-ID: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> Hi, I do have an example. Correct ? for $v in distinct-values($values) where count($values[. = $v]) > 2 return $v R?mi On Wed, Sep 10, 2008 at 11:02 AM, wrote: > Hey Rob, > > i have had a situation in where the XPath predicate selection does not fit > my requirements. I think it was something concerning a query, that combines > to sequences, but i'm not sure. It is a long time ago and i can't find the > example. > > But the where is essential in some case. But you're right, most of the > selections can be done with XPath. > > HTH > Timothy > ----- original Nachricht -------- > > Betreff: [xquery-talk] FLOR or FLWOR > Gesendet: Mi 10 Sep 2008 03:02:44 CEST > Von: "Robert Koberg" > > > Hi, > > > > Where would you use 'where' that couldn't be handled by XPath? In > > other words, why is there a where? > > > > best, > > -Rob > > _______________________________________________ > > talk@x-query.com > > http://x-query.com/mailman/listinfo/talk > > > > --- original Nachricht Ende ---- > > > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080910/76ced389/attachment.htm From mike at saxonica.com Wed Sep 10 12:01:15 2008 From: mike at saxonica.com (Michael Kay) Date: Wed Sep 10 02:59:36 2008 Subject: [xquery-talk] FLOR or FLWOR In-Reply-To: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> References: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> Message-ID: There are some cases where using a predicate may be inconvenient, but it is always possible. This query is equivalent to distinct-values($values)[let $v := . return count($values[. = $v] > 2] or if you prefer (or if you are restricted to XPath 2.0 syntax) distinct-values($values)[exists(index-of($values, .))[3]] Michael Kay http://www.saxonica.com/ _____ From: talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] On Behalf Of R?mi Dewitte Sent: 10 September 2008 10:35 To: timothymarc@freenet.de Cc: Robert Koberg; talk@x-query.com Subject: Re: [xquery-talk] FLOR or FLWOR Hi, I do have an example. Correct ? for $v in distinct-values($values) where count($values[. = $v]) > 2 return $v R?mi On Wed, Sep 10, 2008 at 11:02 AM, wrote: Hey Rob, i have had a situation in where the XPath predicate selection does not fit my requirements. I think it was something concerning a query, that combines to sequences, but i'm not sure. It is a long time ago and i can't find the example. But the where is essential in some case. But you're right, most of the selections can be done with XPath. HTH Timothy ----- original Nachricht -------- Betreff: [xquery-talk] FLOR or FLWOR Gesendet: Mi 10 Sep 2008 03:02:44 CEST Von: "Robert Koberg" > Hi, > > Where would you use 'where' that couldn't be handled by XPath? In > other words, why is there a where? > > best, > -Rob > _______________________________________________ > talk@x-query.com > http://x-query.com/mailman/listinfo/talk > --- original Nachricht Ende ---- _______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080910/dae7313d/attachment.htm From davidc at nag.co.uk Wed Sep 10 12:11:20 2008 From: davidc at nag.co.uk (David Carlisle) Date: Wed Sep 10 03:09:39 2008 Subject: [xquery-talk] FLOR or FLWOR In-Reply-To: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> (remi@gide.net) References: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> Message-ID: <200809101011.m8AABKHA007267@edinburgh.nag.co.uk> > I do have an example. Correct ? > for $v in distinct-values($values) where count($values[. = $v]) > 2 > return $v But that is a typical example where the where clause is not needed. it is distinct-values($values)[let $v := . return count($values[. = $v]) > 2] or simpler distinct-values($values)[let $v := . return $values[. = $v][2]] It is possible to come up with cases where where is theoretically more expressive as it has access to the full tuple stream, but they temd to be rather artificial. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________ From mike at saxonica.com Wed Sep 10 13:40:07 2008 From: mike at saxonica.com (Michael Kay) Date: Wed Sep 10 04:38:26 2008 Subject: [xquery-talk] FLOR or FLWOR In-Reply-To: <200809101011.m8AABKHA007267@edinburgh.nag.co.uk> References: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> <200809101011.m8AABKHA007267@edinburgh.nag.co.uk> Message-ID: <12DAFF3D859849B1B203974DC850E066@Sealion> > > or simpler > > distinct-values($values)[let $v := . return $values[. = $v][2]] > I think you need an exists() call there - a value might be 0 or "" or false(). Michael Kay http://www.saxonica.com/ From davidc at nag.co.uk Wed Sep 10 13:48:27 2008 From: davidc at nag.co.uk (David Carlisle) Date: Wed Sep 10 04:41:54 2008 Subject: [xquery-talk] FLOR or FLWOR In-Reply-To: <12DAFF3D859849B1B203974DC850E066@Sealion> (mike@saxonica.com) References: <2184b2340809100235x3a888637gcce672cce9a6dd4c@mail.gmail.com> <200809101011.m8AABKHA007267@edinburgh.nag.co.uk> <12DAFF3D859849B1B203974DC850E066@Sealion> Message-ID: <200809101148.m8ABmRKg008948@edinburgh.nag.co.uk> > I think you need an exists() call there - a value might be 0 or "" or > false(). blurg. Who's idea was it to allow atomic values in node sets////// sequences:-) You are quite right of course, also it should be [3] not [2] to match the original expression. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________ From hrennau at yahoo.de Mon Sep 15 04:49:00 2008 From: hrennau at yahoo.de (Hans-Juergen Rennau) Date: Sun Sep 14 20:49:41 2008 Subject: [xquery-talk] FLOR or FLWOR Message-ID: <896798.43388.qm@web27104.mail.ukl.yahoo.com> >> >> or simpler >> >> distinct-values($values)[let $v := . return $values[. = $v][2]] >> >I think you need an exists() call there - a value might be 0 or "" or >false(). > >Michael Kay >http://www.saxonica.com/ Not to mention the danger of $values containing atomic values of a type for which the Effective Boolean Value is not defined, that is, any non-numeric type other than xs:string or xs:boolean! With kind regards, Hans-Juergen Rennau __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verf?gt ?ber einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com From hrennau at yahoo.de Mon Sep 15 05:54:42 2008 From: hrennau at yahoo.de (Hans-Juergen Rennau) Date: Sun Sep 14 21:55:21 2008 Subject: [xquery-talk] RE: FLOR or FLWOR Message-ID: <368715.86375.qm@web27105.mail.ukl.yahoo.com> Hello, Rob, it seems to me important to remember two facts about FLWOR expressions: a) they may not only create loops but procure intermediate results (via let clause) b) to remove a tuple from the tuple stream, a predicate has to be placed in a for clause If the filter condition refers to such an intermediate result, it is very convenient that we have the where, because otherwise we would have to create the intermediary twice: once to procure the predicate (as part of a for loop), and once to be used later on (as a let clause). As an illustration consider this query: (:---------------------------------------------------------------------------------------:) string-join( for $owner in distinct-values(//ContainerDataList/@EIGT) let $nrs := distinct-values(//ContainerDataList[@EIGT eq $owner]/@CONR) where count($nrs) le 2 order by $owner return ( concat($owner, " (", count($nrs), ")"), for $n in $nrs return concat(" ", $n) ) , " ") (:---------------------------------------------------------------------------------------:) The intermediate ($nrs) is definitely needed later on, and the filter condition refers to it. To replace the where by a predicate, one would end up with something like this: (:---------------------------------------------------------------------------------------:) string-join( let $in := . for $owner in distinct-values(//ContainerDataList/@EIGT) [let $o := . return count(distinct-values($in//ContainerDataList[@EIGT eq $o]/@CONR)) le 2] let $nrs := distinct-values(//ContainerDataList[@EIGT eq $owner]/@CONR) order by $owner return ( concat($owner, " (", count($nrs), ")"), for $n in $nrs return concat(" ", $n) ) , " ") (:---------------------------------------------------------------------------------------:) which is horrible, isn't it? The alternative would be to introduce an artificial for clause: (:---------------------------------------------------------------------------------------:) string-join( for $owner in distinct-values(//ContainerDataList/@EIGT) let $nrs := distinct-values(//ContainerDataList[@EIGT eq $owner]/@CONR) for $dummy in 1[count($nrs) le 1] return ( concat($owner, " (", count($nrs), ")"), for $n in $nrs return concat(" ", $n) ) , " ") (:---------------------------------------------------------------------------------------:) If anyone considers this an acceptable alternative to a where clause, I give up. With kind regards - Hans-Juergen Rennau > Message: 2 >Date: Tue, 9 Sep 2008 21:01:36 -0400 > From: Robert Koberg > Subject: [xquery-talk] FLOR or FLWOR > To: talk@x-query.com > Message-ID: <889FFFD6-3BBB-435A-A9B3-679797354799@koberg.com> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > Hi, > > Where would you use 'where' that couldn't be handled by XPath? In > other words, why is there a where? > > best, > -Rob *********************************** __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verf?gt ?ber einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com From kennorth at sbcglobal.net Fri Sep 19 13:21:08 2008 From: kennorth at sbcglobal.net (Ken North) Date: Fri Sep 19 12:21:52 2008 Subject: [xquery-talk] Call for speakers for DataServices World closes 26 September 2008 Message-ID: <006601c91a8c$e11eb740$2301a8c0@DURANTE> Following the successful launch of DataServices World in New York City, we're running the Fall event on November 20, 2008. It is co-located with SOAWorld 2008, Virtualization Conference and Cloud Computing Conference and Expo. -------------------------------------------------------------- Call for Speakers Closes September 26, 2008 DataServices World Fall 2008 San Jose, California (November 20, 2008) The complexities of distributed processing and the importance of middleware can elude even senior technical people, including enterprise architects, IT managers, consultants and designers. Enterprise developers embraced the separation of presentation, data services and application logic. Internet computing, cloud computing, web services and service-oriented architecture (SOA) continue a trend towards moving data access and data integration logic into a separate data services layer. The data services layer, databases and data access are the focus of DataServices World. We're looking for technical presentations about architecture and solutions for data access and data integration from heterogeneous data sources including XML, SQL tables, geo-coded data, content management systems, enterprise resource planning (ERP) systems, data warehouses, and web data. Topics of interest include: ? Information as a service ? Grid and cloud data services ? Data services development: architecture, tools ? Essential capabilities for effective, robust, secure data services ? Data services enabling technology: JDBC, JNDI, Hibernate, JAX-WS, JAX-RS, DWR, LINQ, ADO.NET Entity Framework ? End-to-end performance optimization: (database, metadata, data distribution, caching, query tuning, load balancing, protocols, data services) If you're interested in speaking, you must submit a proposal by September 26, 2008. Send your proposal to videoscribe21st-dsworld@yahoo.com. Please include: - The presentation title and a brief abstract (< 200 words). - Your name, title, a brief biography and complete contact information. - A summary of your speaking experience. Presentations and video from DataServices World in New York City (June 24, 2008): http://www.dataservicesworld.com ======== Ken North =========== www.KNComputing.com www.DataServicesWorld.com www.CloudComputingSummit.com www.LinkedDataSummit.com www.WebServicesSummit.com www.SQLSummit.com www.GridSummit.com From D.McBeath at elsevier.com Tue Sep 23 09:04:04 2008 From: D.McBeath at elsevier.com (McBeath, Darin W (ELS-STL)) Date: Tue Sep 23 06:05:21 2008 Subject: [xquery-talk] Leverage your XQuery skills in the Article 2.0 Contest Message-ID: Elsevier Labs is inviting creative individuals who have wanted the opportunity to view and work with scientific journal article content on the web to enter the Elsevier Article 2.0 Contest. Each contestant will be provided online access to approximately 7,500 full-text XML articles from Elsevier journals, including the associated images, and the Elsevier Article 2.0 API to develop a unique yet useful web-based journal article rendering application. The sample apps (including source code) we have provided on the Article 2.0 Contest web site were developed in XQuery. While the contest does not mandate the use of XQuery, our experience has shown the technology is a natural fit for building these types of applications. If you are interested in the contest, please visit the web site (http://article20.elsevier.com ) and apply for an Article 2.0 API Key. If you have any questions about the contest, drop us an email at info-article20@elsevier.com. Thanks. Elsevier Labs. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080923/75829e7d/attachment.htm From remi at gide.net Wed Sep 24 16:42:21 2008 From: remi at gide.net (=?UTF-8?Q?R=C3=A9mi_Dewitte?=) Date: Wed Sep 24 10:06:37 2008 Subject: [xquery-talk] XQuery memoization Message-ID: <2184b2340809240642s4c99f2fsc59e1c2e5cda606a@mail.gmail.com> Hi all, Is there something to apply memoization on a function to speed up multiple calls with same arguments ? I am using saxon 9. Cheers, R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080924/cffa6319/attachment.htm From mike at saxonica.com Wed Sep 24 22:23:52 2008 From: mike at saxonica.com (Michael Kay) Date: Wed Sep 24 13:24:52 2008 Subject: [xquery-talk] XQuery memoization In-Reply-To: <2184b2340809240642s4c99f2fsc59e1c2e5cda606a@mail.gmail.com> References: <2184b2340809240642s4c99f2fsc59e1c2e5cda606a@mail.gmail.com> Message-ID: Yes. Use "declare option saxon:memo-function", see http://www.saxonica.com/documentation/using-xquery/extensions.html Michael Kay Saxonica _____ From: talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] On Behalf Of R?mi Dewitte Sent: 24 September 2008 14:42 To: talk@x-query.com Subject: [xquery-talk] XQuery memoization Hi all, Is there something to apply memoization on a function to speed up multiple calls with same arguments ? I am using saxon 9. Cheers, R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080924/30f8432b/attachment.htm From remi at gide.net Wed Sep 24 23:38:08 2008 From: remi at gide.net (=?UTF-8?Q?R=C3=A9mi_Dewitte?=) Date: Wed Sep 24 13:39:02 2008 Subject: [xquery-talk] XQuery memoization In-Reply-To: References: <2184b2340809240642s4c99f2fsc59e1c2e5cda606a@mail.gmail.com> Message-ID: <2184b2340809241338r634c35at3d23264b5f907300@mail.gmail.com> That's great ! R?mi On Wed, Sep 24, 2008 at 10:23 PM, Michael Kay wrote: > Yes. Use "declare option saxon:memo-function", see > > http://www.saxonica.com/documentation/using-xquery/extensions.html > > Michael Kay > Saxonica > > ------------------------------ > *From:* talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] *On > Behalf Of *R?mi Dewitte > *Sent:* 24 September 2008 14:42 > *To:* talk@x-query.com > *Subject:* [xquery-talk] XQuery memoization > > Hi all, > Is there something to apply memoization on a function to speed up multiple > calls with same arguments ? > > I am using saxon 9. > > Cheers, > R?mi > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20080924/f82b7915/attachment.htm