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]

testing for matches using variables


hi,

i guess i found it, i made it like this:
<xsl:template>
  <xsl:choose>
   <xsl:when test="not(preceding::item[1]/name=name)">
    <xsl:value-of select="name"/>
   </xsl:when>
   <xsl:otherwise>same as above</xsl:otherwise>
  </xsl:choose>
</xsl:template>
but now, i have to use "$name" variable instead of "name" element.
any suggestions?
jian

><items>
><item>
>  <date>011020<date>
>  <stuff>stuff...</stuff>
>  <name>jane</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
><item>
>  <date>011020<date>
>  <stuff>stuff...</stuff>
>  <name>alfa</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
><item>
>  <date>011020<date>
>  <stuff>stuff...</stuff>
>  <name>alfa</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
><item>
>  <date>011021<date>
>  <stuff>stuff...</stuff>
>  <name>jane</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
><item>
>  <date>011021<date>
>  <stuff>stuff...</stuff>
>  <name>bata</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
><item>
>  <date>011020<date>
>  <stuff>stuff...</stuff>
>  <name>betta</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
><item>
>  <date>011021<date>
>  <stuff>stuff...</stuff>
>  <name>jane</name>
>  <stuff>stuff...</stuff>
>   .
>   .
></item>
></items>
>
>and i want an output like
>
>date               name
>-----------------------
>011020             jane
>same as above      alfa
>same as above      same as above
>011021             jane
>same as above      betta
>011020             same as above
>011021             jane
>
>that is to have "same as above" where the previouse date/name is the same.
>i've been trying something like:
>
><xsl:template match="item">
>  <xsl:choose>
>   <xsl:when test="not(preceding::item[position()=last()]/date=date)">
><!--for date-->
><!--   <xsl:when test="not(preceding::item[position()=last()]/name=name)">
>and this one for name-->
>    <xsl:value-of select="date"/><br/>
>   </xsl:when>
>   <xsl:otherwise>same as above</xsl:otherwise>
>  </xsl:choose>
></xsl:template>


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.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]