|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: conditional template matching & failure
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








