home contribute faq download

FunctX XSLT Functions

functx:has-empty-content

Whether an element has empty content

Google
Webxsltfunctions.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

XSLT Function Declaration

See XQuery definition.
XSLT 2.0 Syntax:
<xsl:function name="functx:has-empty-content" as="xs:boolean" 
              xmlns:functx="http://www.functx.com" >
  <xsl:param name="element" as="element()"/> 
 
  <xsl:sequence select=" 
   not($element/node())
 "/>
   
</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<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>
</xsl:variable>
XSLT 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
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley