[xsl] XSL If Statement - repost with code

Subject: [xsl] XSL If Statement - repost with code
From: "Sumit Patki" <sumitpatki@xxxxxxxxx>
Date: Sun, 24 Aug 2008 14:43:39 -0400
Here is the xsl and xml I am using to write the state matrix in html
o/p only if matrix element has 1 in it.
None of the XSL:IF statements in the below code work.

I think I can change namespace to
"http://www.w3.org/1999/XSL/Transform"; instead of
"http://www.w3.org/TR/WD-xsl"; since the xsl file doesn't have any
other WD-XSL specific tags. Even though I change the namespace, it
doesn't work. The extension of the xsl file is .xsl I am not sure what
it will be for xslt.

XSL code:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>

<xsl:template match="/">
<HTML>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; FONT-SIZE: x-small">

       <table STYLE="border: 1px #000066 outset ;  border-collapse:
collapse" width="100%">

       <tr>
       <td colspan="2">
       <table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>

           <td width="100%" STYLE=" font-family: Arial, Helvetica,
sans-serif; font-size: 11px; color: #000000;">


               <xsl:apply-templates select="topic/detail/content" />

           </td>
         </tr>
       </table>
       <!-- matrix code start -->
       <table border="0" width="100%" >
       <tr>
         <td align="center" STYLE="font-weight: bold;"> <xsl:value-of
select="topic/detail/heading" /> </td>
       </tr>
       </table>


       <xsl:for-each select="topic/detail">
       <!-- <xsl:if test="matrix &gt; 0">       -->
       <xsl:if match=".[matrix=1]">
       <table border="2">
       <tr>
           <td align="center" STYLE="font-weight: bold;">
<xsl:value-of select="topic/detail/tableheading1" /> </td>
           <td align="center" STYLE="font-weight: bold;">
<xsl:value-of select="topic/detail/tableheading2" /> </td>
       </tr>
       <xsl:for-each select="topic/detail/table/state" >
       <tr>
           <td STYLE="font-weight: bold;vertical-align: top;">
<xsl:value-of select="statename" /> </td>
           <td STYLE="vertical-align: top;"> <xsl:apply-templates
select="statedesc" /> </td>
       </tr>
       </xsl:for-each>

       </table>
       </xsl:if>
       </xsl:for-each>
       <!--matrix code end-->


</td>
</tr>
</table>



</BODY>
</HTML>
</xsl:template>



<xsl:template match="topic/detail/content">

   <xsl:apply-templates />

</xsl:template>

<xsl:template match="br">
       <br><xsl:apply-templates /></br>
</xsl:template>


 <xsl:template match="text()"><xsl:value-of /></xsl:template>

</xsl:stylesheet>


XML Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="help.xsl" ?>
<topic>
       <detail>
               <pageid>123</pageid>
               <name>test</name>
               <content>test content <br /></content>
               <heading>State Matrix</heading>
               <matrix>1</matrix>
               <tableheading1>State Code/Name</tableheading1>
               <tableheading2>State Description</tableheading2>
               <table>
                       <state>
                               <statename>01/AL</statename>
                               <statedesc>Alabama</statedesc>
                       </state>
                       <state>
                               <statename>02/AK</statename>
                               <statedesc>Alaska</statedesc>
                       </state>
                       <state>
                               <statename>04/AZ</statename>
                               <statedesc>Arizona</statedesc>
                       </state>
               </table>
       </detail>
</topic>

Current Thread