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]
Other format: [Raw text]

selection on position


hi i have a problem which is not working the way i wud have thot it should work.

i have an xml that looks like
<colors>
<color>red</color>
<color>blue</color>
<color>green</color>
</colors>

and i want to match a pattern based on a condition.. 
( this is a purely experimental example.. and is intended to understand xsl )

i want to get the second color element ie blue

i can do something like

 
<xsl:template match="colors">
<xsl:value-of select="color[position()=2]"/>
</xsl:template>
 

---or---

<xsl:template match="/">
<xsl:value-of select="/colors/color[position()=2]"/>
</xsl:template>

-------------------------------------------------

however, something like 

<xsl:template match="/colors/color[position()=2]">
<xsl:value-of select="."/>
</xsl:template>

would gimme all colors, ignoring the condition...

I am not sure what happens behind.. any explaination to this is appreciated

thanks

--------------------------------------------------------------
Sent with "Me-Mail", Boltblue's FREE mobile messaging service.
http://www.boltblue.com


 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]