<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.msochpdefault, li.msochpdefault, div.msochpdefault
        {mso-style-name:msochpdefault;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Calibri","sans-serif";}
span.emailstyle17
        {mso-style-name:emailstyle17;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Can you explain this more:</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">($fn($el)[$bool], $el)[1]<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Construct a sequence of<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">( Call the function $fn  given the argument $el
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">   if $bool is true the the result of the function is used otherwise () ,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">   The element $el )<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This produces a 1 or 2 element sequence.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[1] takes the first element which is either the wrapped $el or just $el<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I would put this example in the camp of "advanced xquery"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Misztur, Chris [mailto:CMisztur@macleanfogg.com]
<br>
<b>Sent:</b> Monday, December 16, 2013 12:33 PM<br>
<b>To:</b> James Fuller; David Lee<br>
<b>Cc:</b> David Carlisle; talk@x-query.com<br>
<b>Subject:</b> RE: [xquery-talk] Wrapping element conditionally<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Can you explain this more:</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">($fn($el)[$bool], $el)[1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><img width="191" height="47" id="Picture_x0020_2" src="cid:image001.jpg@01CEFA60.3733A920" alt="Description: Description: C:\Users\bduffy\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\WXCD6RUK\MF_4C_email (2).jpeg"></span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0085C2"> </span></b><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#0085C2">Chris Misztur</span></b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#0085C2">
</span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">|
<b>Engineer, Business Systems</b></span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">1000 Allanson Rd, Mundelein, IL 60060 (<a href="http://g.co/maps/kxf8e">Map</a>)
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">Office +1 847 837-3729 | Cell +1 312 504-0681</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><a href="http://www.macleanfoggcs.com/">www.macleanfoggcs.com</a></span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> James Fuller [<a href="mailto:james.fuller.2007@gmail.com">mailto:james.fuller.2007@gmail.com</a>]
<br>
<b>Sent:</b> Monday, December 16, 2013 11:10 AM<br>
<b>To:</b> David Lee<br>
<b>Cc:</b> David Carlisle; Misztur, Chris; <a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
<b>Subject:</b> Re: [xquery-talk] Wrapping element conditionally</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">and for a bit of xquery 3.0 fun<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">xquery version "3.0";<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">let $apply:= function($bool,$fn,$el){ ($fn($el)[$bool], $el)[1] }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">let $wrap := true() ,  <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">    $p := <p>something here</p><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">return<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">$apply(<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   $wrap,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   function($el){<html><body>{$el}</body></html>}, <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   $p)<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
 <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Mon, Dec 16, 2013 at 6:01 PM, David Lee <<a href="mailto:dlee@calldei.com" target="_blank">dlee@calldei.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:.5in">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.<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
<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><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in">_______________________________________________<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><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div class="MsoNormal" align="center" style="margin-left:.5in;text-align:center">
<hr size="2" width="100%" align="center">
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:gray"><br>
The contents of this message may be privileged and confidential. Therefore, if this message has been received in error, please delete it without reading it. Your receipt of this message is not intended to waive any applicable privilege. Please do not disseminate
 this message without the permission of the author.<br>
<br>
Please consider the environment before printing this e-mail</span><o:p></o:p></p>
</div>
</body>
</html>