home contribute faq download

FunctX XQuery Functions

functx:distinct-attribute-names

The distinct names of all attributes in an XML fragment

Google
Webxqueryfunctions.com

Description

The functx:distinct-attribute-names function returns the distinct set of attribute names that exist on nodes in $nodes or their descendants.

Arguments and Return Type

NameTypeDescription
$nodes node()* the root 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-attribute-names 
  ( $nodes as node()* )  as xs:string* {
       
   distinct-values($nodes//@*/name(.))
 } ;
XQuery Syntax for July 2004:
declare namespace functx = "http://www.functx.com"; 
declare function functx:distinct-attribute-names 
  ( $nodes as node()* )  as xs:string* {
       
   distinct-values(for $attr in $nodes//@*
                      return name($attr))
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function distinct-attribute-names 
  ( $nodes as node()* )  as xs:string* {
       
   fn:distinct-values(for $attr in $nodes//@*
                      return fn:name($attr))
 }

Examples

let $in-xml :=
<authors a1="xyz">
   <author a2="abc">
      <fName a3="def">Kate</fName>
      <lName>Jones</lName>
   </author>
   <author>
      <fName a3="def">John</fName>
      <lName>Doe</lName>
   </author>
</authors>
return
XQuery ExampleResults
functx:distinct-attribute-names($in-xml)
('a1', 'a2', 'a3')

See Also

functx:distinct-element-namesThe distinct names of all 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