Hi Pragya,

If you are using XSLT, please try below code and see if this helps,

 <xsl:template match="@*|node()">
        <xsl:choose>
            <xsl:when test="descendant-or-self::text()[normalize-space(.)
ne '']">
                <xsl:copy>
                    <xsl:apply-templates select="@* | node()"/>
                </xsl:copy>
            </xsl:when>
            <xsl:otherwise/>
        </xsl:choose>
    </xsl:template>

Thank you!

On Fri, Mar 27, 2015 at 5:43 PM, Dave Cassel <dave.cas...@marklogic.com>
wrote:

>  Pragya, you can do that using XSL or recursive descent in XQuery
> <http://blog.davidcassel.net/2014/01/recursive-descent-in-xquery/>. The
> typeswitch case would look something like:
>
>  case element() return
>   let $children := $node/node() ! local:change(.)
>   return
>     if (fn:exists($children)) then
>       element { fn:node-name($node) } {
>         $node/@*,
>         $children
>       }
>     else ()
> …
>
>  --
>  Dave Cassel
> Developer Community Manager
> MarkLogic Corporation <http://www.marklogic.com/>
> MarkLogic World - San Francisco April 13 - 17
> <http://world.marklogic.com/locations/san-francisco/>
>
>
>   From: <Kapoor>, Pragya <pkapo...@innodata.com>
> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com>
> Date: Friday, March 27, 2015 at 7:53 AM
> To: MarkLogic Developer Discussion <general@developer.marklogic.com>
> Subject: [MarkLogic Dev General] Empty Results
>
>    Hi,
>
>
>  I want to remove the empty result element from the dynamic xml.
>
>
>  For example:
>
> 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.
>
>
>  Exclude the below exlemnt
>     <result>
>              <Currency/>
>          </result>
>
>  dynamic.xml:
>  <report>
>     <columns>
>         <title>Currency</title>
>     </columns>
>     <results>
>         <result>
>             <Currency/>
>         </result>
>         <result>
>             <Currency/>
>         </result>
>         <result>
>             <Currency/>
>         </result>
>         <result>
>             <Currency>Pound sterling</Currency>
>         </result>
>         <result>
>             <Currency/>
>         </result>
>         <result>
>             <Currency>Pound sterling</Currency>
>         </result>
>     </results>
> </report>
>
>
>  Excepted output:
>
>   <report>
>      <columns>
>          <title>Currency</title>
>      </columns>
>      <results>
>  ​            <Currency>Pound sterling</Currency>
>          </result>
>          <result>
>              <Currency>Pound sterling</Currency>
>          </result>
>      </results>
>  </report>
>
>  Thanks
>  Pragya
>
>
>  "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."
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to