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 9.5.0.2 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) = 3]][1]"/> 2) <xsl:variable name="table-ancestors" select="//*[descendant::node()=$table-node]"/> 3) <xsl:variable name="table-parents" select="//*[descendant::node()[. is $table-node]]"/> 4) <xsl:variable name="intersection" select="$table-ancestors intersect $table-parents"/> <xsl:message> 3.1) <xsl:text>table-parents</xsl:text><xsl:value-of select="count($table-parents)"/> </xsl:message> <xsl:message> 2.1) <xsl:text>table-ancestors</xsl:text><xsl:value-of select="count($table-ancestors)"/> </xsl:message> <xsl:message> 4.1) <xsl:text>intersection</xsl:text><xsl:value-of select="count($intersection)"/> </xsl:message> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: initial-page-number, KAATMAN Matthew | Thread | Re: [xsl] Inconsistency in descenda, Martin Honnen |
Re: [xsl] Data-driven XSLT code usi, Dimitre Novatchev | Date | Re: [xsl] Inconsistency in descenda, Martin Honnen |
Month |