This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Whose axis am I?


"John E. Simpson" wrote:

> 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.
>

Thanks, this makes sense to me.

 The example is bizarre, it is just the simplest case I could think of that
 would demonstrate my confusion.  I have yet to post any of my actual work
as it does not illustrate any particular issue well, and would open me to public
humiliation, or at least a few jibes.

As you suspect, the number of greedies will equal the number of tag elements.
 "For each tag element go and get the attribute name of my parents first child."

Thanks to you.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]