At 2004-09-07 15:46 -0700, Anthony Ettinger wrote:
Agreed. I figured i could just use [position()] and it
works.
It shouldn't work because of the context in which it is being evaluated.
The only reason I'm responding is that I wouldn't want readers of the
archive to believe that it would work.
At 2004-09-07 14:53 -0700, Anthony Ettinger wrote:
Do you think something like this would work instead,
without using variables?
<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.
Next you have "/BB/BB1", but "/root" is your document element, so the node
set expression "/BB/BB1[position()]" will always evaluate to the empty
set. Let's assume the initial "/" was a typo, even without it the
predicate would be evaluating "BB" children of "AA1", and there are no "BB"
children of "AA1", so again it would create an empty set.
The empty set is then used as a predicate, which evaluates to false().
This disqualifies every AA1 child of AA child of root.
Therefore, the end result will be an empty result tree.
If you meant to say "/root/BB/BB1[position()]" as a predicate, your example
data set indicates this will always evaluate to a non-empty node set, which
will convert to true(), which will give you a copy of *every* AA1 child of
AA child of root for each of the BB1 children of "BB".
So, for the archive, just using [position()] won't give you the same
results that Michael took the time to give you.
I'm not sure how you could say that it works.
I hope this helps.
........................ Ken
--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal