home contribute faq download

FunctX XQuery Functions

functx:distinct-element-paths

The distinct paths of all descendant elements in an XML fragment

Google
Webxqueryfunctions.com

Description

The functx:distinct-element-paths function returns a sequence of strings representing the paths of elements that are in $nodes or among their descendants.

Arguments and Return Type

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

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:distinct-element-paths
  ( $nodes as node()* )  as xs:string* {

   distinct-values(functx:path-to-node($nodes/descendant-or-self::*))
 } ;

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

Depends On

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

See Also

functx:distinct-element-namesThe distinct names of all elements in an XML fragment
functx:path-to-nodeA path to an XML node (or sequence of nodes)
functx:dynamic-pathDynamically evaluates a simple XPath path

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