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 TypeName | Type | Description |
$root |
node()? |
the root |
return value |
element()* |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:leaf-elements
( $root as node()? ) as element()* {
$root/descendant-or-self::*[not(*)]
} ; |
Exampleslet $in-xml := | <authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> | return |
XQuery Example | Results |
---|
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 |
Recommended Reading:
|