home contribute faq download

FunctX XSLT Functions

functx:has-simple-content

Whether an element has simple content

Google
Webxsltfunctions.com

Description

The functx:has-simple-content function returns true if the element has no child elements but does have some textual (character data) content, even if it is all whitespace.

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-simple-content" as="xs:boolean" 
              xmlns:functx="http://www.functx.com" >
  <xsl:param name="element" as="element()"/> 
 
  <xsl:sequence select=" 
   $element/text() and not($element/*)
 "/>
   
</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>
</in-xml>
</xsl:variable>
XSLT ExampleResults
functx:has-simple-content($in-xml/a)
false
functx:has-simple-content($in-xml/b)
false
functx:has-simple-content($in-xml/c)
true
functx:has-simple-content($in-xml/d)
true
functx:has-simple-content($in-xml/e)
false
functx:has-simple-content($in-xml/f)
false

See Also

functx:has-mixed-contentWhether an element has mixed content
functx:has-element-only-contentWhether an element has element-only content
functx:has-empty-contentWhether an element has empty 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