[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Inconsistency in descendant:: expressions?

Subject: [xsl] Inconsistency in descendant:: expressions?
From: Peter West <lists@xxxxxxxxx>
Date: Sun, 4 Aug 2013 16:22:43 +1000

I'm using Oxygen 15.0 with Saxon PE XSLT 2.

My XSLT is rusty, and I was struggling with the expression of particular
descendant expression. After a number of botched attempts, I cam up with two
versions that seemed to work. (Yes, I will use the ancestor:: axis, but I want
to know what is happening here.)

The following code operates on an xhtml document.

1)  <xsl:variable name="table-node" select="//*:table[//*:tr[count(*:td) =

2)  <xsl:variable name="table-ancestors"
3)  <xsl:variable name="table-parents" select="//*[descendant::node()[. is
4)  <xsl:variable name="intersection" select="$table-ancestors intersect

3.1)    <xsl:text>table-parents</xsl:text><xsl:value-of
2.1)    <xsl:text>table-ancestors</xsl:text><xsl:value-of
4.1)    <xsl:text>intersection</xsl:text><xsl:value-of

I was suspicious of the expression in 2) that derives $table-ancestors, but it
appeared to work. However, 2.1) results in a value one greater than 3.1); in
the particular case, 15 vs 14.

4.1) results in 14, so all but one on the nodes is common. The extra node, as
expected, is last node of $table-ancestors, which is the table node itself.

What is it about 2) that results in the extra value?

Peter West

"Ask and it will be given you; seek, and you will find; knock, and it will be
opened to you."

Current Thread