home contribute faq download

FunctX XQuery Functions

functx:has-empty-content

Whether an element has empty content

Google
Webxqueryfunctions.com

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 Type

NameTypeDescription
$element element() the XML element to test
return value xs:boolean

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:has-empty-content
  ( $element as element() )  as xs:boolean {

   not($element/node())
 } ;

Examples

let $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 ExampleResults
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 Also

fn:emptyWhether a value is the empty sequence
functx:has-mixed-contentWhether an element has mixed content
functx:has-element-only-contentWhether an element has element-only content
functx:has-simple-contentWhether an element has simple content
functx:all-whitespaceWhether a value is all whitespace or a zero-length string

History

Published OnLast UpdatedContributor(s)
2007-04-302007-04-30Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XQuery Services

Recommended Reading:

XQuery