This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Whose axis am I?
- To: xsl-list at mulberrytech dot com
- Subject: Re: Whose axis am I?
- From: "John E. Simpson" <simpson at polaris dot net>
- Date: Mon, 03 Apr 2000 20:02:16 -0400
- Reply-To: xsl-list at mulberrytech dot com
At 02:19 PM 04/03/2000 -0700, quagly wrote:
><xsl:template match="tag">
> <xsl:value-of select="@name"/>
></xsl:template match>
[Aside: remove "match" from the end tag there.]
Here, you're telling the processor "Whenever you encounter an element named
'tag' in the source tree, place into the result tree the value of its
'name' attribute." With two different tag elements, each of which has a
different value for its name attribute, you get two different attribute values.
But:
><xsl:template match="tag">
> <xsl:value-of select="../tag/@name"/>
></xsl:template match>
[Aside: remove "match" from the end tag there.]
If I may say, this is a rather bizarre select expression. The template
match is identical to the previous one, e.g. "Whenever you encounter an
element named 'tag' in the source tree...." But the select statement here
is saying, "...then *back up to the parent of that 'tag' element*, get the
child of that parent named 'tag' and place into the result tree the value
of its 'name' attribute." What makes this bizarre is that of course the
"tag" element doesn't have just ONE child named tag, it's got TWO. Since
you can't get "THE attribute value" of "TWO tag elements' name attributes,"
the processor is picking the value of the FIRST tag element's name
attribute, no matter which of the original tag elements it's processing. (I
ran this with XT and assume that other processors will do the same.)
I haven't tested it, but I bet if you added 8 or 10 or 159 tag elements,
you'd have "greedy" in the result tree that many times.
================================================================
John E. Simpson | "I was gratified to be able to answer
http://www.flixml.org | promptly. I said I don't know."
simpson@polaris.net | (Mark Twain)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list