home contribute faq download

FunctX XQuery Functions

functx:all-whitespace

Whether a value is all whitespace or a zero-length string

Google
Webxqueryfunctions.com

Description

The functx:all-whitespace function tests whether a string (or node that is atomized) is all whitespace or empty. If $arg is the empty sequence, it returns true.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string (or node) to test
return value xs:boolean

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:all-whitespace
  ( $arg as xs:string? )  as xs:boolean {

   normalize-space($arg) = ''
 } ;

Examples

let $in-xml :=
<in-xml>
   <a>    </a>
   <b>x    </b>
   <c>  <x>x</x>    </c>
</in-xml>
return
XQuery ExampleResults
functx:all-whitespace('   ')
true
functx:all-whitespace(' x  ')
false
functx:all-whitespace($in-xml/a)
true
functx:all-whitespace($in-xml/b)
false
functx:all-whitespace($in-xml/c)
false
functx:all-whitespace($in-xml/c/text()[1])
true

See Also

fn:emptyWhether a value 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

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley