home contribute faq download

FunctX XSLT Functions

fn:empty

Whether a value is the empty sequence

Google
Webdatypic.com

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 Type

NameType
$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 ExampleResultsExplanation
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 Also

fn:existsWhether an argument is the empty sequence
functx:if-emptyThe first argument if it is not blank, otherwise the second argument
functx:if-absentThe first argument if it is not empty, otherwise the second argument
functx:all-whitespaceWhether a value is all whitespace or a zero-length string

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery