[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 02:19 PM 04/03/2000 -0700, quagly wrote:
[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:
[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.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: Whose axis am I?
Subject: Re: Whose axis am I? From: "John E. Simpson" <simpson@xxxxxxxxxxx> Date: Mon, 03 Apr 2000 20:02:16 -0400 |
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@xxxxxxxxxxx | (Mark Twain)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Whose axis am I?, David Carlisle | Thread | Re: Whose axis am I?, quagly |
Re: Whose axis am I?, quagly | Date | Re: efficient filtering of XML file, Mike Brown |
Month |