Re: [xsl] Show YEAR once if the YEAR same as preious element by xsl

Subject: Re: [xsl] Show YEAR once if the YEAR same as preious element by xsl
From: S Woodside <sbwoodside@xxxxxxxxx>
Date: Sun, 27 Apr 2003 02:41:22 -0400
You have to abandon the procedural mindset ;-) use modes.

try this:
<xsl:apply-template select="row[@year=2001]" mode="year_only"/>
<xsl:apply-template select="row[@year=2001]" mode="month"/>

<xsl:template match="row" mode="year_only">
  <xsl:value-of select="@year"/><xsl:text>/</xsl:text>
</xsl:template>
<xsl:template match="row" mode="month">
  <xsl:value-of select="@month"/><br/>
</xsl:template>

...just pseudo-code haven't tried it, but that's the hard part. Grouping the years shouldn't be too hard.

simon

On Sunday, April 27, 2003, at 02:24 AM, Cheung Tin Po wrote:

hi expert,
sorry for the syntax error

<record>
<row year="2001" month="1"/>
<row year="2001" month="2"/>
<row year="2001" month="3"/>
<row year="2001" month="4"/>
<row year="2002" month="1"/>
<row year="2002" month="2"/>
<row year="2002" month="3"/>
<row year="2003" month="1"/>
<row year="2003" month="2"/>
</record>




From: "Cheung Tin Po" <timothy298@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
CC: timothy298@xxxxxxxxxxx
Subject: [xsl] Show YEAR once if the YEAR same as preious element by xsl
Date: Sun, 27 Apr 2003 03:57:44 +0000


hi expert,

i get the following XML file

<record>
<row year="2001" month="1">
<row year="2001" month="2">
<row year="2001" month="3">
<row year="2001" month="4">
<row year="2002" month="1">
<row year="2002" month="2">
<row year="2002" month="3">
<row year="2003" month="1">
<row year="2003" month="2">
</record>

i want to transform it to html with the following result

2001/1
    2
    3
    4
2002/1
    2
    3
2003/1
    2


as XSLT cannot store the variable so i cannot think any method to should the result.


:<
From Timothy


_________________________________________________________________
No masks required! Use MSN Messenger to chat with friends and family. http://go.msnserver.com/HK/25382.asp



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




_________________________________________________________________
No masks required! Use MSN Messenger to chat with friends and family. http://go.msnserver.com/HK/25382.asp



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




-- anti-spam: do not post this address publicly www.simonwoodside.com -- 99% Devil, 1% Angel


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



Current Thread