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