home contribute faq download

FunctX XSLT Functions

functx:precedes-not-ancestor

Whether an XML node precedes another without being its ancestor

Google
Webxsltfunctions.com

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.

Arguments and Return Type

NameTypeDescription
$a node()? the first node
$b node()? the second node
return value xs:boolean

XSLT Function Declaration

See XQuery definition.
XSLT 2.0 Syntax:
<xsl:function name="functx:precedes-not-ancestor" as="xs:boolean"
              xmlns:functx="http://www.functx.com" >
  <xsl:param name="a" as="node()?"/>
  <xsl:param name="b" as="node()?"/>

  <xsl:sequence select="
   $a &lt;&lt; $b and empty($a intersect $b/ancestor::node())
 "/>

</xsl:function>

Examples

<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>
XSLT ExampleResults
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

See Also

functx:follows-not-descendantWhether an XML node follows another without being its descendant
functx:first-nodeThe XML node in a sequence that appears first in document order

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C XML Query Working Group, XQuery 1.0: An XML Query Language, http://www.w3.org/TR/xquery/(name was changed from precedes to precedes-not-ancestor for clarity)
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley