Hi, Mark:
As a footnote on the suggestion from Chris, you should be able
to get elements without child elements this way:
/xh:BOOKS//*[empty(*)]
and elements without any child nodes this way:
/xh:BOOKS//*[empty(node())]
If I recall correctly, documents with a known schema can have
insignificant whitespace that doesn't count as a node, but I may be
misremembering the rules for insignificant whitespace.
Hoping that helps,
Erik Hennum
________________________________________
From: [email protected]
[[email protected]] on behalf of Christopher Hamlin
[[email protected]]
Sent: Tuesday, May 12, 2015 6:02 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Xquery to delete all null elements?
If you just want to get the elements below BOOKS:
/xh:BOOKS/element()
or, for all nodes
/xh:BOOKS/node()
/ch
On Tue, May 12, 2015 at 7:12 PM, Mark Shanks <[email protected]> wrote:
> Hi, I want to run an xquery that deletes elements that are empty, e.g.,
> <tag></tag>
>
> The following code works for a specific element:
>
> declare namespace xh="http://marklogic/";
> for $t in (/xh:BOOKS)/xh:TITLES
> return if ($t='')
> then
> xdmp:node-delete($t)
> else
> ()
>
> However, how can I modify it to delete all elements in BOOKS, not just
> TITLES? I tried obvious solutions like for $t in (/xh:BOOKS) and this did
> not hit any of the elements.
>
> Thanks,
>
> Mark
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general