From ghislain.fourny at 28msec.com Mon Oct 1 07:25:03 2012 From: ghislain.fourny at 28msec.com (Ghislain Fourny) Date: Mon, 1 Oct 2012 16:25:03 +0200 Subject: [xquery-talk] incorrect syntax? In-Reply-To: References: Message-ID: <55721D64-619C-46E0-BAA0-53E0E24F462C@28msec.com> Hi Gleb, Could the prefix in front of the return call be missing? (e.g., local:return, depending on how you defined this function) By default (if you have not changed it), the default function namespace is the builtin one (also available through fn:), so just typing "return" will look up among builtin functions (fn:return, which as far as I know does not exist). Does this help? Kind regards, Ghislain On Oct 1, 2012, at 4:19 PM, Gleb Gawriljuk wrote: > Hey everyone, > > I have the following query which I use as a string in Saxon 8.9: > {return( > if ( > not(doc('path.xml')/Student/StudentID = doc(path.xml')/RentNote/StudentID) and > not(doc('path.xml')/Buch/BuchID = doc('path.xml')/RentNote/BuchID) > ) > then error() > else > ) > } > > However I receive the follwoing error: > > > I cannot see where my error lies. I am just executing the return function which holds a xpath expression. Can anybody help? > > Kind regards, > Gleb > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From davidc at nag.co.uk Mon Oct 1 07:29:35 2012 From: davidc at nag.co.uk (David Carlisle) Date: Mon, 01 Oct 2012 15:29:35 +0100 Subject: [xquery-talk] incorrect syntax? In-Reply-To: References: Message-ID: <5069A8CF.3050401@nag.co.uk> On 01/10/2012 15:19, Gleb Gawriljuk wrote: > I cannot see where my error lies. I am just executing the return function That is your error. Xquery does not have a return function. Without seeing more context it's not clear what the query should be. 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 rpbourret at rpbourret.com Mon Oct 1 17:55:20 2012 From: rpbourret at rpbourret.com (Ronald Bourret) Date: Mon, 01 Oct 2012 17:55:20 -0700 Subject: [xquery-talk] incorrect syntax? In-Reply-To: <506A3679.10607@ifactory.com> References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> Message-ID: <506A3B78.2040606@rpbourret.com> This is actually very straightforward. "return" is a keyword, used in FLWOR expressions and a few other places. There is no standalone "return" in XQuery. Thus: let $x:=0 return (23) is a valid (if uninteresting) FLWOR expression that is equivalent to the even less interesting (but still valid) expression: (23) And a standalone "return" is illegal: return (23) (: error :) Where you have included parentheses below, you are calling a function named "return" and XQuery works as expected. It's a bad idea to name a function using a keyword as a name, but XQuery allows it. If you replace "return(...)" with "foo(...)" in the expressions below, the intended meaning will be clear. The last two XQuery expressions should return errors (and do in the online Zorba XQuery processor I tried them in). As noted above, this is because there is no standalone use of the "return" keyword -- either the processor you are using has a bug or you haven't shown us the entire expression. Thanks, -- Ron On 10/1/2012 5:34 PM, Michael Sokolov wrote: > On 10/1/2012 10:48 AM, Michael Kay wrote: >> There is no function called "return". Just remove the keyword. >> Depending on the context, you might need to remove the outer curly >> braces as well. >> >> It's a little confusing because you can say >> >> let $x:=0 return 23 >> >> but you can't say >> >> return 23 > > Actually if you really start to dig, it becomes a lot confusing > > you can say > > let $x := 0 return (23) > > but in that instance return is not a function call; the parentheses here > are constructing a sequence (of one item) > > But if you say > > declare default function namespace "x"; > declare function return ($x) { $x+1 }; > return (23) > > that does seem to return 24 for at least one processor that I tried, > which seems truly bizarre (to me, anyway) > > yet > > declare default function namespace "x"; > declare function return ($x) { $x+1 }; > return 23 > > returns 23 > > while > > declare default function namespace "x"; > declare function return ($x) { $x+1 }; > return return(23) > > returns 24 > > -Mike Sokolov > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From sokolov at ifactory.com Mon Oct 1 19:22:03 2012 From: sokolov at ifactory.com (Michael Sokolov) Date: Mon, 01 Oct 2012 22:22:03 -0400 Subject: [xquery-talk] incorrect syntax? In-Reply-To: <506A3B78.2040606@rpbourret.com> References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> <506A3B78.2040606@rpbourret.com> Message-ID: <506A4FCB.60405@ifactory.com> Sorry, I think I neglected to include a let before a couple of the returns. But my main point was the unusual (and probably unfamiliar to people used to other languages) change in the interpretation of parentheses when they follow the return keyword and when they follow the return function. Admittedly the idea of defining a function with the same name as a keyword is contrived and ill-advised, right up there with C++ operator overloading. It just occurred to me on reading Michael Kay's comment 'There is no function called "return"' that there actually could be one. Mike Sokolov On 10/1/2012 8:55 PM, Ronald Bourret wrote: > This is actually very straightforward. "return" is a keyword, used in > FLWOR expressions and a few other places. There is no standalone > "return" in XQuery. Thus: > > let $x:=0 return (23) > > is a valid (if uninteresting) FLWOR expression that is equivalent to > the even less interesting (but still valid) expression: > > (23) > > And a standalone "return" is illegal: > > return (23) (: error :) > > Where you have included parentheses below, you are calling a function > named "return" and XQuery works as expected. It's a bad idea to name a > function using a keyword as a name, but XQuery allows it. If you > replace "return(...)" with "foo(...)" in the expressions below, the > intended meaning will be clear. > > The last two XQuery expressions should return errors (and do in the > online Zorba XQuery processor I tried them in). As noted above, this > is because there is no standalone use of the "return" keyword -- > either the processor you are using has a bug or you haven't shown us > the entire expression. > > Thanks, > > -- Ron > > On 10/1/2012 5:34 PM, Michael Sokolov wrote: >> On 10/1/2012 10:48 AM, Michael Kay wrote: >>> There is no function called "return". Just remove the keyword. >>> Depending on the context, you might need to remove the outer curly >>> braces as well. >>> >>> It's a little confusing because you can say >>> >>> let $x:=0 return 23 >>> >>> but you can't say >>> >>> return 23 >> >> Actually if you really start to dig, it becomes a lot confusing >> >> you can say >> >> let $x := 0 return (23) >> >> but in that instance return is not a function call; the parentheses here >> are constructing a sequence (of one item) >> >> But if you say >> >> declare default function namespace "x"; >> declare function return ($x) { $x+1 }; >> return (23) >> >> that does seem to return 24 for at least one processor that I tried, >> which seems truly bizarre (to me, anyway) >> >> yet >> >> declare default function namespace "x"; >> declare function return ($x) { $x+1 }; >> return 23 >> >> returns 23 >> >> while >> >> declare default function namespace "x"; >> declare function return ($x) { $x+1 }; >> return return(23) >> >> returns 24 >> >> -Mike Sokolov >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk From rpbourret at rpbourret.com Mon Oct 1 21:11:32 2012 From: rpbourret at rpbourret.com (Ronald Bourret) Date: Mon, 01 Oct 2012 21:11:32 -0700 Subject: [xquery-talk] incorrect syntax? In-Reply-To: <506A4FCB.60405@ifactory.com> References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> <506A3B78.2040606@rpbourret.com> <506A4FCB.60405@ifactory.com> Message-ID: <506A6974.6090700@rpbourret.com> On 10/1/2012 7:22 PM, Michael Sokolov wrote: > Sorry, I think I neglected to include a let before a couple of the > returns. I thought that might be the case. > But my main point was the unusual (and probably unfamiliar to > people used to other languages) change in the interpretation of > parentheses when they follow the return keyword and when they follow the > return function. That is confusing. The other thing that confuses people is that functions don't use the "return" keyword and instead just return the result of evaluating the contained expression. > Admittedly the idea of defining a function with the same name as a > keyword is contrived and ill-advised, right up there with C++ operator > overloading. It just occurred to me on reading Michael Kay's comment > 'There is no function called "return"' that there actually could be one. Agreed. -- Ron From andrew.j.welch at gmail.com Tue Oct 2 00:56:32 2012 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Tue, 2 Oct 2012 08:56:32 +0100 Subject: [xquery-talk] incorrect syntax? In-Reply-To: <506A3679.10607@ifactory.com> References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> Message-ID: > But if you say > > declare default function namespace "x"; > declare function return ($x) { $x+1 }; > return (23) > > that does seem to return 24 for at least one processor that I tried, which > seems truly bizarre (to me, anyway) ha that's great (if a little contrived): declare default function namespace "x"; declare function return ($x) { $x+1 }; return (23) returns 24 but add a let: declare default function namespace "x"; declare function return ($x) { $x+1 }; let $foo := 1 return (23) returns 23 (tested using Saxon HE 9.3.0.5.) From davidc at nag.co.uk Tue Oct 2 01:30:07 2012 From: davidc at nag.co.uk (David Carlisle) Date: Tue, 02 Oct 2012 09:30:07 +0100 Subject: [xquery-talk] incorrect syntax? In-Reply-To: References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> Message-ID: <506AA60F.40707@nag.co.uk> On 02/10/2012 08:56, Andrew Welch wrote: > ha that's great (if a little contrived): > > declare default function namespace "x"; > declare function return ($x) { $x+1 }; > return (23) > > returns 24 Yes that is contrived, I think it's clearer if you write it like this declare default function namespace "return"; declare variable $return := 23; declare function return ($return) { $return+1 }; return ($return) ________________________________________________________________________ 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 Tue Oct 2 01:38:30 2012 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Tue, 2 Oct 2012 09:38:30 +0100 Subject: [xquery-talk] incorrect syntax? In-Reply-To: <506AA60F.40707@nag.co.uk> References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> <506AA60F.40707@nag.co.uk> Message-ID: On 2 October 2012 09:30, David Carlisle wrote: > On 02/10/2012 08:56, Andrew Welch wrote: >> >> ha that's great (if a little contrived): >> >> declare default function namespace "x"; >> declare function return ($x) { $x+1 }; >> return (23) >> >> returns 24 > > > Yes that is contrived, I think it's clearer if you write it like this > > declare default function namespace "return"; > declare variable $return := 23; > declare function return ($return) { $return+1 }; > return ($return) That is indeed much clearer, thanks David. ;) -- Andrew Welch http://andrewjwelch.com From rpbourret at rpbourret.com Tue Oct 2 08:51:12 2012 From: rpbourret at rpbourret.com (Ronald Bourret) Date: Tue, 02 Oct 2012 08:51:12 -0700 Subject: [xquery-talk] incorrect syntax? In-Reply-To: References: <5069AD3C.507@saxonica.com> <506A3679.10607@ifactory.com> <506AA60F.40707@nag.co.uk> Message-ID: <506B0D70.9040403@rpbourret.com> Do I sense an International Obfuscated XQuery Code Contest [1] [2] in the offing? -- Ron [1] http://www.ioccc.org/ [2] http://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest On 10/2/2012 1:38 AM, Andrew Welch wrote: > On 2 October 2012 09:30, David Carlisle wrote: >> On 02/10/2012 08:56, Andrew Welch wrote: >>> >>> ha that's great (if a little contrived): >>> >>> declare default function namespace "x"; >>> declare function return ($x) { $x+1 }; >>> return (23) >>> >>> returns 24 >> >> >> Yes that is contrived, I think it's clearer if you write it like this >> >> declare default function namespace "return"; >> declare variable $return := 23; >> declare function return ($return) { $return+1 }; >> return ($return) > > That is indeed much clearer, thanks David. > > > ;) > > From james.fuller.2007 at gmail.com Wed Oct 10 03:42:45 2012 From: james.fuller.2007 at gmail.com (James Fuller) Date: Wed, 10 Oct 2012 12:42:45 +0200 Subject: [xquery-talk] [ANN] XML Prague 2013 Call for Papers Message-ID: XML Prague 2013 is now welcoming submissions for presentations on the following topics: Digital books and publishing: The role of XML in single-source publishing in the era of tablets, smart phones, and eBook readers. Semantic web: Beyond mere structures. Expressing semantics in data formats and communication protocols. XML vocabularies: A deep dive into industry specific usage of XML. XML efficiency: High-speed processing, compact serialization and storage, processing of big data volumes. XML birthday: Do we need new syntax, data model or both or is XML just fine after 15 years? For more information on CFP http://www.xmlprague.cz/call-for-papers/ on behalf, XML Prague Committee 2013 -- -- XMLPrague 2013, Feb 8-10 Sponsored by XML editor From Robby.Pelssers at nxp.com Fri Oct 12 05:02:40 2012 From: Robby.Pelssers at nxp.com (Robby Pelssers) Date: Fri, 12 Oct 2012 14:02:40 +0200 Subject: [xquery-talk] deduplicating information in XML files Message-ID: <927C66C0775CCA43B88EB1E3006614B31E4AA4E1@eu1rdcrdc1wx032.exi.nxp.com> Hi all, This time I have a rather challenging task at hand. ?Let me first describe the use case.? We have lots of product information stored in XML.? Some of that information describes . Technical applications . Features and benefits . Technical summary One of the problems is a lot of products had e.g. the same features and benefits as they are of the same product family or group.? But as we stored that info per product it got duplicated.? Now we want to deduplicate that info by generating DITA maps and topics (both are just XML).? Now for simplicity let's assume we generate the following content for product1 and product2.? The goal is to get from INPUT to OUTPUT by checking if the body of the linked topics are duplicates, next create 1 generic topic and rewrite the links in the map to? point to that single topic.? I have XSLT / XQuery (XMLDB) and Java at my disposal to get the job done.? I'm not sure what will be the easiest way to get the job done. ?Keep also in mind that my INPUT will contain a few 1000 files (maps and linked topics) and I will need to deduplicate the whole set ;-) Thx upfront for any input, Robby ? INPUT Product1_map.xml ? Product1_FandB.xml: ? ??? product1 ? ? ???

Suitable for high frequency applications due to fast switching characteristics

???

Suitable for logic level gate drive sources

?
Product2_map.xml ? Product2_FandB.xml: ? ??? product2 ? ? ???

Suitable for high frequency applications due to fast switching characteristics

???

Suitable for logic level gate drive sources

?
Expected output: Product1_map.xml ? Product2_map.xml ? FandB_1.xml: ? ??? ? ? ???

Suitable for high frequency applications due to fast switching characteristics

???

Suitable for logic level gate drive sources

?
From helena.galhardas at ist.utl.pt Wed Oct 17 03:18:36 2012 From: helena.galhardas at ist.utl.pt (Helena Galhardas) Date: Wed, 17 Oct 2012 11:18:36 +0100 Subject: [xquery-talk] deduplicating information in XML files In-Reply-To: <927C66C0775CCA43B88EB1E3006614B31E4AA4E1@eu1rdcrdc1wx032.exi.nxp.com> References: <927C66C0775CCA43B88EB1E3006614B31E4AA4E1@eu1rdcrdc1wx032.exi.nxp.com> Message-ID: Dear Robby, Zorba XQuery processor currently supports a data cleaning module (look for data cleaning in http://www.zorba-xquery.com/html/modules) that we may want to try. In principle, the requirements associated to your data de-duplication problem can be addressed by writing an XQuery program that invokes some of the functions available in this data cleaning module. We would appreciate your feedback if you decide to do so and please let us know if we can help somehow. Thanks. Best Regards, Helena Galhardas On Oct 12, 2012, at 1:02 PM, Robby Pelssers wrote: > Hi all, > > This time I have a rather challenging task at hand. Let me first describe the use case. We have lots of product information stored in XML. Some of that information describes > . Technical applications > . Features and benefits > . Technical summary > > One of the problems is a lot of products had e.g. the same features and benefits as they are of the same product family or group. But as we stored that info per product it got duplicated. Now we want to deduplicate that info by generating DITA maps and topics (both are just XML). Now for simplicity let's assume we generate the following content for product1 and product2. The goal is to get from INPUT to OUTPUT by checking if the body of the linked topics are duplicates, next create 1 generic topic and rewrite the links in the map to point to that single topic. I have XSLT / XQuery (XMLDB) and Java at my disposal to get the job done. I'm not sure what will be the easiest way to get the job done. Keep also in mind that my INPUT will contain a few 1000 files (maps and linked topics) and I will need to deduplicate the whole set ;-) > > Thx upfront for any input, > Robby > > INPUT > > Product1_map.xml > > > > > Product1_FandB.xml: > > > product1 > > >

Suitable for high frequency applications due to fast switching characteristics

>

Suitable for logic level gate drive sources

> >
> > Product2_map.xml > > > > > Product2_FandB.xml: > > > product2 > > >

Suitable for high frequency applications due to fast switching characteristics

>

Suitable for logic level gate drive sources

> >
> > Expected output: > > Product1_map.xml > > > > > Product2_map.xml > > > > > FandB_1.xml: > > > > > >

Suitable for high frequency applications due to fast switching characteristics

>

Suitable for logic level gate drive sources

> >
> > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From Robby.Pelssers at nxp.com Fri Oct 19 04:05:55 2012 From: Robby.Pelssers at nxp.com (Robby Pelssers) Date: Fri, 19 Oct 2012 13:05:55 +0200 Subject: [xquery-talk] deduplicating information in XML files In-Reply-To: References: <927C66C0775CCA43B88EB1E3006614B31E4AA4E1@eu1rdcrdc1wx032.exi.nxp.com> Message-ID: <927C66C0775CCA43B88EB1E3006614B31E76A378@eu1rdcrdc1wx032.exi.nxp.com> Hi, I'm currently trying out a pure XSLT solution. As an add-on, I'd like to mention I like where Zorba is going although I did not have the time to use it yet. I really need to take a closer look once I have time at the documentation. Thx for the tip by the way. Robby -----Original Message----- From: Helena Galhardas [mailto:helena.galhardas at ist.utl.pt] Sent: Wednesday, October 17, 2012 12:19 PM To: Robby Pelssers Cc: xsl-list at lists.mulberrytech.com; xquery-discuss; Bruno Martins; Daniela Florescu Subject: Re: [xquery-talk] deduplicating information in XML files Dear Robby, Zorba XQuery processor currently supports a data cleaning module (look for data cleaning in http://www.zorba-xquery.com/html/modules) that we may want to try. In principle, the requirements associated to your data de-duplication problem can be addressed by writing an XQuery program that invokes some of the functions available in this data cleaning module. We would appreciate your feedback if you decide to do so and please let us know if we can help somehow. Thanks. Best Regards, Helena Galhardas On Oct 12, 2012, at 1:02 PM, Robby Pelssers wrote: > Hi all, > > This time I have a rather challenging task at hand. Let me first > describe the use case. We have lots of product information stored in > XML. Some of that information describes . Technical applications . > Features and benefits . Technical summary > > One of the problems is a lot of products had e.g. the same features > and benefits as they are of the same product family or group. But as > we stored that info per product it got duplicated. Now we want to > deduplicate that info by generating DITA maps and topics (both are > just XML). Now for simplicity let's assume we generate the following > content for product1 and product2. The goal is to get from INPUT to > OUTPUT by checking if the body of the linked topics are duplicates, > next create 1 generic topic and rewrite the links in the map to point > to that single topic. I have XSLT / XQuery (XMLDB) and Java at my > disposal to get the job done. I'm not sure what will be the easiest > way to get the job done. Keep also in mind that my INPUT will contain > a few 1000 files (maps and linked topics) and I will need to > deduplicate the whole set ;-) > > Thx upfront for any input, > Robby > > INPUT > > Product1_map.xml > > > > Product1_FandB.xml: > > > product1 > > >

Suitable for high frequency applications due to fast switching characteristics

>

Suitable for logic level gate drive sources

> >
> > Product2_map.xml > > > > Product2_FandB.xml: > > > product2 > > >

Suitable for high frequency applications due to fast switching characteristics

>

Suitable for logic level gate drive sources

> >
> > Expected output: > > Product1_map.xml > > > > > Product2_map.xml > > > > > FandB_1.xml: > > > > > >

Suitable for high frequency applications due to fast switching characteristics

>

Suitable for logic level gate drive sources

> >
> > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From naveen.h at gmail.com Fri Oct 19 08:29:26 2012 From: naveen.h at gmail.com (Naveen Hanumara) Date: Fri, 19 Oct 2012 15:29:26 +0000 (UTC) Subject: [xquery-talk] Invitation to connect on LinkedIn Message-ID: <1166319530.1375650.1350660566644.JavaMail.app@ela4-app2316.prod> LinkedIn ------------ I'd like to add you to my professional network on LinkedIn. - Naveen Naveen Hanumara Software Developer at Detica London, United Kingdom Confirm that you know Naveen Hanumara: https://www.linkedin.com/e/vuwohj-h8hgff4f-3o/isd/9161410241/uQwFakjN/?hs=false&tok=1xEmtoYKixvls1 -- You are receiving Invitation to Connect emails. Click to unsubscribe: http://www.linkedin.com/e/vuwohj-h8hgff4f-3o/uDkLrgTRH42D5Lxbr_d17aeXvE/goo/talk%40xquery%2Ecom/20061/I3065200479_1/?hs=false&tok=0hRZBjI-axvls1 (c) 2012 LinkedIn Corporation. 2029 Stierlin Ct, Mountain View, CA 94043, USA. -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.mueller at mac.com Tue Oct 23 06:36:41 2012 From: martin.mueller at mac.com (Martin Mueller) Date: Tue, 23 Oct 2012 08:36:41 -0500 Subject: [xquery-talk] moving an element from last child to next sibling Message-ID: I have used the xquery typeswitch function to transform elements from a TEI file, but I am stymied by a task involving the following fragment: Your ever affectionate WOODVILLE.

P.S. You have a house, within a mile of York; where we have spent many happy days?"Days of ease, and nights of pleasure." Who knows but we may there recover our juve?nile tastes and passions! impossible! As well when advanced in life, might we hope to reco?ver our youth, in those fields where we once were young.?But is that house untenanted? Will you be our host? Or have you lett, or lent it?

I want to move the element from its position as the last child of into the position of right sibling of so that the desire output would look like this: Your ever affectionate WOODVILLE.

P.S. You have a house, within a mile of York; where we have spent many happy days?"Days of ease, and nights of pleasure." Who knows but we may there recover our juve?nile tastes and passions! impossible! As well when advanced in life, might we hope to reco?ver our youth, in those fields where we once were young.?But is that house untenanted? Will you be our host? Or have you lett, or lent it?

How do I do this? In a typeswitch function the different tasks relating to elements are carried out by subsidiary function. Here is the postscript function that simply passes through the element: declare function eccoparse:postscript($node as element(tei:postscript)) as element() { {$node/@*}{eccoparse:recurse($node)} }; I know how to various things that would change the postscript element but leave it in its current place. But how do I put it in another place without changing anything in it? Is this a task that should be done at the level of the parent element? I'll be grateful for any advice. Martin Mueller Professor emeritus of English and Classics Northwestern University -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsewell at virginia.edu Tue Oct 23 07:02:06 2012 From: dsewell at virginia.edu (David Sewell) Date: Tue, 23 Oct 2012 10:02:06 -0400 (EDT) Subject: [xquery-talk] moving an element from last child to next sibling In-Reply-To: References: Message-ID: There are at least a couple of different approaches to this via the typeswitch strategy, but I think the simplest would be: 1. In your function for closer, recurse over the child nodes as usual (which I assume will output a element, or whatever you transform it to), then process your postscript children: for $ps in $node/tei:postscript return {$ps/@*, eccoparse:recurse($ps)} 2. Extend your postscript function so it returns null if the postscript is a child of : declare function eccoparse:postscript($node as element(tei:postscript)) as element()* { if ($node/parent::tei:closer) then () else {$node/@*}{eccoparse:recurse($node)} } Speaking as someone who wrote a lot of pseudo-templates in XQuery before MarkLogic added an XSLT 2.0 parser to their product, this is one area where XSLT is a lot more pleasant to use, if that's a possibility. David On Tue, 23 Oct 2012, Martin Mueller wrote: > I have used the xquery typeswitch function to transform elements from a TEI > file, but I am stymied by a task involving the following fragment: > > > Your ever affectionate WOODVILLE. > >

P.S. You have a house, within a mile of York; where we > have spent many happy days?"Days of ease, and nights of > pleasure." Who knows but we may there recover our juve?nile tastes and > passions! impossible! As well when advanced in life, might we hope to > reco?ver our youth, in those fields where we once were young.?But > is that house untenanted? Will you be our host? Or have you lett, or lent > it?

>
>
> > I want to move the element from its position as the last child > of into the position of right sibling of so that the > desire output would look like this: > > > Your ever affectionate WOODVILLE. > > > >

P.S. You have a house, within a mile of York; where we > have spent many happy days?"Days of ease, and nights of > pleasure." Who knows but we may there recover our juve?nile tastes and > passions! impossible! As well when advanced in life, might we hope to > reco?ver our youth, in those fields where we once were young.?But > is that house untenanted? Will you be our host? Or have you lett, or lent > it?

>
> > > How do I do this? In a typeswitch function the different tasks relating to > elements are carried out by subsidiary function. Here is the postscript > function that simply passes through the element: > > declare function eccoparse:postscript($node as element(tei:postscript)) as > element() > { > {$node/@*}{eccoparse:recurse($node)} > }; > > > > I know how to various things that would change the postscript element but > leave it in its current place. But how do I put it in another place without > changing anything in it? Is this a task that should be done at the level of > the parent element? > > > > I'll be grateful for any advice. > > > > > > Martin Mueller > > Professor emeritus of English and Classics > > Northwestern University > > > > > -- David Sewell, Editorial and Technical Manager ROTUNDA, The University of Virginia Press PO Box 400314, Charlottesville, VA 22904-4314 USA Email: dsewell at virginia.edu Tel: +1 434 924 9973 Web: http://rotunda.upress.virginia.edu/ From sokolov at ifactory.com Tue Oct 23 19:30:20 2012 From: sokolov at ifactory.com (Michael Sokolov) Date: Tue, 23 Oct 2012 22:30:20 -0400 Subject: [xquery-talk] moving an element from last child to next sibling In-Reply-To: References: Message-ID: <508752BC.2040809@ifactory.com> On 10/23/2012 10:02 AM, David Sewell wrote: > > Speaking as someone who wrote a lot of pseudo-templates in XQuery > before MarkLogic added an XSLT 2.0 parser to their product, this is > one area where XSLT is a lot more pleasant to use, if that's a > possibility. > > David Hear, hear - we abandoned using xquery for transformations as well for that reason. When I was still struggling with that, I found myself trying to write a pattern-matching system (basically something like xslt implemented in xquery), but it was too difficult in XQuery 1.0. Now I wonder whether something like this is feasible using xquery 3.0 features. Maybe not worth the effort, given the existence of xslt, but at least you could imagine defining a map of XPath to function, iterating over a tree, matching patterns and calling functions... -Mike From mike at saxonica.com Wed Oct 24 00:43:14 2012 From: mike at saxonica.com (Michael Kay) Date: Wed, 24 Oct 2012 08:43:14 +0100 Subject: [xquery-talk] moving an element from last child to next sibling In-Reply-To: <508752BC.2040809@ifactory.com> References: <508752BC.2040809@ifactory.com> Message-ID: <50879C12.5060108@saxonica.com> > Now I wonder whether something like this is feasible using xquery 3.0 > features. Maybe not worth the effort, given the existence of xslt, > but at least you could imagine defining a map of XPath to function, > iterating over a tree, matching patterns and calling functions... > I think that with maps* and higher-order functions you could do something quite powerful; however the resulting code might be very cryptic to the uninitiated. * Sadly, maps are not in XQuery 3.0, though John Snelson has shown how they can be implemented using higher-order functions... Michael Kay Saxonica From adam.retter at googlemail.com Thu Oct 25 05:24:20 2012 From: adam.retter at googlemail.com (Adam Retter) Date: Thu, 25 Oct 2012 13:24:20 +0100 Subject: [xquery-talk] exist xquery search In-Reply-To: References: Message-ID: Im not quite sure what the context of your query is, but this really does not look right to me. I would try inverting the order of execution, you can often use the set operators like union or intersect to bring together faceted queries - e.g. let $base := if($person) then //foo/bar[contributions/person/@val = $person] else //foo/bar return let $next := if($other) then //foo/bar[other = $other] else //foo/bar return subsequence($base intersect $next, $off, $num) Another option is actually to build your predicates as a string using concatenation, and then use util:eval to evaluate the query. On 25 October 2012 12:37, Michael Jones wrote: > Hi, > > I'm trying to write a faceted search with exist and xquery. What I have so > far is: > > xquery version "1.0"; > declare namespace request="http://exist-db.org/xquery/request"; > declare namespace xs="http://www.w3.org/2001/XMLSchema"; > declare option exist:serialize "method=xml media-type=text/xml > omit-xml-declaration=no indent=yes"; > > let $label:= request:get-parameter("l",'0') > let $dateTo:= request:get-parameter("dt",'0') > let $dateFrom := request:get-parameter("df",'0') > let $person := request:get-parameter("p",'0') > let $officesHeld := request:get-parameter("o",'0') > let $off := request:get-parameter("off",'0') > let $num := request:get-parameter("num",'10') > > return > > { > subsequence(//foo/bar[ > > (: label :) > (if ($label = '0') > then ( > * > )else( > label/@val = $label > )) > > and > (: person :) > (if ($person = '0') > then ( > * > )else( > contributions/person/@val = $person > )) > and > (: offices held :) > (if ($officesHeld = '0') > then ( > * > )else( > contributions/offices_held/@val = $officesHeld > )) > ],$off,$num) > } > > > On my local machine this runs fine but on my server I get FORG0001: > xs:string(0) is not a sub-type of xs:double [at line 18, column 9]. Also the > performance is really bad. Is there a better way to do a faceted search? I > want to say, if there is a parameter in the URL that matches $person then > search for a person that matches something similar to the value of the > person element. And if the parameter isn't in the url don't search for it, > the way I thought about getting around that is by putting in *, and then > building up a search query based on that. But this seems really inefficient. > I haven't fully done an index of the exist-db yet. But can anyone see a > better way to do this search? > > Thanks > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From adam.retter at googlemail.com Thu Oct 25 05:26:22 2012 From: adam.retter at googlemail.com (Adam Retter) Date: Thu, 25 Oct 2012 13:26:22 +0100 Subject: [xquery-talk] exist xquery search In-Reply-To: References: Message-ID: >Also the > performance is really bad. Your query can be made much more efficient yet. > I haven't fully done an index of the exist-db yet. Indexes made a huge difference in eXist, but you need to get your query correct first, so that you know which indexes you need. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From james.fuller.2007 at gmail.com Sun Oct 28 12:23:40 2012 From: james.fuller.2007 at gmail.com (James Fuller) Date: Sun, 28 Oct 2012 21:23:40 +0100 Subject: [xquery-talk] [ANN] RXQ v0.1 - RESTful MVC with XQuery 3.0 annotations for MarkLogic Message-ID: having fun with Adam Retter's RESTXQ src at https://github.com/xquery/rxq -Jim Fuller From christian.gruen at gmail.com Sun Oct 28 12:26:39 2012 From: christian.gruen at gmail.com (=?ISO-8859-1?Q?Christian_Gr=FCn?=) Date: Sun, 28 Oct 2012 21:26:39 +0100 Subject: [xquery-talk] [ANN] RXQ v0.1 - RESTful MVC with XQuery 3.0 annotations for MarkLogic In-Reply-To: References: Message-ID: ..great news, thanks for the links! Christian ___________________________ > having fun with Adam Retter's RESTXQ > > src at https://github.com/xquery/rxq > > -Jim Fuller > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk