[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Inconsistency in descendant:: expressions?

Subject: Inconsistency in descendant:: expressions?
From: Peter West <lists@xxxxxxxxx>
Date: Sun, 4 Aug 2013 16:22:43 +1000
 Inconsistency in descendant:: expressions?
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.