xsl-list
[Top] [All Lists]

RE: xsl needed: sibilings with different parents

2004-09-08 00:36:04
<xsl:for-each select="BB/BB1">
<xsl:copy-of
select="/root/AA/AA1[/BB/BB1[position()]]"/>
</xsl:for-each>

You are using position() as a standalone expression for a 
predicate.  All 
predicates are converted to boolean true()/false() before they are 
used.  The position() function always returns a positive 
number, hence will 
always be converted to boolean true().  This qualifies all 
BB1 children of 
BB that may be present.

Ken is right that [position()] won't work, but he hasn't explained the
reason very clearly. Any predicate that is the numeric value [N] is treated
as shorthand for [position()=N], so the predicate [position()] is short for
[position()=position()] which of course is always true.

Generally speaking, any operation involving combining or comparing two
node-sets needs variables, except for a limited class of joins that can be
handled using the implicit existential semantics of operators like "=".
Perhaps someone better versed in predicate logic than I am can explain why
this is true.

Michael Kay



<Prev in Thread] Current Thread [Next in Thread>