Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSL transformation not works for code reuse

From: "Magnus Henriksson" <magnus.henriksson@--------------.--->
To: 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 &gt; 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




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent