Greetings.
Looking for a little better understanding of the results I'm getting.
--------------------
My initial use of abbreviated XPath axes like simple "../../@name"
worked. (See # 1 down below)
But then exploring *going up one more level* (../) so I could
then *explicitly name* the element did _not_ work:
"../../../span-fill/@name" (See # 2 down below)
[ I guess I thought the XPath would be more readable if
I showed *by name* which element had the @name attribute
vs. leaving it just at a long string of "../../../" ]
parent::
Further looking into the parent::node() attribute showed me that it
behaved the same as the use of both ../../ and ../../../
(that's what it's supposed to do, I'm sure!). (See #s 3 and 4 below)
axis::
Finally, the use of "ancestor::span-fill/@name" did just what I wanted:
it got the right data, and shows
the name of the element explicitly. (See # 5 below)
-------------------------------------------
My basic question: what is going on that
A. "../../@name"
is so different from
B. "../../../span-fill/@name"
?
Or put another way,
what is it that the ancestor:: axis does
to help the correct nodeset selection, such that it works,
vs. whatever nodeset being built up by "B." that
evidently does not (correctly?) test the span-fill/@name value?
C. "ancestor::span-fill/@name"
A. YES. Gets correct info (a single <span-value> element contents:
"(California Prima OLB)"
B. NO. Gets the contents of ALL the <span-value> elements:
"(California Prima OLB California Prima NO OLB California SAVING OLB
etc. etc. )"
C. YES. Works correctly, like A.
========================
XML
========================
<span-fills>
<span-fill name="checking-product">
<segment-permutation name="1ca_2olb">
<span-value>California Prima OLB</span-value>
</segment-permutation>
<segment-permutation name="1ca_2nonolb">
<span-value>California Prima NO OLB</span-value>
</segment-permutation>
...
<span-fill name="saving-product">
<segment-permutation name="1ca_2olb">
<span-value>California SAVING OLB</span-value>
</segment-permutation>
...
</span-fill>
...
<span-fills>
========================
XSLT
========================
<xsl:for-each
select="document($basedir_span-fillLookupFilenameExt)//span-fills/span-f
ill">
<xsl:apply-templates
select="segment-permutation/span-value[ancestor::span-fill/@name=$span-i
d]
[ancestor::segment-permutation/@name=$segment]/node()"/>
Thanks very much,
William Reilly
wreilly(_at_)digitas(_dot_)com
Boston, Massachusetts, U.S.A.
===================================
1. "../../"
YES (1st approach)
<xsl:apply-templates
select="segment-permutation/span-value[../../@name=$span-id][../@name=$s
egment]"/>
2. "../../../span-fill/"
NO (2nd approach)
<xsl:apply-templates
select="segment-permutation/span-value[../../../span-fill/@name=$span-id
][../../segment-permutation/@name=$segment]"/>
3. "parent::node()/parent::node()/"
YES (emulating 1st approach, but with 'parent::' axis)
<xsl:apply-templates
select="segment-permutation/span-value[parent::node()/parent::node()/@na
me=$span-id][parent::node()/segment-permutation/@name=$segment]"/>
4. "parent::node()/parent::node()/parent::node()/span-fill/"
NO (emulating 2nd approach, but with 'parent::' axis)
<xsl:apply-templates
select="segment-permutation/span-value[parent::node()/parent::node()/par
ent::node()/span-fill/@name=$span-id][parent::node()/parent::node()/segm
ent-permutation/@name=$segment]"/>
5. "ancestor::span-fill/"
YES (arguably emulating 2nd approach, but with 'ancestor::' axis)
<xsl:apply-templates
select="segment-permutation/span-value[ancestor::span-fill/@name=$span-i
d][ancestor::segment-permutation/@name=$segment]"/>
+++ /END
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list