home contribute faq download

FunctX XSLT Functions

functx:leaf-elements

All XML elements that don't have any child elements

Google
Webxsltfunctions.com

Description

The functx:leaf-elements function returns the elements that do not have any element children that are descendants of (or the same as) the root. Leaf elements may have attributes, and may contain text, processing instructions and/or comments.

Arguments and Return Type

NameTypeDescription
$root node()? the root
return value element()*

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:leaf-elements" as="element()*"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="root" as="node()?"/>

  <xsl:sequence select="
   $root/descendant-or-self::*[not(*)]
 "/>

</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<authors>
   <author>
      <fName>Kate</fName>
      <lName>Jones</lName>
   </author>
   <author>
      <fName>John</fName>
      <lName>Doe</lName>
   </author>
</authors>
</xsl:variable>
XPath ExampleResults
functx:leaf-elements($in-xml)
<fName>Kate</fName>
<lName>Jones</lName>
<fName>John</fName>
<lName>Doe</lName>
functx:leaf-elements($in-xml/author[1])
<fName>Kate</fName>
<lName>Jones</lName>

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery