Hi, Pragya:

If whitespace only appears in container elements and not in leaf elements, you 
can use node tests:

    if (empty($in-xml//*[empty(*) and exists(text())])) then ...


Hoping that helps,


Erik Hennum


________________________________
From: [email protected] 
[[email protected]] on behalf of VISH RAJPUT 
[[email protected]]
Sent: Monday, April 18, 2016 4:02 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Xquery : Empty Content

Hi Pragya,

I think we can test normalize-space here like below:-

 let $in-xml :=
(<in-xml>
   <a></a>
   <b/>
   <c></c>
   <d><X></X></d>
   <e></e>
   <f></f>
   <g></g>
</in-xml>)

return (if ($in-xml[normalize-space() = '']) then ("Empty In-XML") else ("Not 
Empty"))

Regards,
Vishnu

On Mon, Apr 18, 2016 at 3:37 PM, Kapoor, Pragya 
<[email protected]<mailto:[email protected]>> wrote:


Hi,


I have an xml :


    let $in-xml :=
<in-xml>
   <a></a>
   <b/>
   <c></c>
   <d><X></X></d>
   <e></e>
   <f></f>
   <g></g>
</in-xml>



Now, how can I check if the content of all the elements and there child 
elements in $in-xml are empty(no content)?


if(content is empty) then "do this" else "do this"


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
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general




--
Vishnu Singh | http://marklogicgd.blogspot.in/
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to