Subject: RE: [xsl] conditional template matching & failure From: Jarno.Elovirta@xxxxxxxxx Date: Tue, 16 Jul 2002 08:42:31 +0300 |
Hi, > I tried doing something like: > > <xsl:template match="schedule[@username=$thisUser]"> Instead of trying to set the predicate in the match pattern (which you cant' do), select only the nodes you want to process (schedule[@username=$thisUser]) and write a template to match them (schedule). > <table> > <xs:apply-templates select="semester[season=$thisSeason and > year=$thisYear]"/> > </table> > </xsl:template> > > <xsl:template match="semester[season=$thisSeason and year=$thisYear]"> Same applies here. You've already selected the nodes with the correct season and year in the apply-templates above, so here you can just make the template match semester elements. > <xsl:for-each select="course"> > <tr><td><xsl:value-of select="title"/></td></tr> > </xsl:for-each> > </xsl:template> So something like this: <xsl:template match="schedules"> <xsl:choose> <xsl:when test="schedule[@username = $thisUser]"> <xsl:apply-templates select="schedule[@username = $thisUser]" /> </xsl:when> <xsl:otherwise>not found</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="schedule"> <table> <xsl:apply-templates select="semester[season = $thisSeason and year = $thisYear]"/> </table> </xsl:template> <xsl:template match="semester"> <xsl:for-each select="course"> <tr> <td> <xsl:value-of select="title"/> </td> </tr> </xsl:for-each> </xsl:template> Cheers, Jarno XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] conditional template matc, Michael Kay | Thread | [xsl] Matching node by its position, Agaram Madhavaraju |
Re: Re: [xsl] Re: WML input problem, ashu t | Date | [xsl] Matching node by its position, Agaram Madhavaraju |
Month |