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?


>     I believe I am confusing myself with an axis issue.

You're not understanding what xsl:value-of does, I think.

>     <root>
>            <tag name="greedy"></tag>
>            <tag name="lonely"></tag>
>     </root>
> 
> <xsl:template match="tag">
>     <xsl:value-of select="../tag/@name"/>
> </xsl:template match>
> 
> I get:
> 
> greedygreedy
> 
> that is, the first attribute twice.


In the XSL I quoted above, you have identified in your select="" a
node-set consisting of *two* 'name' attribute nodes. This pair is
implicitly passed to the string() function as per 

http://www.w3.org/TR/xslt#value-of
and its reference to
http://www.w3.org/TR/xpath#function-string

In short, string(foo), where foo is a node-set, returns the string-value
of the first node in the set. The string-value of an attribute node is the
attribute value.

The xsl template is apparently being instantiated twice, once for each
'tag' element, yet both times, the first node in that particular set
you've identified happens to be the same one.

-Mike


 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]