home contribute faq download

FunctX XQuery Functions

functx:distinct-element-names

The distinct names of all elements in an XML fragment

Google
Webxqueryfunctions.com

Description

The functx:distinct-element-names function returns the distinct set of element names that exist in $nodes or among the descendants of $nodes.

Arguments and Return Type

NameTypeDescription
$nodes node()* the root(s) to start from
return value xs:string*

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for April 2005 - January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:distinct-element-names 
  ( $nodes as node()* )  as xs:string* {
       
   distinct-values($nodes/descendant-or-self::*/name(.))
 } ;
XQuery Syntax for July 2004:
declare namespace functx = "http://www.functx.com"; 
declare function functx:distinct-element-names 
  ( $nodes as node()* )  as xs:string* {
       
   distinct-values(for $el in $nodes/descendant-or-self::*
                      return name($el))
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function distinct-element-names 
  ( $nodes as node()* )  as xs:string* {
       
   fn:distinct-values(for $el in $nodes/descendant-or-self::*
                      return fn:name($el))
 }

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:distinct-element-names($in-xml)
('authors',
'author',
'fName',
'lName')
functx:distinct-element-names(
   $in-xml/author[1])
('author',
'fName',
'lName')

Depends On

functx:path-to-nodeA path to an XML node (or sequence of nodes)

See Also

functx:distinct-attribute-namesThe distinct names of all attributes in an XML fragment
functx:distinct-element-pathsThe distinct paths of all descendant elements in an XML fragment

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