[xquery-talk] Wrapping element conditionally

James Fuller james.fuller.2007 at gmail.com
Mon Dec 16 09:09:37 PST 2013


and for a bit of xquery 3.0 fun

xquery version "3.0";

let $apply:= function($bool,$fn,$el){ ($fn($el)[$bool], $el)[1] }

let $wrap := true() ,
    $p := <p>something here</p>
return
$apply(
   $wrap,
   function($el){<html><body>{$el}</body></html>},
   $p)




On Mon, Dec 16, 2013 at 6:01 PM, David Lee <dlee at calldei.com> wrote:

> FYI the key to understanding XQuery (and XSLT) is that you are not
> "printing lines" your generating element.  *full elements* with these
> constructs.
> You cant just   printf("<html>")  then later printf("</html>")
>
> You are constructing an entire element including the start, end and body
> all at once.
> So you cant conditionally include or exclude half the markup.
>
>
> -----Original Message-----
> From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On
> Behalf Of David Carlisle
> Sent: Monday, December 16, 2013 11:47 AM
> To: Misztur, Chris; talk at x-query.com
> Subject: Re: [xquery-talk] Wrapping element conditionally
>
> On 16/12/2013 16:28, Misztur, Chris wrote:
> > How would I get the output to look like:
> >
> > <html><body><p/></body><html>
> >
> > Or just:
> >
> > <p/>
>
> <html><body><p>something here</p></body></html>/
>     (if($wrap) then . else body/p)
>
> David
>
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England and
> Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>
> _______________________________________________
> 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/20131216/b7876c4b/attachment.html>


More information about the talk mailing list