From oesterg at gmail.com Mon Jul 9 00:41:30 2012 From: oesterg at gmail.com (=?iso-8859-1?Q?Jens_=D8stergaard_Petersen?=) Date: Mon, 9 Jul 2012 09:41:30 +0200 Subject: [xquery-talk] simple map operator Message-ID: <9C7E7EEC-A75B-44C5-9B69-B852CC9874AE@gmail.com> Hi, Can anyone explain to me why the XQuery 3.0 simple map operator is a relative path expression? Which nodes within trees does it locate? Thanks in advance for any enlightenment, Jens From ms at basex.org Mon Jul 9 01:01:21 2012 From: ms at basex.org (Michael Seiferle) Date: Mon, 9 Jul 2012 10:01:21 +0200 Subject: [xquery-talk] simple map operator In-Reply-To: <9C7E7EEC-A75B-44C5-9B69-B852CC9874AE@gmail.com> References: <9C7E7EEC-A75B-44C5-9B69-B852CC9874AE@gmail.com> Message-ID: Hi Jens, they are relative, such that each step (E1 ! E2) will serve as the input sequence E'1 for the next operation (E'1 ! E'2), hence: > > hello > world > and > hello > universe > /bar ! (: here we locate each child of :) > upper-case(.) ! (: we return a sequence of their text() in upper-case :) > substring(.,2,string-length(.)) (: we return a sequence of the upper case text and strip the first character :) the map operator redefines the context items (inner focus) for each subsequent operation. So it does not locate any special nodes within trees, but works on sequences of items you specify by expressions, for example: > (1 to 5) ! (. + 1) ! (. * 2) will work as well and returns (4, 6, 8, 10, 12). Hope this helped to clear things up a little :-). I guess others on this list will correct me if I got something wrong. Kind regards Michael Am 09.07.2012 um 09:41 schrieb Jens ?stergaard Petersen: > Hi, > > Can anyone explain to me why the XQuery 3.0 simple map operator is a relative path expression? Which nodes within trees does it locate? > > Thanks in advance for any enlightenment, > > Jens > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From oesterg at gmail.com Mon Jul 9 01:43:12 2012 From: oesterg at gmail.com (=?iso-8859-1?Q?Jens_=D8stergaard_Petersen?=) Date: Mon, 9 Jul 2012 10:43:12 +0200 Subject: [xquery-talk] simple map operator In-Reply-To: References: <9C7E7EEC-A75B-44C5-9B69-B852CC9874AE@gmail.com> Message-ID: <977462E9-391F-44F3-9630-AC919F7B3EE8@gmail.com> Thanks, Michael, If the simple map operator "does not locate any special nodes within trees, but works on sequences of items you specify by expressions", does that not make it into a sequence expression in the terms of Michael Kay's Reference, Chapter 10 (which also has "/" as a simple mapping expression when it works on atomic values)? Also, the draft defines a path expression as something that "can be used to locate nodes within trees", so I still wonder what the meaning behind this categorisation is. Cheers, Jens On Jul 9, 2012, at 10:01 AM, Michael Seiferle wrote: > Hi Jens, > > they are relative, such that each step (E1 ! E2) will serve as the input sequence E'1 for the next operation (E'1 ! E'2), hence: > >> >> hello >> world >> and >> hello >> universe >> /bar ! (: here we locate each child of :) >> upper-case(.) ! (: we return a sequence of their text() in upper-case :) >> substring(.,2,string-length(.)) (: we return a sequence of the upper case text and strip the first character :) > the map operator redefines the context items (inner focus) for each subsequent operation. > > So it does not locate any special nodes within trees, but works on sequences of items you specify by expressions, for example: >> (1 to 5) ! (. + 1) ! (. * 2) > will work as well and returns (4, 6, 8, 10, 12). > > Hope this helped to clear things up a little :-). > I guess others on this list will correct me if I got something wrong. > > Kind regards > > Michael > > > > Am 09.07.2012 um 09:41 schrieb Jens ?stergaard Petersen: > >> Hi, >> >> Can anyone explain to me why the XQuery 3.0 simple map operator is a relative path expression? Which nodes within trees does it locate? >> >> Thanks in advance for any enlightenment, >> >> Jens >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > From mike at saxonica.com Mon Jul 9 02:26:50 2012 From: mike at saxonica.com (Michael Kay) Date: Mon, 09 Jul 2012 10:26:50 +0100 Subject: [xquery-talk] simple map operator In-Reply-To: <977462E9-391F-44F3-9630-AC919F7B3EE8@gmail.com> References: <9C7E7EEC-A75B-44C5-9B69-B852CC9874AE@gmail.com> <977462E9-391F-44F3-9630-AC919F7B3EE8@gmail.com> Message-ID: <4FFAA3DA.9000806@saxonica.com> A!B is a RelativePathExpr in the BNF grammar, but so are 29, count($x), and (1 to 10)[3]. Similarly, the way the grammar works, "a and b" is an instance of OrExpr, and 2+2 is an instance of ValueComp. So you need to distinguish the names of productions in the grammar, which affect the precedence of expressions, from the semantics of the operators appearing in those expressions. Generally productions are named after the lowest-precedence operator that is allowed to appear in the expression. In fact, since XPath 3.0 was last published, we have decided to change the precedence of the new "!" operator to be lower than the precedence of "/", so this will change. As for my book, see the discussion of the terminological problems around the phrase "path expression" on the first page of chapter 9; also see page 523. In common parlance, a "path expression" is an expression that uses the "/" operator, just as an "or expression" is one that uses the "or" operator; but that doesn't correspond to the BNF symbols PathExpr and OrExpr. The term "sequence expression" is used as a chapter heading in my book, as a convenient title for the set of constructs I chose to describe in that chapter, but it is not a term that appears in the XPath language specification itself. Michael Kay Saxonica On 09/07/2012 09:43, Jens ?stergaard Petersen wrote: > Thanks, Michael, > > If the simple map operator "does not locate any special nodes within trees, but works on sequences of items you specify by expressions", does that not make it into a sequence expression in the terms of Michael Kay's Reference, Chapter 10 (which also has "/" as a simple mapping expression when it works on atomic values)? Also, the draft defines a path expression as something that "can be used to locate nodes within trees", so I still wonder what the meaning behind this categorisation is. > > Cheers, > > Jens > > On Jul 9, 2012, at 10:01 AM, Michael Seiferle wrote: > >> Hi Jens, >> >> they are relative, such that each step (E1 ! E2) will serve as the input sequence E'1 for the next operation (E'1 ! E'2), hence: >> >>> >>> hello >>> world >>> and >>> hello >>> universe >>> /bar ! (: here we locate each child of :) >>> upper-case(.) ! (: we return a sequence of their text() in upper-case :) >>> substring(.,2,string-length(.)) (: we return a sequence of the upper case text and strip the first character :) >> the map operator redefines the context items (inner focus) for each subsequent operation. >> >> So it does not locate any special nodes within trees, but works on sequences of items you specify by expressions, for example: >>> (1 to 5) ! (. + 1) ! (. * 2) >> will work as well and returns (4, 6, 8, 10, 12). >> >> Hope this helped to clear things up a little :-). >> I guess others on this list will correct me if I got something wrong. >> >> Kind regards >> >> Michael >> >> >> >> Am 09.07.2012 um 09:41 schrieb Jens ?stergaard Petersen: >> >>> Hi, >>> >>> Can anyone explain to me why the XQuery 3.0 simple map operator is a relative path expression? Which nodes within trees does it locate? >>> >>> Thanks in advance for any enlightenment, >>> >>> Jens >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > From oesterg at gmail.com Mon Jul 9 03:30:44 2012 From: oesterg at gmail.com (=?iso-8859-1?Q?Jens_=D8stergaard_Petersen?=) Date: Mon, 9 Jul 2012 12:30:44 +0200 Subject: [xquery-talk] simple map operator In-Reply-To: <4FFAA3DA.9000806@saxonica.com> References: <9C7E7EEC-A75B-44C5-9B69-B852CC9874AE@gmail.com> <977462E9-391F-44F3-9630-AC919F7B3EE8@gmail.com> <4FFAA3DA.9000806@saxonica.com> Message-ID: <8408B763-84EF-42EA-B84F-ACF3C41A45FA@gmail.com> Thank you, Michael, I see that this is a syntactic categorisation and that the semantics of the definition does not carry as much weight as the order of precedence. When the order of precedence changes in the next draft, will "/" and "//" become map operators? Waiting to have syntax and semantics linked up again, in the next edition of your book, Jens On Jul 9, 2012, at 11:26 AM, Michael Kay wrote: > > A!B is a RelativePathExpr in the BNF grammar, but so are 29, count($x), and (1 to 10)[3]. > > Similarly, the way the grammar works, "a and b" is an instance of OrExpr, and 2+2 is an instance of ValueComp. > > So you need to distinguish the names of productions in the grammar, which affect the precedence of expressions, from the semantics of the operators appearing in those expressions. Generally productions are named after the lowest-precedence operator that is allowed to appear in the expression. > > In fact, since XPath 3.0 was last published, we have decided to change the precedence of the new "!" operator to be lower than the precedence of "/", so this will change. > > As for my book, see the discussion of the terminological problems around the phrase "path expression" on the first page of chapter 9; also see page 523. In common parlance, a "path expression" is an expression that uses the "/" operator, just as an "or expression" is one that uses the "or" operator; but that doesn't correspond to the BNF symbols PathExpr and OrExpr. > > The term "sequence expression" is used as a chapter heading in my book, as a convenient title for the set of constructs I chose to describe in that chapter, but it is not a term that appears in the XPath language specification itself. > > Michael Kay > Saxonica > > > On 09/07/2012 09:43, Jens ?stergaard Petersen wrote: >> Thanks, Michael, >> >> If the simple map operator "does not locate any special nodes within trees, but works on sequences of items you specify by expressions", does that not make it into a sequence expression in the terms of Michael Kay's Reference, Chapter 10 (which also has "/" as a simple mapping expression when it works on atomic values)? Also, the draft defines a path expression as something that "can be used to locate nodes within trees", so I still wonder what the meaning behind this categorisation is. >> >> Cheers, >> >> Jens >> >> On Jul 9, 2012, at 10:01 AM, Michael Seiferle wrote: >> >>> Hi Jens, >>> >>> they are relative, such that each step (E1 ! E2) will serve as the input sequence E'1 for the next operation (E'1 ! E'2), hence: >>> >>>> >>>> hello >>>> world >>>> and >>>> hello >>>> universe >>>> /bar ! (: here we locate each child of :) >>>> upper-case(.) ! (: we return a sequence of their text() in upper-case :) >>>> substring(.,2,string-length(.)) (: we return a sequence of the upper case text and strip the first character :) >>> the map operator redefines the context items (inner focus) for each subsequent operation. >>> >>> So it does not locate any special nodes within trees, but works on sequences of items you specify by expressions, for example: >>>> (1 to 5) ! (. + 1) ! (. * 2) >>> will work as well and returns (4, 6, 8, 10, 12). >>> >>> Hope this helped to clear things up a little :-). >>> I guess others on this list will correct me if I got something wrong. >>> >>> Kind regards >>> >>> Michael >>> >>> >>> >>> Am 09.07.2012 um 09:41 schrieb Jens ?stergaard Petersen: >>> >>>> Hi, >>>> >>>> Can anyone explain to me why the XQuery 3.0 simple map operator is a relative path expression? Which nodes within trees does it locate? >>>> >>>> Thanks in advance for any enlightenment, >>>> >>>> Jens >>>> _______________________________________________ >>>> talk at x-query.com >>>> http://x-query.com/mailman/listinfo/talk >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From Martin.Honnen at gmx.de Mon Jul 9 07:32:17 2012 From: Martin.Honnen at gmx.de (Martin Honnen) Date: Mon, 09 Jul 2012 16:32:17 +0200 Subject: [xquery-talk] fn:doc not returning data In-Reply-To: References: Message-ID: <4FFAEB71.6060108@gmx.de> Daniel Oneil wrote: > I'm trying to use XQIB to get data from an XML file using the fn:doc > function. > The following link leads to a Source Forge forum where I posted my code > and a link to the books.xml file. > https://sourceforge.net/projects/mxquery/forums/forum/633155/topic/5412690 > The post at the Source Forge forum describes the problem and various > attempts. Any assistance would be appreciated -- thanks. What is the location of the HTML file with the XQuery script in relation to that local XML file? Is the HTML file also loaded from the local file system? Does the Firefox or Chrome error console show any security errors like "access to ... denied"? -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/ From ghislain.fourny at 28msec.com Mon Jul 9 09:10:28 2012 From: ghislain.fourny at 28msec.com (Ghislain Fourny) Date: Mon, 9 Jul 2012 18:10:28 +0200 Subject: [xquery-talk] fn:doc not returning data In-Reply-To: References: Message-ID: <37AE9BC4-7E20-4393-8F2E-6ABB309AD26D@28msec.com> Hi Daniel, XQIB does not support the doc function - the XQIB way of accessing an XML document is to send a GET request over the Web with the EXPath http-client module (possibly to the same server). An example is given here: http://www.xqib.org/js/RESTCallCourses_source.html I hope this is helpful? Kind regards, Ghislain On Jul 9, 2012, at 4:15 PM, Daniel Oneil wrote: > I'm trying to use XQIB to get data from an XML file using the fn:doc function. > The following link leads to a Source Forge forum where I posted my code and a link to the books.xml file. > https://sourceforge.net/projects/mxquery/forums/forum/633155/topic/5412690 > > Kurt Cagle successfully used the fn:doc function in his example. > http://www.stylusstudio.com/xmldev/201101/post20010.html > > The post at the Source Forge forum describes the problem and various attempts. Any assistance would be appreciated -- thanks. > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From joewiz at gmail.com Mon Jul 9 11:45:23 2012 From: joewiz at gmail.com (Joe Wicentowski) Date: Mon, 9 Jul 2012 14:45:23 -0400 Subject: [xquery-talk] XQuery Update Facility and unwanted whitespace Message-ID: Hi all, I'm having a problem with query I wrote that makes use of the XQuery Update Facility. The problem is that unwanted whitespace inserted into the results of my query. Here is my source XML (a TEI-like list), the query in question, and the output showing the unwanted whitespace: source.xml: ----------------- See Middle East Middle East 68 fix-ids.xq: -------------- let $doc := doc('source.xml') for $item-id at $count in $doc//item/@xml:id let $new-id := concat('in', $count) let $new-target := concat('#', $new-id) let $targets := $doc//ref[@target = concat('#', $item-id)]/@target return ( (: fix @xml:ids :) replace value of node $item-id with $new-id , (: fix @targets :) for $target in $targets return replace value of node $target with $new-target ) output: ---------- See Middle East Middle East 68 Note that while the query only modifies attribute values, the results of the query are somehow re-indented. (Specifically, in the source, there was no whitespace between and , but in the results, is on a new line. Is this a serialization issue? Is there a way for me to declare some options that will prevent the unwanted whitespace from being inserted? I'm not sure whether this is a general XQuery issue or an implementation-specific issue, so let me know if this isn't the right forum for this question. I'm using oXygen 13 in XQuery Debugger mode with Saxon EE-XQuery 9.3.0.5. (On a related note, I see that XQuery 3.0 has new support for serialization options -- http://www.w3.org/TR/xquery-30/#id-serialization -- but oXygen doesn't seem to allow combining XQuery 3.0 with XQuery Update Facility and Saxon EE. This forum post instructs users to disable XQuery 1.1/3.0 support in order to use XQUF: http://www.oxygenxml.com/forum/topic6615.html.) Thanks, Joe From andrew.j.welch at gmail.com Mon Jul 9 12:02:22 2012 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Mon, 9 Jul 2012 20:02:22 +0100 Subject: [xquery-talk] XQuery Update Facility and unwanted whitespace In-Reply-To: References: Message-ID: > Is this a serialization issue? Is there a way for me to declare some > options that will prevent the unwanted whitespace from being inserted? > > I'm not sure whether this is a general XQuery issue or an > implementation-specific issue, so let me know if this isn't the right > forum for this question. I'm using oXygen 13 in XQuery Debugger mode > with Saxon EE-XQuery 9.3.0.5. In the XQuery options (in oXygen) untick 'format transformer output' -- Andrew Welch http://andrewjwelch.com From joewiz at gmail.com Mon Jul 9 12:35:47 2012 From: joewiz at gmail.com (Joe Wicentowski) Date: Mon, 9 Jul 2012 15:35:47 -0400 Subject: [xquery-talk] XQuery Update Facility and unwanted whitespace In-Reply-To: References: Message-ID: Hi Andrew, > In the XQuery options (in oXygen) untick 'format transformer output' Thanks for that suggestion. That's definitely preferable, in that it doesn't introduce new whitespace, though it does strips out all whitespace between nodes -- which is fine with me: See Middle EastMiddle East 68 To sum up, I guess this was an oXygen/Saxon-specific issue, but it applies to all XQuery results in oXygen, not just those queries that use the XQuery Update Facility. Ah, whitespace. Life would be so boring and straightforward without you. Thanks again, Joe From andrew.j.welch at gmail.com Mon Jul 9 12:53:49 2012 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Mon, 9 Jul 2012 20:53:49 +0100 Subject: [xquery-talk] XQuery Update Facility and unwanted whitespace In-Reply-To: References: Message-ID: On 9 July 2012 20:35, Joe Wicentowski wrote: > Hi Andrew, > >> In the XQuery options (in oXygen) untick 'format transformer output' > > Thanks for that suggestion. That's definitely preferable, in that it > doesn't introduce new whitespace, though it does strips out all > whitespace between nodes -- which is fine with me: What is you "strip whitespace" set to? It sounds like it's set to "all"... -- Andrew Welch http://andrewjwelch.com From joewiz at gmail.com Mon Jul 9 14:12:04 2012 From: joewiz at gmail.com (Joe Wicentowski) Date: Mon, 9 Jul 2012 17:12:04 -0400 Subject: [xquery-talk] XQuery Update Facility and unwanted whitespace In-Reply-To: References: Message-ID: Hi Andrew, > What is you "strip whitespace" set to? It sounds like it's set to "all"... Great point - I had actually been fiddling with that setting earlier before your I emailed the list. Setting it back to "none" or "ignorable" is much better: See Middle East Middle East 68 I couldn't get it to put on a new line, but that's no biggie. So, in sum, the combination of unticking 'format transformer output' and setting 'strip whitespace' to 'none' or 'ignorable' yields quite nice results. Thanks very much, Andrew. Joe From mike at saxonica.com Tue Jul 10 01:00:23 2012 From: mike at saxonica.com (Michael Kay) Date: Tue, 10 Jul 2012 09:00:23 +0100 Subject: [xquery-talk] XQuery Update Facility and unwanted whitespace In-Reply-To: References: Message-ID: <4FFBE117.70204@saxonica.com> Andrew has answered the whitespace questions. It's a Saxon (not an Oxygen) restriction that XQuery 3.0 and XQuery Update can't currently be used together in the same query. It happened that way because both are implemented as extensions to the "core" XQuery 1.0 parser, built using subclassing. (Done that way partly because of the code separation between different Saxon editions). We need to fix this mechanism, which is becoming pretty unmanageable with the number of different language dialects supported. Ideally, I suppose, we should make a complete break and move to a bottom-up table driven parser; but XQuery parsing is so fragile with the number of context-dependent decisions that need to be made, it's a risky change to contemplate. Michael Kay Saxonica On 09/07/2012 19:45, Joe Wicentowski wrote: > Hi all, > > I'm having a problem with query I wrote that makes use of the XQuery > Update Facility. The problem is that unwanted whitespace inserted > into the results of my query. Here is my source XML (a TEI-like > list), the query in question, and the output showing the unwanted > whitespace: > > source.xml: > ----------------- > > See Middle East > Middle East 68 > > > fix-ids.xq: > -------------- > let $doc := doc('source.xml') > for $item-id at $count in $doc//item/@xml:id > let $new-id := concat('in', $count) > let $new-target := concat('#', $new-id) > let $targets := $doc//ref[@target = concat('#', $item-id)]/@target > return > ( > (: fix @xml:ids :) > replace value of node $item-id with $new-id > , > (: fix @targets :) > for $target in $targets > return > replace value of node $target with $new-target > ) > > output: > ---------- > > See Middle East > > Middle East 68 > > > > Note that while the query only modifies attribute values, the results > of the query are somehow re-indented. (Specifically, in the source, > there was no whitespace between and , but in the > results, is on a new line. > > Is this a serialization issue? Is there a way for me to declare some > options that will prevent the unwanted whitespace from being inserted? > > I'm not sure whether this is a general XQuery issue or an > implementation-specific issue, so let me know if this isn't the right > forum for this question. I'm using oXygen 13 in XQuery Debugger mode > with Saxon EE-XQuery 9.3.0.5. > > (On a related note, I see that XQuery 3.0 has new support for > serialization options -- > http://www.w3.org/TR/xquery-30/#id-serialization -- but oXygen doesn't > seem to allow combining XQuery 3.0 with XQuery Update Facility and > Saxon EE. This forum post instructs users to disable XQuery 1.1/3.0 > support in order to use XQUF: > http://www.oxygenxml.com/forum/topic6615.html.) > > Thanks, > Joe > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > From wcandillon at gmail.com Wed Jul 11 08:59:58 2012 From: wcandillon at gmail.com (William Candillon) Date: Wed, 11 Jul 2012 17:59:58 +0200 Subject: [xquery-talk] XML & XQuery @ NoSQL Now! 2012 Message-ID: Hello gang, This year edition of the NoSQL Now! 2012 will feature several talks related to XML & XQuery topics. We have listed the ones related to the Zorba XQuery Processor at http://www.zorba-xquery.com/html/entry/2012/07/10/NoSQL_Now We hope to see you there! William From ihe.onwuka at googlemail.com Fri Jul 13 07:41:50 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Fri, 13 Jul 2012 15:41:50 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. Message-ID: Given this in modelNames.xml sales stocks plants clients I am having problems with the following XQuery xquery version "1.0"; declare namespace b2b = "http://www.b2b.net/plants"; declare namespace xf="http://www.w3.org/2002/xforms"; declare namespace html="http://www.w3.org/1999/xhtml"; declare namespace ev="http://www.w3.org/2001/xml-events"; declare variable $configDir as xs:string :="config"; declare variable $models as element()* :=doc(concat($configDir,"/modelNames.xml"))/*/*; declare function local:bindModel($x,$y,$z) {$x}; declare function local:capitalise($str) { concat(upper-case(substring($str,1,1)),substring($str,2)) }; declare function local:defineModelRoot($model as element()) { element {concat('b2b:',local:capitalise($model/text()))} {element xf:bind {attribute repeat {local:getBindingFileName($model)}}} }; declare function local:getBindingFileName($model as element()) as xs:string { concat($model/@singular,'Bindings.xml') }; {$models/*/{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} The idea of the line that says {$models/*/{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} is for the direct constructor to be evaluated for each model element in $models. The two substitutions I am hoping for is the text() element in the AVT for the id attribute of the case element and the . in local:defineModelRoot, which is meant to pass the context model element as a parameter to local:defineModelRoot. Is my understanding of what I should expect incorrect. If so I would appreciate an explanation rather than just a solution. thanks. From mike at saxonica.com Fri Jul 13 08:18:08 2012 From: mike at saxonica.com (Michael Kay) Date: Fri, 13 Jul 2012 16:18:08 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: References: Message-ID: <50003C30.9040609@saxonica.com> Your problem is that the initialization of $models goes down two levels below the document node, so it is bound to a sequence of Model elements, so when you do $models/* you are selecting the children of the Model elements, but there are no child elements to select. Remove a /* either from the definition of $models or from the expression where it is used. Michael Kay Saxonica On 13/07/2012 15:41, Ihe Onwuka wrote: > xquery version "1.0"; > > > declare namespace b2b ="http://www.b2b.net/plants"; > declare namespace xf="http://www.w3.org/2002/xforms"; > declare namespace html="http://www.w3.org/1999/xhtml"; > declare namespace ev="http://www.w3.org/2001/xml-events"; > > declare variable $configDir as xs:string :="config"; > > declare variable $models as element()* > :=doc(concat($configDir,"/modelNames.xml"))/*/*; > > declare function local:bindModel($x,$y,$z) {$x}; > > declare function local:capitalise($str) > { > concat(upper-case(substring($str,1,1)),substring($str,2)) > }; > > declare function local:defineModelRoot($model as element()) > { > element {concat('b2b:',local:capitalise($model/text()))} > {element xf:bind {attribute repeat > {local:getBindingFileName($model)}}} > }; > > declare function local:getBindingFileName($model as element()) as xs:string > { > concat($model/@singular,'Bindings.xml') > }; > > {$models/*/ id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} > From josh.spiegel at oracle.com Fri Jul 13 08:20:41 2012 From: josh.spiegel at oracle.com (Josh Spiegel) Date: Fri, 13 Jul 2012 08:20:41 -0700 (PDT) Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: References: Message-ID: <7BB45048-4E46-448C-857F-B10DA484250F@oracle.com> It seems like you might have too many '/*' steps. For example, if you evaluate $models/* in the body, I think you should get the empty sequence. $models appears to bind to the sequence of elements so $models/* would select element children of each but there aren't any. I would try changing your line to the following: {$models/{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} Josh On Jul 13, 2012, at 7:41 AM, Ihe Onwuka wrote: > Given this in modelNames.xml > > > > sales > stocks > plants > clients > > > I am having problems with the following XQuery > > xquery version "1.0"; > > > declare namespace b2b = "http://www.b2b.net/plants"; > declare namespace xf="http://www.w3.org/2002/xforms"; > declare namespace html="http://www.w3.org/1999/xhtml"; > declare namespace ev="http://www.w3.org/2001/xml-events"; > > declare variable $configDir as xs:string :="config"; > > declare variable $models as element()* > :=doc(concat($configDir,"/modelNames.xml"))/*/*; > > declare function local:bindModel($x,$y,$z) {$x}; > > declare function local:capitalise($str) > { > concat(upper-case(substring($str,1,1)),substring($str,2)) > }; > > declare function local:defineModelRoot($model as element()) > { > element {concat('b2b:',local:capitalise($model/text()))} > {element xf:bind {attribute repeat > {local:getBindingFileName($model)}}} > }; > > declare function local:getBindingFileName($model as element()) as xs:string > { > concat($model/@singular,'Bindings.xml') > }; > > {$models/*/ id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} > > > The idea of the line that says > > {$models/*/ id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} > > is for the direct constructor to be evaluated for each model > element in $models. The two substitutions I am hoping for is the > text() element in the AVT for the id attribute of the case element and > the . in local:defineModelRoot, which is meant to pass the context > model element as a parameter to local:defineModelRoot. > > Is my understanding of what I should expect incorrect. If so I would > appreciate an explanation rather than just a solution. > > thanks. > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From ihe.onwuka at googlemail.com Fri Jul 13 09:34:53 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Fri, 13 Jul 2012 17:34:53 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: References: <7BB45048-4E46-448C-857F-B10DA484250F@oracle.com> <9E369250-A87B-40E2-B057-ECC5344E16DE@oracle.com> Message-ID: Achhh, didn't realise my replies weren't going to the list. ---------- Forwarded message ---------- From: Ihe Onwuka Date: Fri, Jul 13, 2012 at 5:10 PM Subject: Re: [xquery-talk] Simple (I thought) Xquery giving run-time error. To: Josh Spiegel Thats what I did before. Thats what I thought I did again and to be doubly sure I cut and pasted from your post. I get *************************the id attribute is wrong ******************************* I should add though I am running this in eXide maybe Saxon would give me a different result. On Fri, Jul 13, 2012 at 5:04 PM, Josh Spiegel wrote: > If you change your original query exactly as I suggested, you should get a result that looks something like: > > Josh > > > > On Jul 13, 2012, at 8:59 AM, Ihe Onwuka wrote: > >> Both you and Michael are saying the same thing. >> >> I've tried this before posting. I get > down a level, which has not worked either. >> >> I have also tried . instead of text(). >> >> On Fri, Jul 13, 2012 at 4:20 PM, Josh Spiegel wrote: >>> It seems like you might have too many '/*' steps. For example, if you evaluate $models/* in the body, I think you should get the empty sequence. $models appears to bind to the sequence of elements so $models/* would select element children of each but there aren't any. >>> >>> I would try changing your line to the following: >>> >>> {$models/{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>> >>> Josh >>> >>> On Jul 13, 2012, at 7:41 AM, Ihe Onwuka wrote: >>> >>>> Given this in modelNames.xml >>>> >>>> >>>> >>>> sales >>>> stocks >>>> plants >>>> clients >>>> >>>> >>>> I am having problems with the following XQuery >>>> >>>> xquery version "1.0"; >>>> >>>> >>>> declare namespace b2b = "http://www.b2b.net/plants"; >>>> declare namespace xf="http://www.w3.org/2002/xforms"; >>>> declare namespace html="http://www.w3.org/1999/xhtml"; >>>> declare namespace ev="http://www.w3.org/2001/xml-events"; >>>> >>>> declare variable $configDir as xs:string :="config"; >>>> >>>> declare variable $models as element()* >>>> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >>>> >>>> declare function local:bindModel($x,$y,$z) {$x}; >>>> >>>> declare function local:capitalise($str) >>>> { >>>> concat(upper-case(substring($str,1,1)),substring($str,2)) >>>> }; >>>> >>>> declare function local:defineModelRoot($model as element()) >>>> { >>>> element {concat('b2b:',local:capitalise($model/text()))} >>>> {element xf:bind {attribute repeat >>>> {local:getBindingFileName($model)}}} >>>> }; >>>> >>>> declare function local:getBindingFileName($model as element()) as xs:string >>>> { >>>> concat($model/@singular,'Bindings.xml') >>>> }; >>>> >>>> {$models/*/>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>>> >>>> >>>> The idea of the line that says >>>> >>>> {$models/*/>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>>> >>>> is for the direct constructor to be evaluated for each model >>>> element in $models. The two substitutions I am hoping for is the >>>> text() element in the AVT for the id attribute of the case element and >>>> the . in local:defineModelRoot, which is meant to pass the context >>>> model element as a parameter to local:defineModelRoot. >>>> >>>> Is my understanding of what I should expect incorrect. If so I would >>>> appreciate an explanation rather than just a solution. >>>> >>>> thanks. >>>> _______________________________________________ >>>> talk at x-query.com >>>> http://x-query.com/mailman/listinfo/talk >>> > From ihe.onwuka at googlemail.com Fri Jul 13 09:35:54 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Fri, 13 Jul 2012 17:35:54 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: <50003C30.9040609@saxonica.com> References: <50003C30.9040609@saxonica.com> Message-ID: didn't want to tamper with the definition of $models as it is used elsewhere (you are seeing a cut down version of the code), but having removed a /* from its definition, that hasn't worked either (I get the same result reported earlier). On Fri, Jul 13, 2012 at 4:18 PM, Michael Kay wrote: > > Your problem is that the initialization of $models goes down two levels > below the document node, so it is bound to a sequence of Model elements, so > when you do $models/* you are selecting the children of the Model elements, > but there are no child elements to select. Remove a /* either from the > definition of $models or from the expression where it is used. > > Michael Kay > Saxonica > > > On 13/07/2012 15:41, Ihe Onwuka wrote: >> >> xquery version "1.0"; >> >> >> declare namespace b2b ="http://www.b2b.net/plants"; >> declare namespace xf="http://www.w3.org/2002/xforms"; >> declare namespace html="http://www.w3.org/1999/xhtml"; >> declare namespace ev="http://www.w3.org/2001/xml-events"; >> >> declare variable $configDir as xs:string :="config"; >> >> declare variable $models as element()* >> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >> >> declare function local:bindModel($x,$y,$z) {$x}; >> >> declare function local:capitalise($str) >> { >> concat(upper-case(substring($str,1,1)),substring($str,2)) >> }; >> >> declare function local:defineModelRoot($model as element()) >> { >> element {concat('b2b:',local:capitalise($model/text()))} >> {element xf:bind {attribute repeat >> {local:getBindingFileName($model)}}} >> }; >> >> declare function local:getBindingFileName($model as element()) as >> xs:string >> { >> concat($model/@singular,'Bindings.xml') >> }; >> >> {$models/*/> >> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >> > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From mike at saxonica.com Fri Jul 13 09:48:17 2012 From: mike at saxonica.com (Michael Kay) Date: Fri, 13 Jul 2012 17:48:17 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: References: <50003C30.9040609@saxonica.com> Message-ID: <50005151.3040200@saxonica.com> On 13/07/2012 17:35, Ihe Onwuka wrote: > didn't want to tamper with the definition of $models as it is used > elsewhere (you are seeing a cut down version of the code), but having > removed a /* from its definition, that hasn't worked either (I get the > same result reported earlier). Well, there's another mistake then. Removing the /* worked for me. Michael Kay Saxonica > > On Fri, Jul 13, 2012 at 4:18 PM, Michael Kay wrote: >> Your problem is that the initialization of $models goes down two levels >> below the document node, so it is bound to a sequence of Model elements, so >> when you do $models/* you are selecting the children of the Model elements, >> but there are no child elements to select. Remove a /* either from the >> definition of $models or from the expression where it is used. >> >> Michael Kay >> Saxonica >> >> >> On 13/07/2012 15:41, Ihe Onwuka wrote: >>> xquery version "1.0"; >>> >>> >>> declare namespace b2b ="http://www.b2b.net/plants"; >>> declare namespace xf="http://www.w3.org/2002/xforms"; >>> declare namespace html="http://www.w3.org/1999/xhtml"; >>> declare namespace ev="http://www.w3.org/2001/xml-events"; >>> >>> declare variable $configDir as xs:string :="config"; >>> >>> declare variable $models as element()* >>> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >>> >>> declare function local:bindModel($x,$y,$z) {$x}; >>> >>> declare function local:capitalise($str) >>> { >>> concat(upper-case(substring($str,1,1)),substring($str,2)) >>> }; >>> >>> declare function local:defineModelRoot($model as element()) >>> { >>> element {concat('b2b:',local:capitalise($model/text()))} >>> {element xf:bind {attribute repeat >>> {local:getBindingFileName($model)}}} >>> }; >>> >>> declare function local:getBindingFileName($model as element()) as >>> xs:string >>> { >>> concat($model/@singular,'Bindings.xml') >>> }; >>> >>> {$models/*/>> >>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > From ihe.onwuka at googlemail.com Fri Jul 13 09:55:45 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Fri, 13 Jul 2012 17:55:45 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: <50005151.3040200@saxonica.com> References: <50003C30.9040609@saxonica.com> <50005151.3040200@saxonica.com> Message-ID: I'm running this on eXide, I'll try it on Saxon. On Fri, Jul 13, 2012 at 5:48 PM, Michael Kay wrote: > > On 13/07/2012 17:35, Ihe Onwuka wrote: >> >> didn't want to tamper with the definition of $models as it is used >> elsewhere (you are seeing a cut down version of the code), but having >> removed a /* from its definition, that hasn't worked either (I get the >> same result reported earlier). > > Well, there's another mistake then. Removing the /* worked for me. > > Michael Kay > Saxonica >> >> >> On Fri, Jul 13, 2012 at 4:18 PM, Michael Kay wrote: >>> >>> Your problem is that the initialization of $models goes down two levels >>> below the document node, so it is bound to a sequence of Model elements, >>> so >>> when you do $models/* you are selecting the children of the Model >>> elements, >>> but there are no child elements to select. Remove a /* either from the >>> definition of $models or from the expression where it is used. >>> >>> Michael Kay >>> Saxonica >>> >>> >>> On 13/07/2012 15:41, Ihe Onwuka wrote: >>>> >>>> xquery version "1.0"; >>>> >>>> >>>> declare namespace b2b ="http://www.b2b.net/plants"; >>>> declare namespace xf="http://www.w3.org/2002/xforms"; >>>> declare namespace html="http://www.w3.org/1999/xhtml"; >>>> declare namespace ev="http://www.w3.org/2001/xml-events"; >>>> >>>> declare variable $configDir as xs:string :="config"; >>>> >>>> declare variable $models as element()* >>>> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >>>> >>>> declare function local:bindModel($x,$y,$z) {$x}; >>>> >>>> declare function local:capitalise($str) >>>> { >>>> concat(upper-case(substring($str,1,1)),substring($str,2)) >>>> }; >>>> >>>> declare function local:defineModelRoot($model as element()) >>>> { >>>> element {concat('b2b:',local:capitalise($model/text()))} >>>> {element xf:bind {attribute repeat >>>> {local:getBindingFileName($model)}}} >>>> }; >>>> >>>> declare function local:getBindingFileName($model as element()) as >>>> xs:string >>>> { >>>> concat($model/@singular,'Bindings.xml') >>>> }; >>>> >>>> {$models/*/>>> >>>> >>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>>> >>> >>> >>> >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From ihe.onwuka at googlemail.com Fri Jul 13 10:44:44 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Fri, 13 Jul 2012 18:44:44 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: References: <50003C30.9040609@saxonica.com> <50005151.3040200@saxonica.com> Message-ID: It works on Saxon.... it's a bug in the eXist XQuery processor. On Fri, Jul 13, 2012 at 5:55 PM, Ihe Onwuka wrote: > I'm running this on eXide, I'll try it on Saxon. > > On Fri, Jul 13, 2012 at 5:48 PM, Michael Kay wrote: >> >> On 13/07/2012 17:35, Ihe Onwuka wrote: >>> >>> didn't want to tamper with the definition of $models as it is used >>> elsewhere (you are seeing a cut down version of the code), but having >>> removed a /* from its definition, that hasn't worked either (I get the >>> same result reported earlier). >> >> Well, there's another mistake then. Removing the /* worked for me. >> >> Michael Kay >> Saxonica >>> >>> >>> On Fri, Jul 13, 2012 at 4:18 PM, Michael Kay wrote: >>>> >>>> Your problem is that the initialization of $models goes down two levels >>>> below the document node, so it is bound to a sequence of Model elements, >>>> so >>>> when you do $models/* you are selecting the children of the Model >>>> elements, >>>> but there are no child elements to select. Remove a /* either from the >>>> definition of $models or from the expression where it is used. >>>> >>>> Michael Kay >>>> Saxonica >>>> >>>> >>>> On 13/07/2012 15:41, Ihe Onwuka wrote: >>>>> >>>>> xquery version "1.0"; >>>>> >>>>> >>>>> declare namespace b2b ="http://www.b2b.net/plants"; >>>>> declare namespace xf="http://www.w3.org/2002/xforms"; >>>>> declare namespace html="http://www.w3.org/1999/xhtml"; >>>>> declare namespace ev="http://www.w3.org/2001/xml-events"; >>>>> >>>>> declare variable $configDir as xs:string :="config"; >>>>> >>>>> declare variable $models as element()* >>>>> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >>>>> >>>>> declare function local:bindModel($x,$y,$z) {$x}; >>>>> >>>>> declare function local:capitalise($str) >>>>> { >>>>> concat(upper-case(substring($str,1,1)),substring($str,2)) >>>>> }; >>>>> >>>>> declare function local:defineModelRoot($model as element()) >>>>> { >>>>> element {concat('b2b:',local:capitalise($model/text()))} >>>>> {element xf:bind {attribute repeat >>>>> {local:getBindingFileName($model)}}} >>>>> }; >>>>> >>>>> declare function local:getBindingFileName($model as element()) as >>>>> xs:string >>>>> { >>>>> concat($model/@singular,'Bindings.xml') >>>>> }; >>>>> >>>>> {$models/*/>>>> >>>>> >>>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> talk at x-query.com >>>> http://x-query.com/mailman/listinfo/talk >>> >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk >>> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk From ihe.onwuka at googlemail.com Fri Jul 13 13:00:53 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Fri, 13 Jul 2012 21:00:53 +0100 Subject: [xquery-talk] Simple (I thought) Xquery giving run-time error. In-Reply-To: References: <50003C30.9040609@saxonica.com> <50005151.3040200@saxonica.com> Message-ID: which I am told has now been fixed. On Fri, Jul 13, 2012 at 6:44 PM, Ihe Onwuka wrote: > It works on Saxon.... it's a bug in the eXist XQuery processor. > > On Fri, Jul 13, 2012 at 5:55 PM, Ihe Onwuka wrote: >> I'm running this on eXide, I'll try it on Saxon. >> >> On Fri, Jul 13, 2012 at 5:48 PM, Michael Kay wrote: >>> >>> On 13/07/2012 17:35, Ihe Onwuka wrote: >>>> >>>> didn't want to tamper with the definition of $models as it is used >>>> elsewhere (you are seeing a cut down version of the code), but having >>>> removed a /* from its definition, that hasn't worked either (I get the >>>> same result reported earlier). >>> >>> Well, there's another mistake then. Removing the /* worked for me. >>> >>> Michael Kay >>> Saxonica >>>> >>>> >>>> On Fri, Jul 13, 2012 at 4:18 PM, Michael Kay wrote: >>>>> >>>>> Your problem is that the initialization of $models goes down two levels >>>>> below the document node, so it is bound to a sequence of Model elements, >>>>> so >>>>> when you do $models/* you are selecting the children of the Model >>>>> elements, >>>>> but there are no child elements to select. Remove a /* either from the >>>>> definition of $models or from the expression where it is used. >>>>> >>>>> Michael Kay >>>>> Saxonica >>>>> >>>>> >>>>> On 13/07/2012 15:41, Ihe Onwuka wrote: >>>>>> >>>>>> xquery version "1.0"; >>>>>> >>>>>> >>>>>> declare namespace b2b ="http://www.b2b.net/plants"; >>>>>> declare namespace xf="http://www.w3.org/2002/xforms"; >>>>>> declare namespace html="http://www.w3.org/1999/xhtml"; >>>>>> declare namespace ev="http://www.w3.org/2001/xml-events"; >>>>>> >>>>>> declare variable $configDir as xs:string :="config"; >>>>>> >>>>>> declare variable $models as element()* >>>>>> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >>>>>> >>>>>> declare function local:bindModel($x,$y,$z) {$x}; >>>>>> >>>>>> declare function local:capitalise($str) >>>>>> { >>>>>> concat(upper-case(substring($str,1,1)),substring($str,2)) >>>>>> }; >>>>>> >>>>>> declare function local:defineModelRoot($model as element()) >>>>>> { >>>>>> element {concat('b2b:',local:capitalise($model/text()))} >>>>>> {element xf:bind {attribute repeat >>>>>> {local:getBindingFileName($model)}}} >>>>>> }; >>>>>> >>>>>> declare function local:getBindingFileName($model as element()) as >>>>>> xs:string >>>>>> { >>>>>> concat($model/@singular,'Bindings.xml') >>>>>> }; >>>>>> >>>>>> {$models/*/>>>>> >>>>>> >>>>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}} >>>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> talk at x-query.com >>>>> http://x-query.com/mailman/listinfo/talk >>>> >>>> _______________________________________________ >>>> talk at x-query.com >>>> http://x-query.com/mailman/listinfo/talk >>>> >>> >>> >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk From Martin.Honnen at gmx.de Wed Jul 18 05:55:32 2012 From: Martin.Honnen at gmx.de (Martin Honnen) Date: Wed, 18 Jul 2012 14:55:32 +0200 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> Message-ID: <5006B244.2050107@gmx.de> Gary Larsen wrote: > let$doc := > > 1item 1 > 2item 2 > > > let$hdr :=concat('Id', codepoints-to-string(9), 'Name', > codepoints-to-string(10)) return concat($hdr, > for$i in$doc/item return > concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10)) ) -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/ From andrew.j.welch at gmail.com Wed Jul 18 06:04:04 2012 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Wed, 18 Jul 2012 14:04:04 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <5006b176.08e7440a.58ab.ffffaeffSMTPIN_ADDED@mx.google.com> References: <5006b176.08e7440a.58ab.ffffaeffSMTPIN_ADDED@mx.google.com> Message-ID: > I can?t seem to find valid syntax for output of a value before a for loop. > In this example I want to output a header line ($hdr) to the results. > let $doc := > > 1item 1 > 2item 2 > > > let $hdr := concat('Id', codepoints-to-string(9), 'Name', > codepoints-to-string(10)) > > for $i in $doc/item return > concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10)) let $doc := 1item 1 2item 2 return string-join(('Id Name', $doc/item/concat(id, ' ', name)), ' ') -- Andrew Welch http://andrewjwelch.com From davidc at nag.co.uk Wed Jul 18 06:04:29 2012 From: davidc at nag.co.uk (David Carlisle) Date: Wed, 18 Jul 2012 14:04:29 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> Message-ID: <5006B45D.4000705@nag.co.uk> On 18/07/2012 13:49, Gary Larsen wrote: > Hi, > > I can?t seem to find valid syntax for output of a value before a for > loop. In this example I want to output a header line ($hdr) to the results. > > Thanks for your help, > > Gary > > let$doc := > > 1item 1 > 2item 2 > > > let$hdr :=concat('Id', codepoints-to-string(9), 'Name', > codepoints-to-string(10)) > > for$i in$doc/item return > concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10)) > for is just an expression so you could for example use concat($hdr,for $i in ......) of course in this simple example you don't need the variable at all as $hdr is already just a call to concat you could return the single expression concat('Id', codepoints-to-string(9), 'Name', codepoints-to-string(10), for $i in$doc/item return concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10) ) or more simply string-join( ('Id Name',$doc/item/concat(id,' ',name)),' ') the let and for clauses aren't really needed, David -- google plus: https:/profiles.google.com/d.p.carlisle ________________________________________________________________________ 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 Jul 18 06:30:10 2012 From: mike at saxonica.com (Michael Kay) Date: Wed, 18 Jul 2012 14:30:10 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <5006B244.2050107@gmx.de> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B244.2050107@gmx.de> Message-ID: <5006BA62.1090309@saxonica.com> An argument to concat() can't be a sequence: you need string-join(). Michael Kay Saxonica On 18/07/2012 13:55, Martin Honnen wrote: > Gary Larsen wrote: > >> let$doc := >> >> 1item 1 >> 2item 2 >> >> >> let$hdr :=concat('Id', codepoints-to-string(9), 'Name', >> codepoints-to-string(10)) > > return concat($hdr, > >> for$i in$doc/item return >> concat($i/id, codepoints-to-string(9), $i/name, >> codepoints-to-string(10)) > > ) > > From davidc at nag.co.uk Wed Jul 18 06:52:17 2012 From: davidc at nag.co.uk (David Carlisle) Date: Wed, 18 Jul 2012 14:52:17 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <5006B45D.4000705@nag.co.uk> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B45D.4000705@nag.co.uk> Message-ID: <5006BF91.5070703@nag.co.uk> On 18/07/2012 14:04, David Carlisle wrote: > > > for is just an expression true so you could for example use false sorry, you can't use concat here, the verions below using string-join are OK though. > concat($hdr,for $i in ......) > > of course in this simple example you don't need the variable at all as > $hdr is already just a call to concat you could return the single > expression > > concat('Id', codepoints-to-string(9), 'Name', > codepoints-to-string(10), > for $i in$doc/item return > concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10) > ) > > or more simply > > string-join( > ('Id Name',$doc/item/concat(id,' ',name)),' ') > > the let and for clauses aren't really needed, > > David > > > > -- google plus: https:/profiles.google.com/d.p.carlisle ________________________________________________________________________ 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 gary.larsen at envisn.com Wed Jul 18 06:59:29 2012 From: gary.larsen at envisn.com (Gary Larsen) Date: Wed, 18 Jul 2012 09:59:29 -0400 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <5006BF91.5070703@nag.co.uk> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B45D.4000705@nag.co.uk> <5006BF91.5070703@nag.co.uk> Message-ID: <008701cd64ed$8dd33bb0$a979b310$@larsen@envisn.com> Thanks for everyone's suggestions! Using this syntax: let $hdr := concat('Id', codepoints-to-string(9), 'Name', codepoints-to-string(10)) let $body := for $i in $doc/item return concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10)) return string-join($hdr, $body) I'm getting a error due to the results of the for loop: The actual cardinality for parameter 2 does not match the cardinality declared in the function's signature: string-join($arg as xs:string*, $separator as xs:string) xs:string. Expected cardinality: exactly one, got 2. Gary -----Original Message----- From: David Carlisle [mailto:davidc at nag.co.uk] Sent: Wednesday, July 18, 2012 9:52 AM To: Gary Larsen Cc: talk at x-query.com Subject: Re: [xquery-talk] Add value to result before a for loop On 18/07/2012 14:04, David Carlisle wrote: > > > for is just an expression true so you could for example use false sorry, you can't use concat here, the verions below using string-join are OK though. > concat($hdr,for $i in ......) > > of course in this simple example you don't need the variable at all as > $hdr is already just a call to concat you could return the single > expression > > concat('Id', codepoints-to-string(9), 'Name', > codepoints-to-string(10), > for $i in$doc/item return > concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10) > ) > > or more simply > > string-join( > ('Id Name',$doc/item/concat(id,' ',name)),' ') > > the let and for clauses aren't really needed, > > David > > > > -- google plus: https:/profiles.google.com/d.p.carlisle ________________________________________________________________________ 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 davidc at nag.co.uk Wed Jul 18 07:04:07 2012 From: davidc at nag.co.uk (David Carlisle) Date: Wed, 18 Jul 2012 15:04:07 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <008701cd64ed$8dd33bb0$a979b310$@larsen@envisn.com> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B45D.4000705@nag.co.uk> <5006BF91.5070703@nag.co.uk> <008701cd64ed$8dd33bb0$a979b310$@larsen@envisn.com> Message-ID: <5006C257.6030801@nag.co.uk> On 18/07/2012 14:59, Gary Larsen wrote: > string-join($hdr, $body) string join tales a sequence as the first argument and a separator string as the second so that should be string-join(($hdr, $body),'') the examples posted all had '' as the second argument or ' ' if you want to add the line sep at that point rather than add it to each item) David -- google plus: https:/profiles.google.com/d.p.carlisle ________________________________________________________________________ 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 Martin.Honnen at gmx.de Wed Jul 18 07:04:17 2012 From: Martin.Honnen at gmx.de (Martin Honnen) Date: Wed, 18 Jul 2012 16:04:17 +0200 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <008701cd64ed$8dd33bb0$a979b310$@larsen@envisn.com> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B45D.4000705@nag.co.uk> <5006BF91.5070703@nag.co.uk> <008701cd64ed$8dd33bb0$a979b310$@larsen@envisn.com> Message-ID: <5006C261.4020406@gmx.de> Gary Larsen wrote: > let $hdr := concat('Id', codepoints-to-string(9), 'Name', > codepoints-to-string(10)) > let $body := for $i in $doc/item return > concat($i/id, codepoints-to-string(9), $i/name, codepoints-to-string(10)) > return string-join($hdr, $body) Michael had the right suggestion return string-join(($hdr, $body), '') where the first argument to string-join is the sequence ($hdr, $body) and the second argument to separator string. -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/ From Martin.Honnen at gmx.de Wed Jul 18 07:08:31 2012 From: Martin.Honnen at gmx.de (Martin Honnen) Date: Wed, 18 Jul 2012 16:08:31 +0200 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <5006BA62.1090309@saxonica.com> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B244.2050107@gmx.de> <5006BA62.1090309@saxonica.com> Message-ID: <5006C35F.4030909@gmx.de> Michael Kay wrote: > > An argument to concat() can't be a sequence: you need string-join(). You are right, sorry. -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/ From gary.larsen at envisn.com Wed Jul 18 07:20:09 2012 From: gary.larsen at envisn.com (Gary Larsen) Date: Wed, 18 Jul 2012 10:20:09 -0400 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <5006C257.6030801@nag.co.uk> References: <005b01cd64e3$c0685830$41390890$@larsen@envisn.com> <5006B45D.4000705@nag.co.uk> <5006BF91.5070703@nag.co.uk> <008701cd64ed$8dd33bb0$a979b310$@larsen@envisn.com> <5006C257.6030801@nag.co.uk> Message-ID: <009a01cd64f0$701f4ac0$505de040$@larsen@envisn.com> That's it! Thanks. Gary -----Original Message----- From: David Carlisle [mailto:davidc at nag.co.uk] Sent: Wednesday, July 18, 2012 10:04 AM To: Gary Larsen Cc: talk at x-query.com Subject: Re: [xquery-talk] Add value to result before a for loop On 18/07/2012 14:59, Gary Larsen wrote: > string-join($hdr, $body) string join tales a sequence as the first argument and a separator string as the second so that should be string-join(($hdr, $body),'') the examples posted all had '' as the second argument or ' ' if you want to add the line sep at that point rather than add it to each item) David -- google plus: https:/profiles.google.com/d.p.carlisle ________________________________________________________________________ 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 andrew.j.welch at gmail.com Wed Jul 18 12:13:22 2012 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Wed, 18 Jul 2012 20:13:22 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <220256FDE771B74FB662165BC562CF59407B276E@BY2PRD0810MB391.namprd08.prod.outlook.com> References: <5007088B.1090807@ifactory.com> <220256FDE771B74FB662165BC562CF59407B276E@BY2PRD0810MB391.namprd08.prod.outlook.com> Message-ID: On 18 July 2012 20:08, David Lee wrote: > Prety sure you can avoid the text {} and () and just do > > > > "Id Name", > > for $i in $doc/item return > > concat($i/id, " ", $i/name) > you can reduce it down a little further: for $i in $doc/item return concat(.....) is the same as $doc/item/concat(.....) which is what I did earlier: return string-join(('Id Name', $doc/item/concat(id, ' ', name)), ' ') -- Andrew Welch http://andrewjwelch.com From sokolov at ifactory.com Wed Jul 18 12:47:55 2012 From: sokolov at ifactory.com (Mike Sokolov) Date: Wed, 18 Jul 2012 15:47:55 -0400 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: References: <5007088B.1090807@ifactory.com> <220256FDE771B74FB662165BC562CF59407B276E@BY2PRD0810MB391.namprd08.prod.outlook.com> Message-ID: <500712EB.40406@ifactory.com> On 07/18/2012 03:13 PM, Andrew Welch wrote: > > you can reduce it down a little further: > > for $i in $doc/item return concat(.....) > > is the same as > > $doc/item/concat(.....) > > which is what I did earlier: > > return string-join(('Id Name', $doc/item/concat(id, ' ', name)), ' ') > Sorry - missed that :) I still wonder whether 'Id Name', $doc/item/concat(id, ' ', name) will always work, or if you might sometimes get CRLF separators, or spaces, or nothing at all -Mike Sokolov From dlee at calldei.com Wed Jul 18 12:54:16 2012 From: dlee at calldei.com (David Lee) Date: Wed, 18 Jul 2012 19:54:16 +0000 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <500712EB.40406@ifactory.com> References: <5007088B.1090807@ifactory.com> <220256FDE771B74FB662165BC562CF59407B276E@BY2PRD0810MB391.namprd08.prod.outlook.com> <500712EB.40406@ifactory.com> Message-ID: <220256FDE771B74FB662165BC562CF59407B282F@BY2PRD0810MB391.namprd08.prod.outlook.com> > I still wonder whether > > 'Id Name', > $doc/item/concat(id, ' ', name) > > will always work, or if you might sometimes get CRLF separators, or > spaces, or nothing at all > The output is guaranteed to be application specific. If it is text serialized by a spec conforming XQuery processor then the 2 items will be space separated. But no one said how the result is serialized. Up to the app ... ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org From mike at saxonica.com Wed Jul 18 13:43:11 2012 From: mike at saxonica.com (Michael Kay) Date: Wed, 18 Jul 2012 21:43:11 +0100 Subject: [xquery-talk] Add value to result before a for loop In-Reply-To: <500712EB.40406@ifactory.com> References: <5007088B.1090807@ifactory.com> <220256FDE771B74FB662165BC562CF59407B276E@BY2PRD0810MB391.namprd08.prod.outlook.com> <500712EB.40406@ifactory.com> Message-ID: <50071FDF.9080607@saxonica.com> > I still wonder whether > > 'Id Name', > $doc/item/concat(id, ' ', name) > > will always work, or if you might sometimes get CRLF separators, or > spaces, or nothing at all > The serialization spec clearly says that the separator should be a single space character. There is a debate about providing alternatives, but that's the status quo. Michael Kay Saxonica From ihe.onwuka at googlemail.com Sun Jul 22 15:33:24 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Sun, 22 Jul 2012 23:33:24 +0100 Subject: [xquery-talk] Comments Gotcha Message-ID: Didn't use the right kind of comments and fell foul of this gotcha http://en.wikibooks.org/wiki/XQuery/Gotchas#Comments Except what I really want to do is comment a line in a direct constructor and whichever type of comment I use it's going to appear in the output and I don't want it to. From davidc at nag.co.uk Sun Jul 22 15:46:34 2012 From: davidc at nag.co.uk (David Carlisle) Date: Sun, 22 Jul 2012 23:46:34 +0100 Subject: [xquery-talk] Comments Gotcha In-Reply-To: References: Message-ID: <500C82CA.3040000@nag.co.uk> On 22/07/2012 23:33, Ihe Onwuka wrote: > Didn't use the right kind of comments and fell foul of this gotcha > > http://en.wikibooks.org/wiki/XQuery/Gotchas#Comments > > Except what I really want to do is comment a line in a direct > constructor and whichever type of comment I use it's going to appear > in the output and I don't want it to. Can't you do {((: a comment:))} To put a comment in (an empty list in an enclosed expression in) a direct element constructor? David From dlee at calldei.com Sun Jul 22 17:51:50 2012 From: dlee at calldei.com (David Lee) Date: Mon, 23 Jul 2012 00:51:50 +0000 Subject: [xquery-talk] Comments Gotcha In-Reply-To: <500C82CA.3040000@nag.co.uk> References: <500C82CA.3040000@nag.co.uk> Message-ID: <220256FDE771B74FB662165BC562CF59407B5216@BY2PRD0810MB391.namprd08.prod.outlook.com> Like David Said ... Or {()(:comment:)} Admittedly its one of the quirkiest parts of xquery .... But makes total sense once you do a hand stand and put one foot on blue and a hand on red. Atleast its not XSLT :) -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of David Carlisle Sent: Sunday, July 22, 2012 6:47 PM To: Ihe Onwuka Cc: talk at x-query.com Subject: Re: [xquery-talk] Comments Gotcha On 22/07/2012 23:33, Ihe Onwuka wrote: > Didn't use the right kind of comments and fell foul of this gotcha > > http://en.wikibooks.org/wiki/XQuery/Gotchas#Comments > > Except what I really want to do is comment a line in a direct > constructor and whichever type of comment I use it's going to appear > in the output and I don't want it to. Can't you do {((: a comment:))} To put a comment in (an empty list in an enclosed expression in) a direct element constructor? David _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From ihe.onwuka at googlemail.com Tue Jul 31 09:25:25 2012 From: ihe.onwuka at googlemail.com (Ihe Onwuka) Date: Tue, 31 Jul 2012 17:25:25 +0100 Subject: [xquery-talk] FLOWR vs Xpath axis syntax - Performance Message-ID: I vaguely remember reading somewhere that a preference for what I would call axis notation has performance advantages over the equivalent FLOWR code. I certainly recall reading that XPath predicates perform better than where clauses in FLOWR. I would appreciate clarification, confirmation or correction and general enllightenment. From dlee at calldei.com Tue Jul 31 09:29:56 2012 From: dlee at calldei.com (David Lee) Date: Tue, 31 Jul 2012 16:29:56 +0000 Subject: [xquery-talk] FLOWR vs Xpath axis syntax - Performance In-Reply-To: References: Message-ID: <220256FDE771B74FB662165BC562CF59407CC529@BY2PRD0810MB391.namprd08.prod.outlook.com> IMHO ... performance characteristics are implementation dependent. I don't believe one can make a statement that a particular syntax or feature is in general more performant in XQuery in general. It depends on the implementation and often a lot more than that such as the particular document set, indexing, document size, caching, machnine configurations, system variables enabled etc. ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org > -----Original Message----- > From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On > Behalf Of Ihe Onwuka > Sent: Tuesday, July 31, 2012 12:25 PM > To: talk at x-query.com > Subject: [xquery-talk] FLOWR vs Xpath axis syntax - Performance > > I vaguely remember reading somewhere that a preference for what I > would call axis notation has performance advantages over the > equivalent FLOWR code. > > I certainly recall reading that XPath predicates perform better than > where clauses in FLOWR. > > I would appreciate clarification, confirmation or correction and > general enllightenment. > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From liam at w3.org Tue Jul 31 10:42:20 2012 From: liam at w3.org (Liam R E Quin) Date: Tue, 31 Jul 2012 13:42:20 -0400 Subject: [xquery-talk] FLOWR vs Xpath axis syntax - Performance In-Reply-To: References: Message-ID: <1343756540.28307.72.camel@localhost.localdomain> On Tue, 2012-07-31 at 17:25 +0100, Ihe Onwuka wrote: > I vaguely remember reading somewhere that a preference for what I > would call axis notation has performance advantages over the > equivalent FLOWR code. > > I certainly recall reading that XPath predicates perform better than > where clauses in FLOWR. It depends (as David Lee) said on the implementation, but I think today you're unlikely to find a difference in any modern XQuery implementation, except in a few cases to do with effective boolean values, where the "where" syntax might be faster: //a[$x] vs. for $item in //a where $x return $item or for $item at $n in //a where $n eq $x return $item In the past I've seen a factor of two difference between one form or the other for moderately small data sets (under a megabyte of XML, say), but that was quite some time ago, and the implementations weren't consistent in which was faster. If performance with XQuery is an issue, consider... (1) use an XML-native database in order to avoid re-parsing the XML each time; (2) do actual measurements Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org freenode/#xml