Q
Problem solve Get help with specific problems with your technologies, process and projects.

XSL code question

I am fairly new to this. What I want to do is pass an attribute called Formula to the format number function in XSLT that calculates the Total Columns of a table. Examples of the attribute value :( sum(//M1000) , (sum(//M1005) div (sum(//M1003) + sum(//M1004)))*100 ). If I hard code, everything works but I want something dynamic. The problem appears to be that the value is passed as a string and thus the calc is not executed. Here is a snippet of the XSL:

 <xsl:for-each select="//Row[1]/*[@Type='Data']" >
      <xsl:variable name = "N" ><xsl:value-of select ="@Formula"/></xsl:variable>
      <xsl:choose >
       <xsl:when test ="@Format='0'"> 
           <td  class="Tablebody2" align="left" ><font size='1'><xsl:value-of select="format-number($N,'$ #,###,###')"/></font></td>
         </xsl:when> 
         <xsl:when test ="@Format='1'"> 
    <td  class="Tablebody2" align="left" ><font size='1'><xsl:value-of select="format-number($N,'0.0')"/></font></td>             
         </xsl:when> 
         <xsl:when test ="@Format='2'"> 
    <td  class="Tablebody2" align="left" ><font size='1'><xsl:value-of select="format-number($N,'0.00')"/></font></td>             
         </xsl:when> 
         <xsl:when test ="@Format='D'"> 
    <td  class="Tablebody2" align="left" ><font size='1'><xsl:value-of select="format-number($N,'$ #,###,###')"/></font></td>         
         </xsl:when> 
         <xsl:when test ="@Format='P'"> 
    <td  class="Tablebody2" align="left" ><font size='1'><xsl:value-of select="format-number($N,'##.##')"/>%</font></td>           
         </xsl:when> 
         
          <xsl:otherwise> 
          </xsl:otherwise> 
      </xsl:choose> 
 </xsl:for-each>
Thanks for your help in advance.
Details will depend on your XSLT implementation. Refer to the documentation on your XSLT implementation for parameter details of internal and extension functions.

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchAWS

SearchCloudComputing

TheServerSide.com

Close