Description
The functx:has-empty-content function returns true if the element has no content at all (not even whitespace.) This is in contrast to the fn:empty function, which will return true for any element regardless of whether it has any content.
To test whether an element has any content besides whitespace, see the functx:all-whitespace function.
Arguments and Return TypeName | Type | Description |
$element |
element() |
the XML element to test |
return value |
xs:boolean |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:has-empty-content
( $element as element() ) as xs:boolean {
not($element/node())
} ; |
Exampleslet $in-xml := | <in-xml>
<a></a>
<b/>
<c> </c>
<d>xml</d>
<e><x>xml</x></e>
<f>mixed <x>xml</x></f>
<g> <x>xml</x> </g>
</in-xml> | return |
XQuery Example | Results |
---|
functx:has-empty-content($in-xml/a) |
true |
functx:has-empty-content($in-xml/b) |
true |
functx:has-empty-content($in-xml/c) |
false |
functx:has-empty-content($in-xml/d) |
false |
functx:has-empty-content($in-xml/e) |
false |
functx:has-empty-content($in-xml/f) |
false |
functx:has-empty-content($in-xml/g) |
false |
See AlsoHistory |
Recommended Reading:
|