functx:precedes-not-ancestor
Whether an XML node precedes another without being its ancestor
Description
The functx:precedes-not-ancestor function returns a boolean value indicating whether $a precedes $b without being its ancestor. If either argument is the empty sequence the function returns false.
Parameters |
Description |
|---|---|
a:node() |
the first node |
b:node() |
the second node |
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:precedes-not-ancestor($in-xml//author[1],$in-xml//author[2]) |
true |
functx:precedes-not-ancestor($in-xml//author[1], $in-xml//author[1]/fName) |
false |
functx:precedes-not-ancestor($in-xml//author[2],$in-xml//author[1]) |
false |
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-precedes-not-ancestor.
[e] example-functx-precedes-not-ancestor
[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:precedes-not-ancestor($in-xml//author[1],$in-xml//author[2]) }}
[v] E02: {{ functx:precedes-not-ancestor($in-xml//author[1], $in-xml//author[1]/fName) }}
[v] E03: {{ functx:precedes-not-ancestor($in-xml//author[2],$in-xml//author[1]) }}