functx:distinct-element-paths
The distinct paths of all descendant elements in an XML fragment
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.
Parameters |
Description |
|---|---|
nodes:node() |
the root(s) to start from |
Examples
The examples below use this input document:
<xsl:variable name="in-xml" as="item()*">
<authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors>
</xsl:variable>
XPath |
Results |
|---|---|
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') |
In a generator
Copy the snippet below and paste it in Freemapper, under a language node inside the generators element. Each line of the pattern prints the result of one example; to see them, run mi generate <project> <language> example-functx-distinct-element-paths.
[e] example-functx-distinct-element-paths
[e] vars
[e] in-xml
[e] select
[v] copy-of(parse-xml('<authors><author><fName>Kate</fName><lName>Jones</lName></author><author><fName>John</fName><lName>Doe</lName></author></authors>')/*)
[e] start
[e] match
[v] /
[e] body
[e] write-pattern
[v] examples
[e] patterns
[e] examples
[v] E01: {{ functx:distinct-element-paths($in-xml) }}
[v] E02: {{ functx:distinct-element-paths($in-xml/author[1]) }}