From ihe.onwuka at gmail.com Wed Jul 1 15:02:11 2015 From: ihe.onwuka at gmail.com (Ihe Onwuka) Date: Wed, 1 Jul 2015 18:02:11 -0400 Subject: [xquery-talk] [xml-dev] XML to graph In-Reply-To: References: Message-ID: Hmmm I wonder whether this would have worked on the scraped ratings data that I had to clean. Well I did that with XPath in XSLT, might take a look and see. I have 3 different movie data sets from different sources. The one I just posted containing 3m movies, 1 has 180k movies (created by with JSONiq running against freebase) and the other about 50k movies , all of which I have managed to cast in XML. So there is plenty of data to experiment with. I look forward to your trip, I'll be around for a few months myself. On Wed, Jul 1, 2015 at 2:59 PM, daniela florescu wrote: > Ihe, > > transforming XQuery to be able to do data cleaning has been a LONG desire > of mine. > > Helena Galhardas was a PhD student of mine. She is now a professor in > Lisbon, > > She and her students wrote the data cleaning package in Zorba ? it?s 100% > clean XQuery, > so you can reuse it for other engines. > > Let me know how it goes. > > On the 7th I am leaving to Europe for 3-4 months. > > I will certainly visit London often. > > Hope we can talk, best > Dana > > On Jul 1, 2015, at 11:54 AM, daniela florescu wrote: > > Ihe, > > before you load anything anywhere, you need to do data cleaning on this > data > if you do integration from the Web and data has no unique ids?.. > > In particular entity resolution? > > Literature is full of data cleaning and entity resolution algorithms. > > One that you will find familiar (because it looks very much like XQuery > :-) is here: > > http://www.inesc-id.pt/ficheiros/publicacoes/1259.pdf > > Best regards > Dana > > > > > On Jul 1, 2015, at 10:04 AM, Ihe Onwuka wrote: > > You will note that the data doesn't have a unique id. Title certainly > isn't unique, if you consider how many movies there have been called Batman > or Treasure Island. > > Now I may encounter data about this movie from another source that covers > different facets , for example it's box office takings or movie reviews. > > So it's a classic semantic web application. I want to amalgamate disparate > data about the same fact in one entity. As I said I have a transformation > that does this but it doesn't scale very well because I have to search the > entire movie base to find the best match. To overcome this I have to adopt > a mapReduce-ish approach to solve the problem. > > The thinking is a graphical representation would eliminate that problem > because a graph gives me a persistent data structure already indexed for > retrieval via several different axes, whereas indexes constructed in the > XSLT transformation for the same purpose are ephemeral and would need to > be reconstructed every time you ran the transformation. > > On Wed, Jul 1, 2015 at 12:46 PM, Peter Hunsberger < > peter.hunsberger at gmail.com> wrote: > >> Should be pretty straight forward to import that into Neo4J or Titan. >> Neo might be simplest, in particular via conversion of the data into JSON. >> However, Titan might give you other capabilities such as using Hadoop type >> processing either for import or for subsequent analytics. Without knowing >> more about the business requirements can't really give you much more than >> that... >> >> Peter Hunsberger >> >> On Wed, Jul 1, 2015 at 11:32 AM, Ihe Onwuka wrote: >> >>> I would like to convert the XML snippet below to a multi-relational >>> graph representation. >>> One way is to transform a triple store via RDF. Another which I am less >>> familiar with is to transform to graphML followed by a subsequent import >>> into some graph database tool. >>> >>> The graphical representation is desirable for processing rather than >>> visualization reasons. Chiefly I have a matching algorthim implemented in >>> XSLT which works fine but doesn't scale well, a problem that I think can be >>> solved with a graphical representation. >>> >>> I am keen to hear from my elders and betters on the subject. >>> >>> >>> >>> >>> >>> >>> >>> <title title="Amid the Workings of the Deep " year="1907"/> >>> <title title="Deux cent mille lieues sous les mers " year="1907"/> >>> <title title="Le cauchemar d'un p?cheur " year="1907"/> >>> <title title="Under the Seas " year="1907"/> >>> </alias> >>> <directors> >>> <person name="M?li?s, Georges"/> >>> </directors> >>> <genres> >>> <tag name="adventure"/> >>> <tag name="fantasy"/> >>> <tag name="sci-fi"/> >>> <tag name="short"/> >>> </genres> >>> <keywords> >>> <tag name="based-on-novel"/> >>> <tag name="dream"/> >>> <tag name="fish"/> >>> <tag name="number-in-title"/> >>> <tag name="submarine"/> >>> <tag name="undersea-monster"/> >>> <tag name="underwater"/> >>> </keywords> >>> <producers> >>> <person name="M?li?s, Georges"/> >>> </producers> >>> </movie> >>> >> >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150701/e1672655/attachment.html> From ihe.onwuka at gmail.com Sun Jul 5 00:12:19 2015 From: ihe.onwuka at gmail.com (Ihe Onwuka) Date: Sun, 5 Jul 2015 03:12:19 -0400 Subject: [xquery-talk] Izzit Bcos I is functional? Message-ID: <CALfs7+xFrkDVxphXBdgiJJyq=+Mav0hmNjqDkjoZZHdS72kjxQ@mail.gmail.com> On Thu, Jun 18, 2015 at 12:23 PM, daniela florescu <dflorescu at me.com> wrote: > > > Now contrast that with the little experiment that I was running recently: > here is the simplest statistical problem you can imagine. > > You have 3 boxes and 6 balls: 3 white and 3 back. You put the balls in the > boxes, 2 in each. I take one ball out of one box and it is black. > What is the probability that the secod ball in the same box is also black ? > > I asked this question to CTOs of data science companies, Phd in math, Phd > In CS, the head of machine learning at Google, hordes of ?data scientists?. > > Out of tens of people I asked, I got only TWO correct answers: both where > Phd in physics. (not the CTOs, not the head of machine learning..) > > I now remember arguing the equivalent problem with a Math PhD student on a long drive back from a rugby tournament while I was on study abroad. He got it wrong, easy for me to say, at the time I had just taken a probability class. This is a camouflaged version of the Monty Hall problem typically used to introduce Bayes Rule. Here it's camouflaged because what is really being asked is what is the (conditional) probability of selecting the box with 2 black balls (the door with the prize). A priori it is 1/3 but after you take out 1 black ball do your probabilities change. In Bayesian terms, have you been given information that should update your probabilistic beliefs? Alot of people go wrong by thinking that they stay the same but you have been given information that eliminates one of the possibilities (one of the doors without the prize). The next pitfall is intuiting that because you now only have 2 boxes to chose from then the probability is 1/2 or worse that the answer is 3/4 because 3 of the remaining 4 possible balls are black. But the question is really asking for a conditional probability. What is the probability that the 2 black ball box was chosen given that I have shown you that it contains at least one black ball, so you have to divide by the conditioning event - the probability of drawing a black ball. This is usually calculated using the law of total probability but we it can be intuited here as being 1/2 (3 of the 6 balls in the boxes are black). So the answer is obtained by dividing the 1/3 (the original chance of selecting the box with 2 black balls) by the conditioning event 1/2 giving 1/6...........DOH!!! .... 2/3. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150705/3fde03e0/attachment.html> From ihe.onwuka at gmail.com Sun Jul 5 02:40:59 2015 From: ihe.onwuka at gmail.com (Ihe Onwuka) Date: Sun, 5 Jul 2015 05:40:59 -0400 Subject: [xquery-talk] Izzit Bcos I is functional? In-Reply-To: <CALfs7+xFrkDVxphXBdgiJJyq=+Mav0hmNjqDkjoZZHdS72kjxQ@mail.gmail.com> References: <CALfs7+xFrkDVxphXBdgiJJyq=+Mav0hmNjqDkjoZZHdS72kjxQ@mail.gmail.com> Message-ID: <CALfs7+ztoh74K2KxRS6rODzE3=mCqODJE=0eQao+2kqzT2XxwA@mail.gmail.com> On Sun, Jul 5, 2015 at 3:12 AM, Ihe Onwuka <ihe.onwuka at gmail.com> wrote: > > On Thu, Jun 18, 2015 at 12:23 PM, daniela florescu <dflorescu at me.com> > wrote: > >> >> >> Now contrast that with the little experiment that I was running recently: >> here is the simplest statistical problem you can imagine. >> >> You have 3 boxes and 6 balls: 3 white and 3 back. You put the balls in >> the boxes, 2 in each. I take one ball out of one box and it is black. >> What is the probability that the secod ball in the same box is also black >> ? >> >> I asked this question to CTOs of data science companies, Phd in math, Phd >> In CS, the head of machine learning at Google, hordes of ?data scientists?. >> >> Out of tens of people I asked, I got only TWO correct answers: both where >> Phd in physics. (not the CTOs, not the head of machine learning..) >> >> > I now remember arguing the equivalent problem with a Math PhD student on > a long drive back from a rugby tournament while I was on study abroad. He > got it wrong, easy for me to say, at the time I had just taken a > probability class. This is a camouflaged version of the Monty Hall problem > typically used to introduce Bayes Rule. > > Here it's camouflaged because what is really being asked is what is the > (conditional) probability of selecting the box with 2 black balls (the door > with the prize). > > A priori it is 1/3 but after you take out 1 black ball do your > probabilities change. In Bayesian terms, have you been given information > that should update your probabilistic beliefs? Alot of people go wrong by > thinking that they stay the same but you have been given information that > eliminates one of the possibilities (one of the doors without the prize). > The next pitfall is intuiting that because you now only have 2 boxes to > chose from then the probability is 1/2 or worse that the answer is 3/4 > because 3 of the remaining 4 possible balls are black. > > But the question is really asking for a conditional probability. What is > the probability that the 2 black ball box was chosen given that I have > shown you that it contains at least one black ball, so you have to divide > by the conditioning event - the probability of drawing a black ball. This > is usually calculated using the law of total probability but we it can be > intuited here as being 1/2 (3 of the 6 balls in the boxes are black). > > So the answer is obtained by dividing the 1/3 (the original chance of > selecting the box with 2 black balls) by the conditioning event 1/2 giving > 1/6...........DOH!!! .... 2/3. > > Other interesting questions. If you repeat the experiment with the same box and pull out another black ball what is the probability that the other unseen ball is also black ...and how many times would you need to repeat the experiment to be 99% certain that the other ball is black. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150705/1c076a91/attachment.html> From christophe.geiser at e-smile.org Mon Jul 6 00:30:37 2015 From: christophe.geiser at e-smile.org (Christophe Geiser) Date: Mon, 6 Jul 2015 09:30:37 +0200 Subject: [xquery-talk] xquery 3.1 wishlist Message-ID: <CAJC6ZbiKp7pXF5XNjkbTPP2J+hLEHNTzLbfmWtCs32rzK4WM_g@mail.gmail.com> Dear all, Thanks Wouter for initiating this discussion. I?d like to add another feature request to the current implementation of the language : the ability to retrieve the current function being executed. I could not find a work-around for implementing this, and - now with functions being first-class citizens of the language - felt the need for this capability in some edge cases. Something like : declare function local:test($arg) { let $function := function-item() (: would return local:test#1 as function item :) return () }; Thanks and best regards, Christophe Geiser ------------------------------ Hello, I?ve been working with the recent xquery 3.1 implementation in the develop branch eXist-db. I encountered some cases that were quite hard to work around: - the lack of array:index-of() - the lack of the iterator index in arrayfor-each and related higher-order functions Perhaps someone of the workgroup is available to discuss those cases. Thanks, Wouter W.S. Hager Lagua Web Solutions http://lagua.nl ? -- <https://www.e-smile.org> <https://plus.google.com/+E-smileOrg> <https://twitter.com/esmileSolution> <https://github.com/e-smile> *Christophe Geiser*Founder of e-smile e-smile.org Never give up on a dream just because of the time it will take to accomplish it. The time will pass anyway. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150706/c0d97b13/attachment.html> From mike at saxonica.com Mon Jul 6 01:09:23 2015 From: mike at saxonica.com (Michael Kay) Date: Mon, 6 Jul 2015 09:09:23 +0100 Subject: [xquery-talk] xquery 3.1 wishlist In-Reply-To: <CAJC6ZbiKp7pXF5XNjkbTPP2J+hLEHNTzLbfmWtCs32rzK4WM_g@mail.gmail.com> References: <CAJC6ZbiKp7pXF5XNjkbTPP2J+hLEHNTzLbfmWtCs32rzK4WM_g@mail.gmail.com> Message-ID: <8EB31A24-7DBC-415E-B598-CC9B741568ED@saxonica.com> Adding capability to XQuery 3.1 at this stage will require a more convincing justification than ?I felt the need for this in some edge cases?. Are there other functional languages that offer such a feature? Michael Kay Saxonica > On 6 Jul 2015, at 08:30, Christophe Geiser <christophe.geiser at e-smile.org> wrote: > > Dear all, > Thanks Wouter for initiating this discussion. > I?d like to add another feature request to the current implementation of the language : the ability to retrieve the current function being executed. I could not find a work-around for implementing this, and - now with functions being first-class citizens of the language - felt the need for this capability in some edge cases. > Something like : > > declare function local:test($arg) { > let $function := function-item() (: would return local:test#1 as function item :) > return () > }; > Thanks and best regards, > Christophe Geiser > > Hello, > I?ve been working with the recent xquery 3.1 implementation in the develop branch eXist-db. I encountered some cases that were quite hard to work around: > the lack of array:index-of() - the lack of the iterator index in arrayfor-each and related higher-order functions > Perhaps someone of the workgroup is available to discuss those cases. > Thanks, Wouter > W.S. Hager Lagua Web Solutions http://lagua.nl <http://lagua.nl/> > -- > <https://www.e-smile.org/> > <https://plus.google.com/+E-smileOrg> <https://twitter.com/esmileSolution> <https://github.com/e-smile> > Christophe Geiser > Founder of e-smile > > e-smile.org <http://e-smile.org/> > Never give up on a dream just because of the time it will take to accomplish it. The time will pass anyway. > > _______________________________________________ > talk at 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/20150706/d7aed8b7/attachment.html> From christophe.geiser at e-smile.org Mon Jul 6 03:15:06 2015 From: christophe.geiser at e-smile.org (Christophe Geiser) Date: Mon, 6 Jul 2015 12:15:06 +0200 Subject: [xquery-talk] xquery 3.1 wishlist In-Reply-To: <8EB31A24-7DBC-415E-B598-CC9B741568ED@saxonica.com> References: <CAJC6ZbiKp7pXF5XNjkbTPP2J+hLEHNTzLbfmWtCs32rzK4WM_g@mail.gmail.com> <8EB31A24-7DBC-415E-B598-CC9B741568ED@saxonica.com> Message-ID: <CAJC6ZbgG5J5MOE=izb8YErdva2oum7jgi_TFozoFg9aWM56WrQ@mail.gmail.com> On Mon, Jul 6, 2015 at 10:09 AM, Michael Kay <mike at saxonica.com> wrote: Adding capability to XQuery 3.1 at this stage will require a more > convincing justification than ?I felt the need for this in some edge cases?. On Mon, Jul 6, 2015 at 10:40 AM, Christian Gr?n [christian.gruen at gmail.com](mailto:christian.gruen at gmail.com) <http://mailto:[christian.gruen at gmail.com](mailto:christian.gruen at gmail.com)> wrote: The function call might disappear in the evaluated code, and the > resulting expression "123 + 456" might include no reference to the > original function anymore. > Thanks Michael and Christian, Understood and agreed. I was not aware that 3.1 was so close from final and did not mean to be insistent. So far, I am not aware of other Functional languages proposing this type of feature, so consider this request as closed ; ) Best, Christophe P.S. Just to elaborate on one example ?edge case?, this the type of pattern I use for some restxq resource functions (Adam?s Retter eXist implementation). It has the advantages of attaching higher level success and error messages as metaData to resource functions. Having a function-item() function returning the current function being executed would avoid re-typing the function item local:myResourceFunction#arity when the signature of the function changes - not much more convincing as a justification ! declare %rest: ... restxq annotation for the function %msg:success('successKey', 'successMessage'), %msg:error('errorKey', 'errorMessage'), function local:myResourceFunction($args) { let $fn:= function() { let $initialCheck := loginAttemptAndOtherChecks($args) (: throw an exception if not succesfull:) let $doTheWork:= local:doTheWork($args) } return local:processResoureFunction($fn, local:myResourceFunction#arity) }; declare function local:processResourceFunction($fn, $callee ) { try { $fn(), local:retrieveSuccessMessage($callee) } catch * { local:retrieveErrorMessage($callee, $err:code, $err:description, $err:value) } }; declare function local:doTheWork() { (: do the work here, throw exceptions on errors:) }; ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150706/e204ae1f/attachment.html> From dflorescu at me.com Mon Jul 13 14:42:26 2015 From: dflorescu at me.com (daniela florescu) Date: Mon, 13 Jul 2015 14:42:26 -0700 Subject: [xquery-talk] bid data borat :-) In-Reply-To: <13D13314-EFBF-4F15-9C09-BCEDA85DDAF8@me.com> References: <13D13314-EFBF-4F15-9C09-BCEDA85DDAF8@me.com> Message-ID: <542334CE-FEBC-4835-A344-28CA39225AD0@me.com> And the most hilarious of all (sorry, could not resist?) Big Data Borat ?@BigDataBorat 4 Apr 2014 Oracle propose NoSQL standards committee, MongoDB gets board seat to ensure losing data at random become standard NoSQL behaviour > On Jul 13, 2015, at 2:30 PM, daniela florescu <dflorescu at me.com> wrote: > > > https://twitter.com/bigdataborat/status/445677373153742848 <https://twitter.com/bigdataborat/status/445677373153742848> > > https://twitter.com/bigdataborat/status/240938808806359041 <https://twitter.com/bigdataborat/status/240938808806359041> > > https://twitter.com/bigdataborat/status/306596352991830016 <https://twitter.com/bigdataborat/status/306596352991830016> > > https://twitter.com/bigdataborat/status/386123679072919552 <https://twitter.com/bigdataborat/status/386123679072919552> > > https://twitter.com/bigdataborat/status/355511037124030466 <https://twitter.com/bigdataborat/status/355511037124030466>_______________________________________________ > talk at 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/20150713/d161415b/attachment.html> From ekimber at contrext.com Thu Jul 16 07:11:31 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Thu, 16 Jul 2015 09:11:31 -0500 Subject: [xquery-talk] Empty or Null Array? Message-ID: <D1CD25C3.5EACB%ekimber@contrext.com> I'm using an array to pass values down a recursive function call chain. I noticed that, at least with BaseX but also based on my reading of the 3.1 spec, that you cannot construct an empty array. Is this correct? If so, how can one have a function where the array is effectively empty? E.g., given this function declaration: declare ns:myFunc($arg1 as xs:string+, $arg2 as array(*)?, $arg3 as xs:string) {}; How can I satisfy the second argument when in fact I have no items for the array? I tried passing in () but BaseX says "Cannot cast empty-sequence() to array(*)", which makes sense. I would expect array{} to be a valid constructor, such that array:size(array{}) = 0 is true but that does not appear to be allowed for in the 3.1 spec. What have I missed? Thanks, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com From ekimber at contrext.com Thu Jul 16 07:29:26 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Thu, 16 Jul 2015 09:29:26 -0500 Subject: [xquery-talk] Empty or Null Array? Message-ID: <D1CD2946.5EB29%ekimber@contrext.com> I do see that I can do: let $array := [()] To create an array with one member that is an empty sequence. My business problem is I need to pass an array of sequences to a recursive function, where each recursion takes the cadr of the array. When the array is empty, recursion stops. So the question is, how to determine that an array is "empty" given that an array must have at least one member. It looks like the answer is "an array is empty when the only member is an empty sequence". Is my analysis correct? Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/16/15, 9:11 AM, "Eliot Kimber" <talk-bounces at x-query.com on behalf of ekimber at contrext.com> wrote: >I'm using an array to pass values down a recursive function call chain. > >I noticed that, at least with BaseX but also based on my reading of the >3.1 spec, that you cannot construct an empty array. > >Is this correct? > >If so, how can one have a function where the array is effectively empty? >E.g., given this function declaration: > >declare ns:myFunc($arg1 as xs:string+, $arg2 as array(*)?, $arg3 as >xs:string) {}; > >How can I satisfy the second argument when in fact I have no items for the >array? > >I tried passing in () but BaseX says "Cannot cast empty-sequence() to >array(*)", which makes sense. > >I would expect array{} to be a valid constructor, such that > >array:size(array{}) = 0 is true but that does not appear to be allowed for >in the 3.1 spec. > >What have I missed? > >Thanks, > >Eliot > >---- >Eliot Kimber, Owner >Contrext, LLC >http://contrext.com > > > >_______________________________________________ >talk at x-query.com >http://x-query.com/mailman/listinfo/talk > From John.Snelson at marklogic.com Thu Jul 16 07:31:15 2015 From: John.Snelson at marklogic.com (John Snelson) Date: Thu, 16 Jul 2015 14:31:15 +0000 Subject: [xquery-talk] Empty or Null Array? In-Reply-To: <D1CD25C3.5EACB%ekimber@contrext.com> References: <D1CD25C3.5EACB%ekimber@contrext.com> Message-ID: <55A7C032.5090400@marklogic.com> Hi Eliot, The grammar allows you to use both "[]" and "array{}" to create an empty array: http://www.w3.org/TR/xpath-31/#id-arrays John On 16/07/2015 10:11, Eliot Kimber wrote: > I'm using an array to pass values down a recursive function call chain. > > I noticed that, at least with BaseX but also based on my reading of the > 3.1 spec, that you cannot construct an empty array. > > Is this correct? > > If so, how can one have a function where the array is effectively empty? > E.g., given this function declaration: > > declare ns:myFunc($arg1 as xs:string+, $arg2 as array(*)?, $arg3 as > xs:string) {}; > > How can I satisfy the second argument when in fact I have no items for the > array? > > I tried passing in () but BaseX says "Cannot cast empty-sequence() to > array(*)", which makes sense. > > I would expect array{} to be a valid constructor, such that > > array:size(array{}) = 0 is true but that does not appear to be allowed for > in the 3.1 spec. > > What have I missed? > > Thanks, > > Eliot > > ---- > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk -- John Snelson, Lead Engineer http://twitter.com/jpcs MarkLogic Corporation http://www.marklogic.com From ekimber at contrext.com Thu Jul 16 07:43:19 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Thu, 16 Jul 2015 09:43:19 -0500 Subject: [xquery-talk] Empty or Null Array? In-Reply-To: <55A7C032.5090400@marklogic.com> References: <D1CD25C3.5EACB%ekimber@contrext.com> <55A7C032.5090400@marklogic.com> Message-ID: <D1CD2CE8.5EB8E%ekimber@contrext.com> So it does--I misread the BNF diagram. The error I'm getting from BaseX appears to be something different than I thought it was, as this does work: let $array := [] return <result>{$array}</result> So it must be something accessing my empty array that is not happy with it being empty. Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/16/15, 9:31 AM, "John Snelson" <talk-bounces at x-query.com on behalf of John.Snelson at marklogic.com> wrote: >Hi Eliot, > >The grammar allows you to use both "[]" and "array{}" to create an empty >array: > >http://www.w3.org/TR/xpath-31/#id-arrays > >John > >On 16/07/2015 10:11, Eliot Kimber wrote: >> I'm using an array to pass values down a recursive function call chain. >> >> I noticed that, at least with BaseX but also based on my reading of the >> 3.1 spec, that you cannot construct an empty array. >> >> Is this correct? >> >> If so, how can one have a function where the array is effectively empty? >> E.g., given this function declaration: >> >> declare ns:myFunc($arg1 as xs:string+, $arg2 as array(*)?, $arg3 as >> xs:string) {}; >> >> How can I satisfy the second argument when in fact I have no items for >>the >> array? >> >> I tried passing in () but BaseX says "Cannot cast empty-sequence() to >> array(*)", which makes sense. >> >> I would expect array{} to be a valid constructor, such that >> >> array:size(array{}) = 0 is true but that does not appear to be allowed >>for >> in the 3.1 spec. >> >> What have I missed? >> >> Thanks, >> >> Eliot >> >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > >-- >John Snelson, Lead Engineer http://twitter.com/jpcs >MarkLogic Corporation http://www.marklogic.com > >_______________________________________________ >talk at x-query.com >http://x-query.com/mailman/listinfo/talk > From ekimber at contrext.com Thu Jul 16 07:51:47 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Thu, 16 Jul 2015 09:51:47 -0500 Subject: [xquery-talk] Empty or Null Array? In-Reply-To: <55A7C032.5090400@marklogic.com> References: <D1CD25C3.5EACB%ekimber@contrext.com> <55A7C032.5090400@marklogic.com> Message-ID: <D1CD2E0E.5EBB2%ekimber@contrext.com> I see my error: accessing a member that does not exist is a dynamic error, so: let $array := [] let $item1 := $array(1) Throws an error. I naively expected it to return an empty sequence. But upon reflection the defined behavior in the spec is correct, otherwise you wouldn't be able to distinguish the lack of a member and a member whose value is an empty sequence. So array:size($array) := 0 is the correct way to test for an empty array. It would be useful if the 3.1 spec had some examples of these cases--I'm not seeing any examples of creating an empty array in the Array Constructors section. Cheers, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/16/15, 9:31 AM, "John Snelson" <talk-bounces at x-query.com on behalf of John.Snelson at marklogic.com> wrote: >Hi Eliot, > >The grammar allows you to use both "[]" and "array{}" to create an empty >array: > >http://www.w3.org/TR/xpath-31/#id-arrays > >John > >On 16/07/2015 10:11, Eliot Kimber wrote: >> I'm using an array to pass values down a recursive function call chain. >> >> I noticed that, at least with BaseX but also based on my reading of the >> 3.1 spec, that you cannot construct an empty array. >> >> Is this correct? >> >> If so, how can one have a function where the array is effectively empty? >> E.g., given this function declaration: >> >> declare ns:myFunc($arg1 as xs:string+, $arg2 as array(*)?, $arg3 as >> xs:string) {}; >> >> How can I satisfy the second argument when in fact I have no items for >>the >> array? >> >> I tried passing in () but BaseX says "Cannot cast empty-sequence() to >> array(*)", which makes sense. >> >> I would expect array{} to be a valid constructor, such that >> >> array:size(array{}) = 0 is true but that does not appear to be allowed >>for >> in the 3.1 spec. >> >> What have I missed? >> >> Thanks, >> >> Eliot >> >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > >-- >John Snelson, Lead Engineer http://twitter.com/jpcs >MarkLogic Corporation http://www.marklogic.com > >_______________________________________________ >talk at x-query.com >http://x-query.com/mailman/listinfo/talk > From ekimber at contrext.com Fri Jul 17 06:26:50 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Fri, 17 Jul 2015 08:26:50 -0500 Subject: [xquery-talk] How to Reverse an Array Message-ID: <D1CE6CCA.60C2D%ekimber@contrext.com> I'm still getting my head around dynamic functions and arrays in XQuery 3.1. My question for today: easiest/best/most-efficient/cleverest way to reverse an array. You can't just use reverse() on an array, so how to produce a new array that is the reverse of the input array? Thanks, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com From g at 28.io Fri Jul 17 06:31:37 2015 From: g at 28.io (Ghislain Fourny) Date: Fri, 17 Jul 2015 15:31:37 +0200 Subject: [xquery-talk] How to Reverse an Array In-Reply-To: <D1CE6CCA.60C2D%ekimber@contrext.com> References: <D1CE6CCA.60C2D%ekimber@contrext.com> Message-ID: <CAPa8FbQwdQxa3i58KuoPRX=c25C4=bk+a9ixPR5CBs-pQe0_UQ@mail.gmail.com> Hi Eliot, I'd just go to the sequence space and back: array { reverse(array:flatten($array)) } Kind regards, Ghislain On Fri, Jul 17, 2015 at 3:26 PM, Eliot Kimber <ekimber at contrext.com> wrote: > I'm still getting my head around dynamic functions and arrays in XQuery > 3.1. > > My question for today: easiest/best/most-efficient/cleverest way to > reverse an array. > > You can't just use reverse() on an array, so how to produce a new array > that is the reverse of the input array? > > Thanks, > > Eliot > > ---- > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From g at 28.io Fri Jul 17 06:37:43 2015 From: g at 28.io (Ghislain Fourny) Date: Fri, 17 Jul 2015 15:37:43 +0200 Subject: [xquery-talk] How to Reverse an Array In-Reply-To: <CAPa8FbQwdQxa3i58KuoPRX=c25C4=bk+a9ixPR5CBs-pQe0_UQ@mail.gmail.com> References: <D1CE6CCA.60C2D%ekimber@contrext.com> <CAPa8FbQwdQxa3i58KuoPRX=c25C4=bk+a9ixPR5CBs-pQe0_UQ@mail.gmail.com> Message-ID: <CAPa8FbQQVqvCa2z49zUrttsm99osyGOc2PusxYu4RQOmyTjLWg@mail.gmail.com> Hi Eliot, Forget what I said: there is actually a function for this :-) array:reverse($array). http://www.w3.org/TR/xpath-functions-31/#func-array-reverse But the approach in the other query works for any other function. Kind regards, Ghislain On Fri, Jul 17, 2015 at 3:31 PM, Ghislain Fourny <g at 28.io> wrote: > Hi Eliot, > > I'd just go to the sequence space and back: > > array { reverse(array:flatten($array)) } > > Kind regards, > Ghislain > > > On Fri, Jul 17, 2015 at 3:26 PM, Eliot Kimber <ekimber at contrext.com> wrote: >> I'm still getting my head around dynamic functions and arrays in XQuery >> 3.1. >> >> My question for today: easiest/best/most-efficient/cleverest way to >> reverse an array. >> >> You can't just use reverse() on an array, so how to produce a new array >> that is the reverse of the input array? >> >> Thanks, >> >> Eliot >> >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk From ekimber at contrext.com Fri Jul 17 06:39:38 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Fri, 17 Jul 2015 08:39:38 -0500 Subject: [xquery-talk] How to Reverse an Array In-Reply-To: <55A903C1.8070004@benibela.de> References: <D1CE6CCA.60C2D%ekimber@contrext.com> <55A903C1.8070004@benibela.de> Message-ID: <D1CE6F73.60C77%ekimber@contrext.com> Ah--I missed that one--I'm bouncing between the 3.1 spec and a near-final draft of Priscilla Walmsley's updated XQuery book. Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/17/15, 8:31 AM, "Benito van der Zander" <benito at benibela.de> wrote: > >Hi Eliot, > >http://www.w3.org/TR/xpath-functions-31/#func-array-reverse > >Bye, >Benito > > >On 17.07.2015 15:26, Eliot Kimber wrote: >> I'm still getting my head around dynamic functions and arrays in XQuery >> 3.1. >> >> My question for today: easiest/best/most-efficient/cleverest way to >> reverse an array. >> >> You can't just use reverse() on an array, so how to produce a new array >> that is the reverse of the input array? >> >> Thanks, >> >> Eliot >> >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > From mike at saxonica.com Fri Jul 17 07:54:47 2015 From: mike at saxonica.com (Michael Kay) Date: Fri, 17 Jul 2015 15:54:47 +0100 Subject: [xquery-talk] How to Reverse an Array In-Reply-To: <CAPa8FbQwdQxa3i58KuoPRX=c25C4=bk+a9ixPR5CBs-pQe0_UQ@mail.gmail.com> References: <D1CE6CCA.60C2D%ekimber@contrext.com> <CAPa8FbQwdQxa3i58KuoPRX=c25C4=bk+a9ixPR5CBs-pQe0_UQ@mail.gmail.com> Message-ID: <B2EFFE70-2822-454F-AAD8-252BDB655C12@saxonica.com> > On 17 Jul 2015, at 14:31, Ghislain Fourny <g at 28.io> wrote: > > Hi Eliot, > > I'd just go to the sequence space and back: > > array { reverse(array:flatten($array)) } > That doesn?t work if the array contains sequences (of length > 1) - flattening loses the sequence boundaries. Michael Kay From graydonish at gmail.com Sat Jul 18 10:12:04 2015 From: graydonish at gmail.com (Graydon Saunders) Date: Sat, 18 Jul 2015 13:12:04 -0400 Subject: [xquery-talk] map:union function? Message-ID: <CAO3ciQEVCcf6-LN4GKo3=udzt5o0-E7kj2QAm8=BVV9S84d9PA@mail.gmail.com> Hello -- map:merge returns only the last value associated with the key of a map. Any other values are lost. Sometimes something that returns all of the values is wanted; my particular present use case is wanting to make sure I've got all the errors associated with a particular XML node when each rule returns a map using the node identifier as the key and the error code as the value, but I don't think it's hard to think of other use cases. It's certainly possible to write one's own function to do this but there's several possible approaches. A built-in could be more readily optimized by the XQuery processor. (Or at least I hope so!) So where map:merge looks like: map:merge($maps as map(*)*) as map(*) so would map:union($maps as map(*)*) as map(*) The only change would be: The supplied maps are combined as follows: 1. There is one entry in the returned map for each distinct key present in the union of the input maps, where two keys are distinct if they are not the ?same key? <http://www.w3.org/TR/xpath-functions-31/#dt-same-key>. 2. The associated value for each such key is *a sequence of values* taken from *every *map in the input sequence $input that contains an entry with this key. Would this be a useful thing to add, generall? (It would certainly be useful to me!) Thanks! Graydon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150718/57952f50/attachment.html> From mike at saxonica.com Sat Jul 18 10:59:11 2015 From: mike at saxonica.com (Michael Kay) Date: Sat, 18 Jul 2015 18:59:11 +0100 Subject: [xquery-talk] map:union function? In-Reply-To: <CAO3ciQEVCcf6-LN4GKo3=udzt5o0-E7kj2QAm8=BVV9S84d9PA@mail.gmail.com> References: <CAO3ciQEVCcf6-LN4GKo3=udzt5o0-E7kj2QAm8=BVV9S84d9PA@mail.gmail.com> Message-ID: <1116FB4F-0ED5-4EF7-BA68-DF77E1F57189@saxonica.com> I?ve certainly come across the requirement a few times. It?s not too hard to code: map:merge( for $k in distinct-values($maps!map:keys()) return map:entry($k, $maps?($k)) ) and we?re at a stage with 3.1 where there?s very little chance of getting a function added if it can be coded as a 2-liner. Michael Kay Saxonica > On 18 Jul 2015, at 18:12, Graydon Saunders <graydonish at gmail.com> wrote: > > Hello -- > > map:merge returns only the last value associated with the key of a map. Any other values are lost. > > Sometimes something that returns all of the values is wanted; my particular present use case is wanting to make sure I've got all the errors associated with a particular XML node when each rule returns a map using the node identifier as the key and the error code as the value, but I don't think it's hard to think of other use cases. > > It's certainly possible to write one's own function to do this but there's several possible approaches. A built-in could be more readily optimized by the XQuery processor. (Or at least I hope so!) > > So where map:merge looks like: > > map:merge($maps as map(*)*) as map(*) > > so would > > map:union($maps as map(*)*) as map(*) > > The only change would be: > > The supplied maps are combined as follows: > There is one entry in the returned map for each distinct key present in the union of the input maps, where two keys are distinct if they are not the ?same key? <http://www.w3.org/TR/xpath-functions-31/#dt-same-key>. > The associated value for each such key is a sequence of values taken from every map in the input sequence $input that contains an entry with this key. > Would this be a useful thing to add, generall? (It would certainly be useful to me!) > > Thanks! > Graydon > _______________________________________________ > talk at 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/20150718/e60f15b2/attachment.html> From adam.retter at googlemail.com Sun Jul 19 03:01:50 2015 From: adam.retter at googlemail.com (Adam Retter) Date: Sun, 19 Jul 2015 11:01:50 +0100 Subject: [xquery-talk] set as datatype in xquery In-Reply-To: <000c01d0c205$136203c0$3a260b40$@lijbrandt.nl> References: <000c01d0c205$136203c0$3a260b40$@lijbrandt.nl> Message-ID: <CAPK0ichF0_reJi3Tx6pidxp97F-HkS9yZt4DKKpAfTL7ZBJDNQ@mail.gmail.com> Can you tell me how you see a dataSet being different to an array? On 19 July 2015 at 10:27, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Hello, > > > > Is it an option to add a ?dataSet? as datatype in xquery, like for example > the ?array?? > > My case is that I?m having this high-order function that iterates through > a sequence and start a given function on each item until it receives back > an ?nothing?, than it breaks off. > > This works great except with sequences which I ( have to) use for > ?dataSets?: there are occasions that I need to return an empty set without > breaking of the iteration. > > In xquery there are empty arrays, empty maps and empty elements but no > empty ?dataset?, like - set {} - > > > > Thanx, > > > > Rob Stapper > > > > PS. > > - definition for ?dataset? could be something like: - a datatype > representing a dynamic collection of data-items ?. > > > > - Since the ?dataSet? is an datatype, ?dataSets? could hold other dataSets. > > - Function ?for-each? ( no particular sequence) could take a ?dataset? > but ?fold-left? and ?fold-right? ( particular sequence) could not. > > - I don?t know if a ?fold?-function ( no particular sequence) would make > sense, haven?t thought about it enough. > > > > > ------------------------------ > [image: Avast logo] <https://www.avast.com/antivirus> > > Dit e-mailbericht is gecontroleerd op virussen met Avast > antivirussoftware. > www.avast.com <https://www.avast.com/antivirus> > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150719/35bfac27/attachment.html> From adam.retter at googlemail.com Sun Jul 19 04:53:56 2015 From: adam.retter at googlemail.com (Adam Retter) Date: Sun, 19 Jul 2015 12:53:56 +0100 Subject: [xquery-talk] set as datatype in xquery In-Reply-To: <002001d0c212$bd2eb8a0$378c29e0$@lijbrandt.nl> References: <000c01d0c205$136203c0$3a260b40$@lijbrandt.nl> <CAPK0ichF0_reJi3Tx6pidxp97F-HkS9yZt4DKKpAfTL7ZBJDNQ@mail.gmail.com> <002001d0c212$bd2eb8a0$378c29e0$@lijbrandt.nl> Message-ID: <CAPK0ichnc3aRTiDROZzGqWsap+DYc96x3wSJ0V6fFhQqNia0Xw@mail.gmail.com> Okay I see what you are getting at but in light of the fact that there is not a set type, but there is an array type, could you not just use the array type with the XPath 3.1 function arrays:for-each? Regards polluting your code, you would only have that if you chose to access the array by index, instead you could just stick to for-each. Well, I see an array as a specialized dataSet. > > I see an array is an indexed, c.q. subscripted, dataset. > > Or I see a dataset is an array without the indexing-mechanism. > > Or you could also see a dataset as an map without the mapping-mechanism. > > What remains is a dynamic set with data-items where the items can > individually be processed, e.g. by a for-each function, but not > individually be addressed. > > > > Using arrays as datasets pollutes my code with its addressing mechanism. > > Especially for a function language expressiveness of the language should > be one of the highest goods. > > > > Rob > > > > *Van:* Adam Retter [mailto:adam.retter at googlemail.com] > *Verzonden:* zondag 19 juli 2015 12:02 > *Aan:* Rob Stapper > *CC:* talk at x-query.com > *Onderwerp:* Re: [xquery-talk] set as datatype in xquery > > > > Can you tell me how you see a dataSet being different to an array? > > > > On 19 July 2015 at 10:27, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > > Hello, > > > > Is it an option to add a ?dataSet? as datatype in xquery, like for example > the ?array?? > > My case is that I?m having this high-order function that iterates through > a sequence and start a given function on each item until it receives back > an ?nothing?, than it breaks off. > > This works great except with sequences which I ( have to) use for > ?dataSets?: there are occasions that I need to return an empty set without > breaking of the iteration. > > In xquery there are empty arrays, empty maps and empty elements but no > empty ?dataset?, like - set {} - > > > > Thanx, > > > > Rob Stapper > > > > PS. > > - definition for ?dataset? could be something like: - a datatype > representing a dynamic collection of data-items ?. > > > > - Since the ?dataSet? is an datatype, ?dataSets? could hold other dataSets. > > - Function ?for-each? ( no particular sequence) could take a ?dataset? > but ?fold-left? and ?fold-right? ( particular sequence) could not. > > - I don?t know if a ?fold?-function ( no particular sequence) would make > sense, haven?t thought about it enough. > > > > > ------------------------------ > > [image: Afbeelding verwijderd door afzender. Avast logo] > <https://www.avast.com/antivirus> > > Dit e-mailbericht is gecontroleerd op virussen met Avast > antivirussoftware. > www.avast.com <https://www.avast.com/antivirus> > > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > > > > > -- > > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > > > ------------------------------ > [image: Avast logo] <https://www.avast.com/antivirus> > > Dit e-mailbericht is gecontroleerd op virussen met Avast > antivirussoftware. > www.avast.com <https://www.avast.com/antivirus> > > -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150719/703c97f4/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: ~WRD000.jpg Type: image/jpeg Size: 823 bytes Desc: not available URL: <http://x-query.com/pipermail/talk/attachments/20150719/703c97f4/attachment.jpg> From r.stapper at lijbrandt.nl Sun Jul 19 06:11:00 2015 From: r.stapper at lijbrandt.nl (Rob Stapper) Date: Sun, 19 Jul 2015 15:11:00 +0200 Subject: [xquery-talk] FW: set as datatype in xquery References: <000c01d0c205$136203c0$3a260b40$@lijbrandt.nl> <CAPK0ichF0_reJi3Tx6pidxp97F-HkS9yZt4DKKpAfTL7ZBJDNQ@mail.gmail.com> <002001d0c212$bd2eb8a0$378c29e0$@lijbrandt.nl> <CAPK0ichnc3aRTiDROZzGqWsap+DYc96x3wSJ0V6fFhQqNia0Xw@mail.gmail.com> Message-ID: <003501d0c224$5bb1bb10$13153130$@lijbrandt.nl> Van: Rob Stapper [mailto:r.stapper at lijbrandt.nl] Verzonden: zondag 19 juli 2015 15:10 Aan: 'Adam Retter' Onderwerp: RE: [xquery-talk] set as datatype in xquery Sure I can do that because after all an array is a glorified dataset. But I won?t J. Question is: does the W3C as a standardization-organization, want its product to settle for a workaround like that? Van: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] Namens Adam Retter Verzonden: zondag 19 juli 2015 13:54 Aan: Rob Stapper CC: talk at x-query.com Onderwerp: Re: [xquery-talk] set as datatype in xquery Okay I see what you are getting at but in light of the fact that there is not a set type, but there is an array type, could you not just use the array type with the XPath 3.1 function arrays:for-each? Regards polluting your code, you would only have that if you chose to access the array by index, instead you could just stick to for-each. Well, I see an array as a specialized dataSet. I see an array is an indexed, c.q. subscripted, dataset. Or I see a dataset is an array without the indexing-mechanism. Or you could also see a dataset as an map without the mapping-mechanism. What remains is a dynamic set with data-items where the items can individually be processed, e.g. by a for-each function, but not individually be addressed. Using arrays as datasets pollutes my code with its addressing mechanism. Especially for a function language expressiveness of the language should be one of the highest goods. Rob Van: Adam Retter [mailto:adam.retter at googlemail.com] Verzonden: zondag 19 juli 2015 12:02 Aan: Rob Stapper CC: talk at x-query.com Onderwerp: Re: [xquery-talk] set as datatype in xquery Can you tell me how you see a dataSet being different to an array? On 19 July 2015 at 10:27, Rob Stapper <r.stapper at lijbrandt.nl> wrote: Hello, Is it an option to add a ?dataSet? as datatype in xquery, like for example the ?array?? My case is that I?m having this high-order function that iterates through a sequence and start a given function on each item until it receives back an ?nothing?, than it breaks off. This works great except with sequences which I ( have to) use for ?dataSets?: there are occasions that I need to return an empty set without breaking of the iteration. In xquery there are empty arrays, empty maps and empty elements but no empty ?dataset?, like - set {} - Thanx, Rob Stapper PS. - definition for ?dataset? could be something like: - a datatype representing a dynamic collection of data-items ?. - Since the ?dataSet? is an datatype, ?dataSets? could hold other dataSets. - Function ?for-each? ( no particular sequence) could take a ?dataset? but ?fold-left? and ?fold-right? ( particular sequence) could not. - I don?t know if a ?fold?-function ( no particular sequence) would make sense, haven?t thought about it enough. _____ <https://www.avast.com/antivirus> Afbeelding verwijderd door afzender. Avast logo Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. www.avast.com <https://www.avast.com/antivirus> _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk _____ <https://www.avast.com/antivirus> Afbeelding verwijderd door afzender. Avast logo Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. www.avast.com <https://www.avast.com/antivirus> -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150719/2b516c60/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/jpeg Size: 823 bytes Desc: not available URL: <http://x-query.com/pipermail/talk/attachments/20150719/2b516c60/attachment.jpe> From mike at saxonica.com Sun Jul 19 06:35:38 2015 From: mike at saxonica.com (Michael Kay) Date: Sun, 19 Jul 2015 14:35:38 +0100 Subject: [xquery-talk] set as datatype in xquery In-Reply-To: <003501d0c224$5bb1bb10$13153130$@lijbrandt.nl> References: <000c01d0c205$136203c0$3a260b40$@lijbrandt.nl> <CAPK0ichF0_reJi3Tx6pidxp97F-HkS9yZt4DKKpAfTL7ZBJDNQ@mail.gmail.com> <002001d0c212$bd2eb8a0$378c29e0$@lijbrandt.nl> <CAPK0ichnc3aRTiDROZzGqWsap+DYc96x3wSJ0V6fFhQqNia0Xw@mail.gmail.com> <003501d0c224$5bb1bb10$13153130$@lijbrandt.nl> Message-ID: <4EC5E212-BEAF-49F4-B001-CE2CB8D08C38@saxonica.com> > > Sure I can do that because after all an array is a glorified dataset. But I won?t J. > Question is: does the W3C as a standardization-organization, want its product to settle for a workaround like that? > The answer is yes. If we still had 40 people taking an active part in the development process, we would probably be more ambitious. But it?s down to a handful, and you have to set your work programme so it can be achieved with the resources available. Remember the work is not done by W3C as some faceless entity, it is done by individuals whose work is in some cases funded by their companies and in some cases entirely voluntary. If you want to know why they aren?t doing this work, first ask why you aren?t doing it. Adding arrays to the data model was in many ways a kludge. We would have much preferred to have done a generic collection capability where operations like FLWOR expressions applied to any kind of collection, rather than each kind of collection having its own functions and operators. But it was too hard and too disruptive, so we settled for doing it as a bolt-on. Without the underpinnings of a generic collections framework in the language, we certainly wouldn?t want to add more ad-hoc collection types. Michael Kay Saxonica -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150719/982c0bef/attachment.html> From ekimber at contrext.com Sun Jul 19 07:33:16 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Sun, 19 Jul 2015 09:33:16 -0500 Subject: [xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type Message-ID: <D1D11F5C.61091%ekimber@contrext.com> Given this starting document: Let $doc := <root> <a id="a1"> <b>b1</b> <b>b2</b> <c> <b>b6</b> </c> <a id="a2"> <b>b3</b> <b>b4</b> <a id="a3"> <b>b5</b> </a> </a> </a> </root> I want to find all the <b> elements descending from <a id="a1"> but not within nested <a> elements: <b>b1</b> <b>b2</b> <b>b6</b> This gives me the correct answer: let $a1 := $doc/a let $bsInA1 := $a1//b[not(./ancestor::a = ($a1//a))] My question: With Xpath 3.1, is there a better way to express this query? I looked at the new outermost() and innermost() operators but I didn't see a way to apply them to this problem. Thanks, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com From gkholman at CraneSoftwrights.com Sun Jul 19 08:09:37 2015 From: gkholman at CraneSoftwrights.com (G. Ken Holman) Date: Sun, 19 Jul 2015 08:09:37 -0700 Subject: [xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type In-Reply-To: <D1D11F5C.61091%ekimber@contrext.com> References: <D1D11F5C.61091%ekimber@contrext.com> Message-ID: <7.0.1.0.2.20150719080901.0232fa08@wheresmymailserver.com> How about: $a1//b except $a1//a//b . . . . . . Ken At 2015-07-19 06:33 -0500, Eliot Kimber wrote: >Given this starting document: > >Let $doc := ><root> ><a id="a1"> > <b>b1</b> > <b>b2</b> > <c> > <b>b6</b> > </c> > <a id="a2"> > <b>b3</b> > <b>b4</b> > <a id="a3"> > <b>b5</b> > </a> > </a> > </a> > </root> > >I want to find all the <b> elements descending from <a id="a1"> but not >within nested <a> elements: > ><b>b1</b> > <b>b2</b> > <b>b6</b> > > >This gives me the correct answer: > > >let $a1 := $doc/a >let $bsInA1 := $a1//b[not(./ancestor::a = ($a1//a))] > > >My question: With Xpath 3.1, is there a better way to express this query? >I looked at the new outermost() and innermost() operators but I didn't see >a way to apply them to this problem. > >Thanks, > >Eliot > >---- >Eliot Kimber, Owner >Contrext, LLC >http://contrext.com > > > >_______________________________________________ >talk at x-query.com >http://x-query.com/mailman/listinfo/talk -- Check our site for free XML, XSLT, XSL-FO and UBL developer resources | Free 5-hour lecture: http://www.CraneSoftwrights.com/links/video.htm | Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ | G. Ken Holman mailto:gkholman at CraneSoftwrights.com | Google+ profile: http://plus.google.com/+GKenHolman-Crane/about | Legal business disclaimers: http://www.CraneSoftwrights.com/legal | --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From ekimber at contrext.com Sun Jul 19 08:12:15 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Sun, 19 Jul 2015 10:12:15 -0500 Subject: [xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type In-Reply-To: <7.0.1.0.2.20150719080901.0232fa08@wheresmymailserver.com> References: <D1D11F5C.61091%ekimber@contrext.com> <7.0.1.0.2.20150719080901.0232fa08@wheresmymailserver.com> Message-ID: <D1D12838.610E4%ekimber@contrext.com> That seems to easy Ken. In terms of processing optimization, is there any reason to prefer one formulation over the other (meaning, is it possible to predict how XPath processors will be able to optimize this type of expression)? Thanks, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/19/15, 10:09 AM, "G. Ken Holman" <talk-bounces at x-query.com on behalf of gkholman at cranesoftwrights.com> wrote: >How about: > > $a1//b except $a1//a//b > >. . . . . . Ken > >At 2015-07-19 06:33 -0500, Eliot Kimber wrote: >>Given this starting document: >> >>Let $doc := >><root> >><a id="a1"> >> <b>b1</b> >> <b>b2</b> >> <c> >> <b>b6</b> >> </c> >> <a id="a2"> >> <b>b3</b> >> <b>b4</b> >> <a id="a3"> >> <b>b5</b> >> </a> >> </a> >> </a> >> </root> >> >>I want to find all the <b> elements descending from <a id="a1"> but not >>within nested <a> elements: >> >><b>b1</b> >> <b>b2</b> >> <b>b6</b> >> >> >>This gives me the correct answer: >> >> >>let $a1 := $doc/a >>let $bsInA1 := $a1//b[not(./ancestor::a = ($a1//a))] >> >> >>My question: With Xpath 3.1, is there a better way to express this query? >>I looked at the new outermost() and innermost() operators but I didn't >>see >>a way to apply them to this problem. >> >>Thanks, >> >>Eliot >> >>---- >>Eliot Kimber, Owner >>Contrext, LLC >>http://contrext.com >> >> >> >>_______________________________________________ >>talk at x-query.com >>http://x-query.com/mailman/listinfo/talk > > >-- >Check our site for free XML, XSLT, XSL-FO and UBL developer resources | >Free 5-hour lecture: http://www.CraneSoftwrights.com/links/video.htm | >Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ | >G. Ken Holman mailto:gkholman at CraneSoftwrights.com | >Google+ profile: http://plus.google.com/+GKenHolman-Crane/about | >Legal business disclaimers: http://www.CraneSoftwrights.com/legal | > > >--- >This email has been checked for viruses by Avast antivirus software. >https://www.avast.com/antivirus > >_______________________________________________ >talk at x-query.com >http://x-query.com/mailman/listinfo/talk > From mike at saxonica.com Sun Jul 19 08:31:24 2015 From: mike at saxonica.com (Michael Kay) Date: Sun, 19 Jul 2015 16:31:24 +0100 Subject: [xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type In-Reply-To: <D1D12838.610E4%ekimber@contrext.com> References: <D1D11F5C.61091%ekimber@contrext.com> <7.0.1.0.2.20150719080901.0232fa08@wheresmymailserver.com> <D1D12838.610E4%ekimber@contrext.com> Message-ID: <23D5EAE0-9D31-4321-BD58-51F08DAC9056@saxonica.com> > On 19 Jul 2015, at 16:12, Eliot Kimber <ekimber at contrext.com> wrote: > > That seems to easy Ken. > > In terms of processing optimization, is there any reason to prefer one > formulation over the other (meaning, is it possible to predict how XPath > processors will be able to optimize this type of expression)? > No, it?s not really possible to predict. Both are amenable to optimization, but there?s a law of diminishing returns in what it?s worth attempting. Saxon will do both pretty much as written. Saxon did at one time attempt to rewrite a/b/c/X except a/b/c/Y as a/b/c/(X except Y) but I found it was unsound, which taught me a lesson. (I forget the actual case that demonstrates this.) I still find it very hard to know how to prove which rewrites are sound and which aren?t. Michael Kay Saxonica From ekimber at contrext.com Sun Jul 19 08:40:22 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Sun, 19 Jul 2015 10:40:22 -0500 Subject: [xquery-talk] Manipulating Maps In Non-Trivial Ways Message-ID: <D1D12F16.6116F%ekimber@contrext.com> I don't know why I'm having such a hard time figuring out how to operate on maps but I just can't get my head around it (I suspect procedural brain damage but it could just be advancing age). I suspect others will or are having the same challenge. My challenge of the day is: I have an existing map where each entry is a sequence mapped to a string key, e.g.: let $m1 := map{ 'key1' : (), 'key2' : () } I then have a node and a set of key values. For each key I need to find the entry with that key and add the node to the entry, e.g. let $newKeys := ('key1', 'key3') let $obj := <added/> Let $m2 := for $key in $newKeys (: Find sequence for key, Add obj to sequence, Update map entry for new key :) I think the right answer is to use map:merge like so: let $m2 := map:merge( $m1, lor $key in $newKeys Map {$key, ($m1($key), $obj))} ) Is my analysis correct? Is there a better way to do this sort of map updating? Thanks, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com From christian.gruen at gmail.com Sun Jul 19 08:42:25 2015 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Sun, 19 Jul 2015 17:42:25 +0200 Subject: [xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type In-Reply-To: <D1D12838.610E4%ekimber@contrext.com> References: <D1D11F5C.61091%ekimber@contrext.com> <7.0.1.0.2.20150719080901.0232fa08@wheresmymailserver.com> <D1D12838.610E4%ekimber@contrext.com> Message-ID: <CAP94bnMV3_eKr6GnRqMUYrv6K3AOEj-SBjho26DRVC6Q4M6i9g@mail.gmail.com> Hi Eliot, > In terms of processing optimization, is there any reason to prefer one > formulation over the other (meaning, is it possible to predict how XPath > processors will be able to optimize this type of expression)? I like Ken's solution, but mostly because it's more concise. You will never know what a specific implementation does, or what it will do in a future version. It also depends on your data: If you have deep document structures, the ancestor step may get more expensive. Just create some gigabytes of test data and do some simple testing with the processors of your choice. However, your original query may be evaluated faster by some processors if you move the path expression out of the predicate and bind it to an additional variable: let $a1 := $doc/a let $a2 := $a1//a let $bsInA1 := $a1//b[not(ancestor::a = $a2)] Cheers, Christian From ekimber at contrext.com Sun Jul 19 09:08:16 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Sun, 19 Jul 2015 11:08:16 -0500 Subject: [xquery-talk] Manipulating Maps In Non-Trivial Ways Message-ID: <D1D134F2.611DA%ekimber@contrext.com> Just realized that map:merge() takes a *sequence* of maps, so this is wrong: map:merge($m1, $m2) But this is correct: map:merge(($m1, $m2)) That clear in the spec examples (and of course in the function signature) but it still surprised me because I wasn't paying close attention and assumed the signature was (map1, map2). So my examples below need an addition set of parens around the values with map:merge() calls. Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/19/15, 10:40 AM, "Eliot Kimber" <talk-bounces at x-query.com on behalf of ekimber at contrext.com> wrote: >I don't know why I'm having such a hard time figuring out how to operate >on maps but I just can't get my head around it (I suspect procedural brain >damage but it could just be advancing age). I suspect others will or are >having the same challenge. > >My challenge of the day is: > >I have an existing map where each entry is a sequence mapped to a string >key, e.g.: > >let $m1 := map{ 'key1' : (), 'key2' : () } > >I then have a node and a set of key values. For each key I need to find >the entry with that key and add the node to the entry, e.g. > >let $newKeys := ('key1', 'key3') >let $obj := <added/> > >Let $m2 := for $key in $newKeys > (: Find sequence for key, > Add obj to sequence, > Update map entry for new key > :) > >I think the right answer is to use map:merge like so: > >let $m2 := > map:merge( > $m1, > lor $key in $newKeys > Map {$key, ($m1($key), $obj))} > ) > >Is my analysis correct? Is there a better way to do this sort of map >updating? > >Thanks, > >Eliot >---- >Eliot Kimber, Owner >Contrext, LLC >http://contrext.com > > > >_______________________________________________ >talk at x-query.com >http://x-query.com/mailman/listinfo/talk > From mike at saxonica.com Sun Jul 19 10:38:05 2015 From: mike at saxonica.com (Michael Kay) Date: Sun, 19 Jul 2015 18:38:05 +0100 Subject: [xquery-talk] Manipulating Maps In Non-Trivial Ways In-Reply-To: <D1D12F16.6116F%ekimber@contrext.com> References: <D1D12F16.6116F%ekimber@contrext.com> Message-ID: <6009DC5E-A222-4C16-951F-3B71FBCE51F8@saxonica.com> A fold can sometimes be useful for this kind of operation: $newKeys => fold-left($m1, function($key, $map) { $map => map:put($key, ($map($key), $obj) }) Also, appending an item to the value for a key is a sufficiently common operation it?s worth having a function for it: declare function f:map-add($map, $key, $value) as map(*) { map:put($map, $key, ($map($key), $value)) } and then the fold becomes $newKeys => fold-left($m1, function($key, $map) {$map => f:add($key, $obj)}) But it takes a while before folds become intuitive. map:merge works equally well. Michael Kay Saxonica > On 19 Jul 2015, at 16:40, Eliot Kimber <ekimber at contrext.com> wrote: > > I don't know why I'm having such a hard time figuring out how to operate > on maps but I just can't get my head around it (I suspect procedural brain > damage but it could just be advancing age). I suspect others will or are > having the same challenge. > > My challenge of the day is: > > I have an existing map where each entry is a sequence mapped to a string > key, e.g.: > > let $m1 := map{ 'key1' : (), 'key2' : () } > > I then have a node and a set of key values. For each key I need to find > the entry with that key and add the node to the entry, e.g. > > let $newKeys := ('key1', 'key3') > let $obj := <added/> > > Let $m2 := for $key in $newKeys > (: Find sequence for key, > Add obj to sequence, > Update map entry for new key > :) > > I think the right answer is to use map:merge like so: > > let $m2 := > map:merge( > $m1, > lor $key in $newKeys > Map {$key, ($m1($key), $obj))} > ) > > Is my analysis correct? Is there a better way to do this sort of map > updating? > > Thanks, > > Eliot > ---- > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From r.stapper at lijbrandt.nl Sun Jul 19 10:47:22 2015 From: r.stapper at lijbrandt.nl (Rob Stapper) Date: Sun, 19 Jul 2015 19:47:22 +0200 Subject: [xquery-talk] set as datatype in xquery In-Reply-To: <4EC5E212-BEAF-49F4-B001-CE2CB8D08C38@saxonica.com> References: <000c01d0c205$136203c0$3a260b40$@lijbrandt.nl> <CAPK0ichF0_reJi3Tx6pidxp97F-HkS9yZt4DKKpAfTL7ZBJDNQ@mail.gmail.com> <002001d0c212$bd2eb8a0$378c29e0$@lijbrandt.nl> <CAPK0ichnc3aRTiDROZzGqWsap+DYc96x3wSJ0V6fFhQqNia0Xw@mail.gmail.com> <003501d0c224$5bb1bb10$13153130$@lijbrandt.nl> <4EC5E212-BEAF-49F4-B001-CE2CB8D08C38@saxonica.com> Message-ID: <004a01d0c24a$f7aa83a0$e6ff8ae0$@lijbrandt.nl> That?s clear. I?m doing my work which is based on the results of the work done by W3C, also partly funded, partly voluntary. We can?t be all working on the same subject. I hoped that since the specifications of the array is an extension of those of the dataset, the implementation would be a quick win and not so much of a kludge. If the choose is between another ad-hoc implementation of a collection type, which in itself isn?t ad hoc, or the suggested workaround I also would offer the workaround. Until the framework is ready for generic collection types and the dataset hopefully will be implemented, I?ll be using my own work-around.( no array anyway J) One could perhaps make a start with the specifications of the dataset. Rob Stapper Van: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] Namens Michael Kay Verzonden: zondag 19 juli 2015 15:36 Aan: Rob Stapper CC: talk at x-query.com Onderwerp: Re: [xquery-talk] set as datatype in xquery Sure I can do that because after all an array is a glorified dataset. But I won?t J. Question is: does the W3C as a standardization-organization, want its product to settle for a workaround like that? The answer is yes. If we still had 40 people taking an active part in the development process, we would probably be more ambitious. But it?s down to a handful, and you have to set your work programme so it can be achieved with the resources available. Remember the work is not done by W3C as some faceless entity, it is done by individuals whose work is in some cases funded by their companies and in some cases entirely voluntary. If you want to know why they aren?t doing this work, first ask why you aren?t doing it. Adding arrays to the data model was in many ways a kludge. We would have much preferred to have done a generic collection capability where operations like FLWOR expressions applied to any kind of collection, rather than each kind of collection having its own functions and operators. But it was too hard and too disruptive, so we settled for doing it as a bolt-on. Without the underpinnings of a generic collections framework in the language, we certainly wouldn?t want to add more ad-hoc collection types. Michael Kay Saxonica --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150719/0ab3dddc/attachment.html> From ekimber at contrext.com Sun Jul 19 14:55:28 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Sun, 19 Jul 2015 16:55:28 -0500 Subject: [xquery-talk] Manipulating Maps In Non-Trivial Ways In-Reply-To: <6009DC5E-A222-4C16-951F-3B71FBCE51F8@saxonica.com> References: <D1D12F16.6116F%ekimber@contrext.com> <6009DC5E-A222-4C16-951F-3B71FBCE51F8@saxonica.com> Message-ID: <D1D186C3.61761%ekimber@contrext.com> Yes, the fold operations are still a bit too clever for my taste--I prefer to make my business a logic a little more verbose to clearer, at least to me--I don't want to have to think too deeply when I'm programming :-) Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/19/15, 12:38 PM, "Michael Kay" <mike at saxonica.com> wrote: >A fold can sometimes be useful for this kind of operation: > >$newKeys => fold-left($m1, function($key, $map) { $map => map:put($key, >($map($key), $obj) }) > >Also, appending an item to the value for a key is a sufficiently common >operation it?s worth having a function for it: > >declare function f:map-add($map, $key, $value) as map(*) { > map:put($map, $key, ($map($key), $value)) >} > >and then the fold becomes > >$newKeys => fold-left($m1, function($key, $map) {$map => f:add($key, >$obj)}) > >But it takes a while before folds become intuitive. map:merge works >equally well. > >Michael Kay >Saxonica > >> On 19 Jul 2015, at 16:40, Eliot Kimber <ekimber at contrext.com> wrote: >> >> I don't know why I'm having such a hard time figuring out how to operate >> on maps but I just can't get my head around it (I suspect procedural >>brain >> damage but it could just be advancing age). I suspect others will or are >> having the same challenge. >> >> My challenge of the day is: >> >> I have an existing map where each entry is a sequence mapped to a string >> key, e.g.: >> >> let $m1 := map{ 'key1' : (), 'key2' : () } >> >> I then have a node and a set of key values. For each key I need to find >> the entry with that key and add the node to the entry, e.g. >> >> let $newKeys := ('key1', 'key3') >> let $obj := <added/> >> >> Let $m2 := for $key in $newKeys >> (: Find sequence for key, >> Add obj to sequence, >> Update map entry for new key >> :) >> >> I think the right answer is to use map:merge like so: >> >> let $m2 := >> map:merge( >> $m1, >> lor $key in $newKeys >> Map {$key, ($m1($key), $obj))} >> ) >> >> Is my analysis correct? Is there a better way to do this sort of map >> updating? >> >> Thanks, >> >> Eliot >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > From gkholman at CraneSoftwrights.com Sun Jul 19 17:01:25 2015 From: gkholman at CraneSoftwrights.com (G. Ken Holman) Date: Sun, 19 Jul 2015 17:01:25 -0700 Subject: [xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type In-Reply-To: <D1D12838.610E4%ekimber@contrext.com> References: <D1D11F5C.61091%ekimber@contrext.com> <7.0.1.0.2.20150719080901.0232fa08@wheresmymailserver.com> <D1D12838.610E4%ekimber@contrext.com> Message-ID: <7.0.1.0.2.20150719165725.022573b0@wheresmymailserver.com> At 2015-07-19 10:12 -0500, Eliot Kimber wrote: >That seems to easy Ken. >... >On 7/19/15, 10:09 AM, "G. Ken Holman" <talk-bounces at x-query.com on behalf >of gkholman at cranesoftwrights.com> wrote: >... > > $a1//b except $a1//a//b Perhaps, but you were the one that put that expression in words and I just transliterated it: >At 2015-07-19 06:33 -0500, Eliot Kimber wrote: >I want to find all the <b> elements descending from <a id="a1"> but not >within nested <a> elements I see others have commented on the performance of this. I think the maintenance of what I've written is easier than trying to grok the application of the ancestor axis. . . . . . . . Ken -- Check our site for free XML, XSLT, XSL-FO and UBL developer resources | Free 5-hour lecture: http://www.CraneSoftwrights.com/links/video.htm | Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ | G. Ken Holman mailto:gkholman at CraneSoftwrights.com | Google+ profile: http://plus.google.com/+GKenHolman-Crane/about | Legal business disclaimers: http://www.CraneSoftwrights.com/legal | --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From g at 28.io Mon Jul 20 01:57:25 2015 From: g at 28.io (Ghislain Fourny) Date: Mon, 20 Jul 2015 10:57:25 +0200 Subject: [xquery-talk] How to Reverse an Array In-Reply-To: <B2EFFE70-2822-454F-AAD8-252BDB655C12@saxonica.com> References: <D1CE6CCA.60C2D%ekimber@contrext.com> <CAPa8FbQwdQxa3i58KuoPRX=c25C4=bk+a9ixPR5CBs-pQe0_UQ@mail.gmail.com> <B2EFFE70-2822-454F-AAD8-252BDB655C12@saxonica.com> Message-ID: <CAPa8FbQXWtMOkBy2HL_on55W7KRpZbjZToyioOZovtTM3QXAtg@mail.gmail.com> Hi Mike, Ah yes, it makes sense. Thanks for correcting me. This is likely to be the reason why there is an array:reverse function in the first place. I still had the JSONiq mindset where array members are single items. :-) Kind regards, Ghislain On Fri, Jul 17, 2015 at 4:54 PM, Michael Kay <mike at saxonica.com> wrote: > >> On 17 Jul 2015, at 14:31, Ghislain Fourny <g at 28.io> wrote: >> >> Hi Eliot, >> >> I'd just go to the sequence space and back: >> >> array { reverse(array:flatten($array)) } >> > > That doesn?t work if the array contains sequences (of length > 1) - flattening loses the sequence boundaries. > > Michael Kay > From mike at saxonica.com Mon Jul 20 11:35:07 2015 From: mike at saxonica.com (Michael Kay) Date: Mon, 20 Jul 2015 19:35:07 +0100 Subject: [xquery-talk] Manipulating Maps In Non-Trivial Ways In-Reply-To: <D1D186C3.61761%ekimber@contrext.com> References: <D1D12F16.6116F%ekimber@contrext.com> <6009DC5E-A222-4C16-951F-3B71FBCE51F8@saxonica.com> <D1D186C3.61761%ekimber@contrext.com> Message-ID: <6B88C103-F1AB-459E-85EF-AB965426E1A5@saxonica.com> > On 19 Jul 2015, at 22:55, Eliot Kimber <ekimber at contrext.com> wrote: > > Yes, the fold operations are still a bit too clever for my taste--I prefer > to make my business a logic a little more verbose to clearer, at least to > me--I don't want to have to think too deeply when I'm programming :-) > Although I say it myself, I think the xsl:iterate instruction in XSLT 3.0, which is essentially syntactic sugar over a fold operation, addresses the readability problem quite well: > $newKeys => fold-left($m1, function($key, $map) { $map => map:put($key, > ($map($key), $obj) }) becomes <xsl:iterate select=?$newKeys?> <xsl:param name=?map? select=?$m1?/> <xsl:on-completion select=?$map?/> <xsl:next-iteration> <xsl:with-param name=?map? select=?map:put($map, ., ($map(.), $obj))?/> </xsl:next-iteration> </xsl:iterate> Michael Kay Saxonica From ekimber at contrext.com Mon Jul 20 11:44:21 2015 From: ekimber at contrext.com (Eliot Kimber) Date: Mon, 20 Jul 2015 13:44:21 -0500 Subject: [xquery-talk] Manipulating Maps In Non-Trivial Ways In-Reply-To: <6B88C103-F1AB-459E-85EF-AB965426E1A5@saxonica.com> References: <D1D12F16.6116F%ekimber@contrext.com> <6009DC5E-A222-4C16-951F-3B71FBCE51F8@saxonica.com> <D1D186C3.61761%ekimber@contrext.com> <6B88C103-F1AB-459E-85EF-AB965426E1A5@saxonica.com> Message-ID: <D1D2AB33.62D91%ekimber@contrext.com> Hmm, I'll have to think about that one. In the context of XQuery I don't see how it's different from a FOR expression inside map:merge(). In XSLT I can see the value because you might be applying templates or something else you can't do directly in an XPath expression. Cheers, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/20/15, 1:35 PM, "Michael Kay" <mike at saxonica.com> wrote: > >> On 19 Jul 2015, at 22:55, Eliot Kimber <ekimber at contrext.com> wrote: >> >> Yes, the fold operations are still a bit too clever for my taste--I >>prefer >> to make my business a logic a little more verbose to clearer, at least >>to >> me--I don't want to have to think too deeply when I'm programming :-) >> > >Although I say it myself, I think the xsl:iterate instruction in XSLT >3.0, which is essentially syntactic sugar over a fold operation, >addresses the readability problem quite well: > >> $newKeys => fold-left($m1, function($key, $map) { $map => map:put($key, >> ($map($key), $obj) }) > >becomes > ><xsl:iterate select=?$newKeys?> > <xsl:param name=?map? select=?$m1?/> > <xsl:on-completion select=?$map?/> > <xsl:next-iteration> > <xsl:with-param name=?map? select=?map:put($map, ., ($map(.), >$obj))?/> > </xsl:next-iteration> ></xsl:iterate> > >Michael Kay >Saxonica > > From g at 28.io Thu Jul 23 07:56:05 2015 From: g at 28.io (Ghislain Fourny) Date: Thu, 23 Jul 2015 16:56:05 +0200 Subject: [xquery-talk] annotations in function-declarations In-Reply-To: <000901d0c556$d8d45dc0$8a7d1940$@lijbrandt.nl> References: <000901d0c556$d8d45dc0$8a7d1940$@lijbrandt.nl> Message-ID: <CAPa8FbRiftNir4zhwXbckVPW_DaZz4ox1W_SCpEZetHMc7-EbA@mail.gmail.com> Hi Rob, Just off the top of my mind, I would expect some challenges with respect to dynamically vs. statically known information. With a literal, all annotations are known statically. With a variable, this is no longer the case. This may have unexpected implications for function type checking, etc. I hope it makes sense. Kind regards, Ghislain On Thu, Jul 23, 2015 at 4:49 PM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Hi, > > > > Is it possible that in a nearby release of the XQUERY-standard the > parameters of the annotations in function-declarations can also hold > string-variables? > > > > e.g. > > ? declare %myAnnotation( $annotationValue) function f ( ){()} ; > > ? instead of: declare %myAnnotation( ?myLiteral?) function f ( > ){()} ; > > ? > > > > My use-case is that I want to be able to check some of my functions for > specific properties during processing. > > > > - it would be nice if the source of the annotationValue at > function-creation could be the same as at function-checking, e.g. > > ? declare variable $annotationValue := ?testValue? ; > > ? declare %myAnnotation( $annotationValue) function f( ){()} ; > > ? declare function test( $f, $annotationValue){ ?..test > annotation:%myAnnotation of function( $f) for value: $annotationValue?..} ; > > ? ????.. test( $myFunction, $myTestValue) ??.. > > > > - another, more important point is that the constructor-function for these > annotated functions can be called from different places in my program with > different values. So actually function-creation is also during processing. > > > > Is this something that W3C sees as a useful enough addition and is it > feasible within the given capacity? > > > > Thanks in advance, > > Rob Stapper > > > ------------------------------ > [image: Avast logo] <https://www.avast.com/antivirus> > > Dit e-mailbericht is gecontroleerd op virussen met Avast > antivirussoftware. > www.avast.com <https://www.avast.com/antivirus> > > > _______________________________________________ > talk at 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/20150723/45b0802d/attachment.html> From r.stapper at lijbrandt.nl Thu Jul 23 09:12:46 2015 From: r.stapper at lijbrandt.nl (Rob Stapper) Date: Thu, 23 Jul 2015 18:12:46 +0200 Subject: [xquery-talk] FW: annotations in function-declarations References: <000901d0c556$d8d45dc0$8a7d1940$@lijbrandt.nl> <CAPa8FbRiftNir4zhwXbckVPW_DaZz4ox1W_SCpEZetHMc7-EbA@mail.gmail.com> Message-ID: <003601d0c562$69aaea20$3d00be60$@lijbrandt.nl> Always forget to reply to all. Van: Rob Stapper [mailto:r.stapper at lijbrandt.nl] Verzonden: donderdag 23 juli 2015 17:33 Aan: 'Ghislain Fourny' Onderwerp: RE: [xquery-talk] annotations in function-declarations Hello Ghislain, That sure makes sense, I?ve thought about that too. On the other hand the following construction is completely legal and the annotated-function is dynamically created: ? declare function mySpace:constructor( $a, $b, ?.) { %myAnnotation( ?wishThisWasAvariable-InsteadOfAliteralValue?) function ( $f ){$f( $a, $b, ??..)} } ; The function and probably so also its annotation is created dynamically. So it needs a little feasibility-study . Is there room for a little feasibility-study ;-) ( I know capacity) Kind Regards, Rob Van: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] Namens Ghislain Fourny Verzonden: donderdag 23 juli 2015 16:56 Aan: Rob Stapper CC: talk at x-query.com Onderwerp: Re: [xquery-talk] annotations in function-declarations Hi Rob, Just off the top of my mind, I would expect some challenges with respect to dynamically vs. statically known information. With a literal, all annotations are known statically. With a variable, this is no longer the case. This may have unexpected implications for function type checking, etc. I hope it makes sense. Kind regards, Ghislain On Thu, Jul 23, 2015 at 4:49 PM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: Hi, Is it possible that in a nearby release of the XQUERY-standard the parameters of the annotations in function-declarations can also hold string-variables? e.g. ? declare %myAnnotation( $annotationValue) function f ( ){()} ; ? instead of: declare %myAnnotation( ?myLiteral?) function f ( ){()} ; ? My use-case is that I want to be able to check some of my functions for specific properties during processing. - it would be nice if the source of the annotationValue at function-creation could be the same as at function-checking, e.g. ? declare variable $annotationValue := ?testValue? ; ? declare %myAnnotation( $annotationValue) function f( ){()} ; ? declare function test( $f, $annotationValue){ ?..test annotation:%myAnnotation of function( $f) for value: $annotationValue?..} ; ? ????.. test( $myFunction, $myTestValue) ??.. - another, more important point is that the constructor-function for these annotated functions can be called from different places in my program with different values. So actually function-creation is also during processing. Is this something that W3C sees as a useful enough addition and is it feasible within the given capacity? Thanks in advance, Rob Stapper _____ <https://www.avast.com/antivirus> Afbeelding verwijderd door afzender. Avast logo Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. www.avast.com <https://www.avast.com/antivirus> _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150723/70300025/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/jpeg Size: 823 bytes Desc: not available URL: <http://x-query.com/pipermail/talk/attachments/20150723/70300025/attachment.jpe> From r.stapper at lijbrandt.nl Thu Jul 23 23:07:57 2015 From: r.stapper at lijbrandt.nl (Rob Stapper) Date: Fri, 24 Jul 2015 08:07:57 +0200 Subject: [xquery-talk] FW: annotations in function-declarations References: <000901d0c556$d8d45dc0$8a7d1940$@lijbrandt.nl> <CAPa8FbRiftNir4zhwXbckVPW_DaZz4ox1W_SCpEZetHMc7-EbA@mail.gmail.com> Message-ID: <000f01d0c5d7$162ddf90$42899eb0$@lijbrandt.nl> I got my answer: not even Java is flexible here. I?m probably over asking, again. Even have to reconsider my case. Regards, Rob Van: Rob Stapper [mailto:r.stapper at lijbrandt.nl] Verzonden: donderdag 23 juli 2015 18:13 Aan: talk at x-query.com Onderwerp: FW: [xquery-talk] annotations in function-declarations Always forget to reply to all. Van: Rob Stapper [mailto:r.stapper at lijbrandt.nl] Verzonden: donderdag 23 juli 2015 17:33 Aan: 'Ghislain Fourny' Onderwerp: RE: [xquery-talk] annotations in function-declarations Hello Ghislain, That sure makes sense, I?ve thought about that too. On the other hand the following construction is completely legal and the annotated-function is dynamically created: ? declare function mySpace:constructor( $a, $b, ?.) { %myAnnotation( ?wishThisWasAvariable-InsteadOfAliteralValue?) function ( $f ){$f( $a, $b, ??..)} } ; The function and probably so also its annotation is created dynamically. So it needs a little feasibility-study . Is there room for a little feasibility-study ;-) ( I know capacity) Kind Regards, Rob Van: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] Namens Ghislain Fourny Verzonden: donderdag 23 juli 2015 16:56 Aan: Rob Stapper CC: talk at x-query.com Onderwerp: Re: [xquery-talk] annotations in function-declarations Hi Rob, Just off the top of my mind, I would expect some challenges with respect to dynamically vs. statically known information. With a literal, all annotations are known statically. With a variable, this is no longer the case. This may have unexpected implications for function type checking, etc. I hope it makes sense. Kind regards, Ghislain On Thu, Jul 23, 2015 at 4:49 PM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: Hi, Is it possible that in a nearby release of the XQUERY-standard the parameters of the annotations in function-declarations can also hold string-variables? e.g. ? declare %myAnnotation( $annotationValue) function f ( ){()} ; ? instead of: declare %myAnnotation( ?myLiteral?) function f ( ){()} ; ? My use-case is that I want to be able to check some of my functions for specific properties during processing. - it would be nice if the source of the annotationValue at function-creation could be the same as at function-checking, e.g. ? declare variable $annotationValue := ?testValue? ; ? declare %myAnnotation( $annotationValue) function f( ){()} ; ? declare function test( $f, $annotationValue){ ?..test annotation:%myAnnotation of function( $f) for value: $annotationValue?..} ; ? ????.. test( $myFunction, $myTestValue) ??.. - another, more important point is that the constructor-function for these annotated functions can be called from different places in my program with different values. So actually function-creation is also during processing. Is this something that W3C sees as a useful enough addition and is it feasible within the given capacity? Thanks in advance, Rob Stapper _____ <https://www.avast.com/antivirus> Afbeelding verwijderd door afzender. Avast logo Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. www.avast.com <https://www.avast.com/antivirus> _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150724/1a55867c/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/jpeg Size: 823 bytes Desc: not available URL: <http://x-query.com/pipermail/talk/attachments/20150724/1a55867c/attachment.jpe> From geert.josten at gmail.com Fri Jul 31 01:39:04 2015 From: geert.josten at gmail.com (Geert Josten) Date: Fri, 31 Jul 2015 10:39:04 +0200 Subject: [xquery-talk] XML Amsterdam 2015 Call for Abstracts is officially open! Message-ID: <CAH_Jeqe9c7+X0VKseSuB84WW=fdvXKSSwYtejmbqyzttgK3ddQ@mail.gmail.com> XML Amsterdam 2015 is pleased to announce a new venue at CWI in Amsterdam. The conference will be held on 6 November this year. We're looking forward to submissions about a variety of markup related topics! Please visit http://xmlamsterdam.com/2015/abstracts for submission instructions. XML Amsterdam info at xmlamsterdam.com http://xmlamsterdam.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150731/ca575a9c/attachment.html> From fcavalieri83 at gmail.com Fri Jul 31 07:16:21 2015 From: fcavalieri83 at gmail.com (Federico Cavalieri) Date: Fri, 31 Jul 2015 16:16:21 +0200 Subject: [xquery-talk] [ANN] Zorba "Leto" 3.1 Message-ID: <CAAYCj=Lkc_YBrZ3ZHaSBd1M5QAf9nQZ6FTqR74BURdAP6ZMZFA@mail.gmail.com> Dear Zorba users, We are proud to announce the release of Zorba 3.1, codename Leto. This release introduces a new query profiler for performance analysis and a revamped function caching infrastructure. Leto also includes many optimizations, a number of new features, and more than 60 bug fixes. Please check the ChangeLog at https://github.com/28msec/zorba/blob/master/ChangeLog for complete information. Zorba Leto is the first release to be also available via Docker ( https://www.docker.com/). Docker is a great way to deploy Zorba on any operating system. The image is available at https://registry.hub.docker.com/u/fcavalieri/zorba/. Below are examples of Zorba executed via Docker: Zorba command via Docker. docker run zorba -q 1+1 You can also mount a local folder that contains your queries. Zorba command via docker using a mounted volume. docker run -v /home/fcavalieri/myqueries:/queries zorba -q foo.xq -f Checkout the full announcement at http://www.28.io/blog/zorba-3.1/ Happy querying! Federico -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://x-query.com/pipermail/talk/attachments/20150731/96ebfac7/attachment.html> From christian.gruen at gmail.com Fri Jul 31 07:20:56 2015 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Fri, 31 Jul 2015 16:20:56 +0200 Subject: [xquery-talk] [ANN] Zorba "Leto" 3.1 In-Reply-To: <CAAYCj=Lkc_YBrZ3ZHaSBd1M5QAf9nQZ6FTqR74BURdAP6ZMZFA@mail.gmail.com> References: <CAAYCj=Lkc_YBrZ3ZHaSBd1M5QAf9nQZ6FTqR74BURdAP6ZMZFA@mail.gmail.com> Message-ID: <CAP94bnNSZZiykxsgEkg7Ot-9_gtP-FcqfPkhpA+7q7p_5D6FQg@mail.gmail.com> That's great news! Thanks for the update. Christian On Fri, Jul 31, 2015 at 4:16 PM, Federico Cavalieri <fcavalieri83 at gmail.com> wrote: > Dear Zorba users, > > We are proud to announce the release of Zorba 3.1, codename Leto. > > This release introduces a new query profiler for performance analysis and a > revamped function caching infrastructure. > Leto also includes many optimizations, a number of new features, and more > than 60 bug fixes. > Please check the ChangeLog at > https://github.com/28msec/zorba/blob/master/ChangeLog for complete > information. > > Zorba Leto is the first release to be also available via Docker > (https://www.docker.com/). > Docker is a great way to deploy Zorba on any operating system. > The image is available at > https://registry.hub.docker.com/u/fcavalieri/zorba/. > Below are examples of Zorba executed via Docker: > > Zorba command via Docker. > docker run zorba -q 1+1 > > You can also mount a local folder that contains your queries. > > Zorba command via docker using a mounted volume. > docker run -v /home/fcavalieri/myqueries:/queries zorba -q foo.xq -f > > Checkout the full announcement at http://www.28.io/blog/zorba-3.1/ > > Happy querying! > Federico > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk