Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XSL transformation not works for code reuse [Thread Next] Re: XSL transformation not works for code reuseTo: NULL Date: 12/5/2005 2:43:00 PM "Rushi" <IMS.Rushikesh@g...> wrote in message
news:1133787883.601878.138710@z......
> Hi Joe and Magnus,
>
> Magnus, right now we already using ur approach....but it seems very
> ugly...as lots of code is required and if a single change comes in
> param then ll affect all subsiding templates....
OK, if I where to implement this, I would not use a for-each instruction to
begin with. Match templates are much more flexible in the long run.
Something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>My XSLT Testing</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="Books">
<table>
<tr bgcolor="BBCCAA">
<td>Book Name</td>
<td>Rating</td>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="Book">
<tr>
<xsl:attribute name="bgcolor">
<xsl:choose>
<xsl:when test="Rating > 4">red</xsl:when>
<xsl:otherwise>lightblue</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td>
<xsl:value-of select="Rating"/>
</td>
<td>
<xsl:value-of select="Name"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
// Magnus
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
