Description
The fn:empty function checks whether sequence is empty, meaning that it contains zero items. A sequence is not considered empty just because it only contains a zero-length string, the value 0, or an element with empty content.
It is often unnecessary to call the fn:empty function because sequences are automatically converted to their effective boolean value where a boolean value is expected.
This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return TypeName | Type |
$arg |
item()* |
return value |
xs:boolean |
Examples<xsl:variable name="in-xml" as="item()*"> | | <in-xml>
<a></a>
<b/>
<c>xyz</c>
</in-xml> |
| </xsl:variable> |
XPath Example | Results | Explanation |
---|
empty( ('a', 'b', 'c') ) |
false |
empty( () ) |
true |
empty(0) |
false |
empty($in-xml/a) |
false |
empty($in-xml/b) |
false |
empty($in-xml/c) |
false |
empty($in-xml/foo) |
true |
Or a static error, if static typing is in effect and foo is not an allowed child. |
See AlsoHistory |
Recommended Reading:
|