home contribute faq download

FunctX XQuery Functions

functx:leaf-elements

All XML elements that don't have any child elements

Google
Webxqueryfunctions.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()*

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for July 2004 - January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:leaf-elements 
  ( $root as node()? )  as element()* {
       
   $root/descendant-or-self::*[not(*)]
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function leaf-elements 
  ( $root as node()? )  as element()* {
       
   $root/descendant-or-self::*[fn:not(*)]
 }

Examples

let $in-xml :=
<authors>
   <author>
      <fName>Kate</fName>
      <lName>Jones</lName>
   </author>
   <author>
      <fName>John</fName>
      <lName>Doe</lName>
   </author>
</authors>
return
XQuery 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
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley