<div dir="ltr">and for a bit of xquery 3.0 fun<div><br></div><div><div>xquery version "3.0";</div><div><br></div><div>let $apply:= function($bool,$fn,$el){ ($fn($el)[$bool], $el)[1] }</div><div><br></div><div>let $wrap := true() ,  </div>
<div>    $p := <p>something here</p></div><div>return</div><div>$apply(</div><div>   $wrap,</div><div>   function($el){<html><body>{$el}</body></html>}, </div><div>   $p)</div></div><div>
<br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 16, 2013 at 6:01 PM, David Lee <span dir="ltr"><<a href="mailto:dlee@calldei.com" target="_blank">dlee@calldei.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">FYI the key to understanding XQuery (and XSLT) is that you are not "printing lines" your generating element.  *full elements* with these constructs.<br>

You cant just   printf("<html>")  then later printf("</html>")<br>
<br>
You are constructing an entire element including the start, end and body all at once.<br>
So you cant conditionally include or exclude half the markup.<br>
<div><div class="h5"><br>
<br>
-----Original Message-----<br>
From: <a href="mailto:talk-bounces@x-query.com">talk-bounces@x-query.com</a> [mailto:<a href="mailto:talk-bounces@x-query.com">talk-bounces@x-query.com</a>] On Behalf Of David Carlisle<br>
Sent: Monday, December 16, 2013 11:47 AM<br>
To: Misztur, Chris; <a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
Subject: Re: [xquery-talk] Wrapping element conditionally<br>
<br>
On 16/12/2013 16:28, Misztur, Chris wrote:<br>
> How would I get the output to look like:<br>
><br>
> <html><body><p/></body><html><br>
><br>
> Or just:<br>
><br>
> <p/><br>
<br>
<html><body><p>something here</p></body></html>/<br>
    (if($wrap) then . else body/p)<br>
<br>
David<br>
<br>
<br>
________________________________________________________________________<br>
The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is:<br>
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.<br>
<br>
This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs.<br>
________________________________________________________________________<br>
_______________________________________________<br>
<a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
<a href="http://x-query.com/mailman/listinfo/talk" target="_blank">http://x-query.com/mailman/listinfo/talk</a><br>
<br>
</div></div>_______________________________________________<br>
<a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
<a href="http://x-query.com/mailman/listinfo/talk" target="_blank">http://x-query.com/mailman/listinfo/talk</a><br>
</blockquote></div><br></div>