<div dir="ltr"><font face="verdana, sans-serif">Hi Pragya,</font><div><font face="verdana, sans-serif"><br></font></div><div><font face="verdana, sans-serif">If you are using XSLT, please try below code and see if this helps,</font></div><div><font face="verdana, sans-serif"><br></font></div><div><div><font face="verdana, sans-serif"> &lt;xsl:template match=&quot;@*|node()&quot;&gt;</font></div><div><font face="verdana, sans-serif">        &lt;xsl:choose&gt;</font></div><div><font face="verdana, sans-serif">            &lt;xsl:when test=&quot;descendant-or-self::text()[normalize-space(.) ne &#39;&#39;]&quot;&gt;</font></div><div><font face="verdana, sans-serif">                &lt;xsl:copy&gt;</font></div><div><font face="verdana, sans-serif">                    &lt;xsl:apply-templates select=&quot;@* | node()&quot;/&gt;</font></div><div><font face="verdana, sans-serif">                &lt;/xsl:copy&gt;</font></div><div><font face="verdana, sans-serif">            &lt;/xsl:when&gt;                     </font></div><div><font face="verdana, sans-serif">            &lt;xsl:otherwise/&gt;</font></div><div><font face="verdana, sans-serif">        &lt;/xsl:choose&gt;</font></div><div><font face="verdana, sans-serif">    &lt;/xsl:template&gt;</font></div><div><font face="verdana, sans-serif"><br></font></div><div><font face="verdana, sans-serif">Thank you!</font></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 27, 2015 at 5:43 PM, Dave Cassel <span dir="ltr">&lt;<a href="mailto:Dave.Cassel@marklogic.com" target="_blank">Dave.Cassel@marklogic.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>
<div>Pragya, you can do that using XSL or <a href="http://blog.davidcassel.net/2014/01/recursive-descent-in-xquery/" target="_blank">
recursive descent in XQuery</a>. The typeswitch case would look something like:</div>
<div><br>
</div>
<div>case element() return</div>
<div>  let $children := $node/node() ! local:change(.)</div>
<div>  return</div>
<div>    if (fn:exists($children)) then</div>
<div>      element { fn:node-name($node) } { </div>
<div>        $node/@*,</div>
<div>        $children</div>
<div>      }</div>
<div>    else ()</div>
<div>…</div><span class=""><font color="#888888">
<div><br>
</div>
<div>-- </div>
<div>
<div><span style="font-size:11pt;font-family:Calibri">Dave Cassel<br>
</span><span style="font-family:Calibri;font-size:15px">Developer Community Manager</span><span style="font-size:11pt;font-family:Calibri"><br>
<a href="http://www.marklogic.com/" target="_blank">MarkLogic Corporation</a><br>
</span><a href="http://world.marklogic.com/locations/san-francisco/" style="font-family:Calibri;font-size:15px" target="_blank">MarkLogic World - San Francisco April 13 - 17</a><br style="font-family:Calibri;font-size:15px">
<span style="font-size:11pt;font-family:Calibri"><br>
</span></div>
</div>
</font></span></div><span class=""><font color="#888888">
<div><br>
</div>
</font></span><span><span class=""><font color="#888888">
<div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;border-width:1pt medium medium;border-style:solid none none;padding:3pt 0in 0in;border-top-color:rgb(181,196,223)">
<span style="font-weight:bold">From: </span>&lt;Kapoor&gt;, Pragya &lt;<a href="mailto:PKapoor1@innodata.com" target="_blank">PKapoor1@innodata.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@developer.marklogic.com" target="_blank">general@developer.marklogic.com</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Friday, March 27, 2015 at 7:53 AM<br>
<span style="font-weight:bold">To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@developer.marklogic.com" target="_blank">general@developer.marklogic.com</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>[MarkLogic Dev General] Empty Results<br>
</div></font></span><div><div class="h5">
<div><br>
</div>
<blockquote style="BORDER-LEFT:#b5c4df 5 solid;PADDING:0 0 0 5;MARGIN:0 0 0 5">
<div>
<div dir="ltr">
<div style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)">
<p>Hi,<br>
</p>
<p><br>
</p>
<p>I want to remove the empty result element from the dynamic xml.<br>
</p>
<p><br>
</p>
<p>For example:<br>
</p>
<p>In the below xml, I want to exclude the element(which has no values) The element name are not fixed as this xml is dynamically created.<br>
</p>
<p><br>
</p>
<p>Exclude the below exlemnt<br>
</p>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
   &lt;result&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
            &lt;Currency/&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
        &lt;/result&gt;<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
<br>
</div>
<p>dynamic.xml:<br>
</p>
<div>&lt;report&gt;</div>
<div>    &lt;columns&gt;</div>
<div>        &lt;title&gt;Currency&lt;/title&gt;</div>
<div>    &lt;/columns&gt;</div>
<div>    &lt;results&gt;</div>
<div>        &lt;result&gt;</div>
<div>            &lt;Currency/&gt;</div>
<div>        &lt;/result&gt;</div>
<div>        &lt;result&gt;</div>
<div>            &lt;Currency/&gt;</div>
<div>        &lt;/result&gt;</div>
<div>        &lt;result&gt;</div>
<div>            &lt;Currency/&gt;</div>
<div>        &lt;/result&gt;</div>
<div>        &lt;result&gt;</div>
<div>            &lt;Currency&gt;Pound sterling&lt;/Currency&gt;</div>
<div>        &lt;/result&gt;</div>
<div>        &lt;result&gt;</div>
<div>            &lt;Currency/&gt;</div>
<div>        &lt;/result&gt;</div>
<div>        &lt;result&gt;</div>
<div>            &lt;Currency&gt;Pound sterling&lt;/Currency&gt;</div>
<div>        &lt;/result&gt;</div>
<div>    &lt;/results&gt;</div>
<div>&lt;/report&gt;<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Excepted output:<br>
</div>
<div><br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
&lt;report&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
    &lt;columns&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
        &lt;title&gt;Currency&lt;/title&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
    &lt;/columns&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
    &lt;results&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
​            &lt;Currency&gt;Pound sterling&lt;/Currency&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
        &lt;/result&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
        &lt;result&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
            &lt;Currency&gt;Pound sterling&lt;/Currency&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
        &lt;/result&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
    &lt;/results&gt;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">
&lt;/report&gt;<br>
</div>
<br>
</div>
<div>Thanks<br>
</div>
<div>Pragya<br>
</div>
<p><br>
</p>
</div>
&quot;This e-mail and any attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential , proprietary or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and
 destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this e-mail or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful.&quot;
</div>
</div>
</blockquote>
</div></div></span>
</div>

<br>_______________________________________________<br>
General mailing list<br>
<a href="mailto:General@developer.marklogic.com">General@developer.marklogic.com</a><br>
<a href="http://developer.marklogic.com/mailman/listinfo/general" target="_blank">http://developer.marklogic.com/mailman/listinfo/general</a><br>
<br></blockquote></div><br></div></div></div>