1

Creating an XSL to translate XML into Excel. Part of that is a formula which performs a lookup on another worksheet. However, I want to transform/translate the return, so I figured an xsl:choose would be best.

But I don't know how to reference my ss:Formula inside the xsl:choose?

    <Cell ss:StyleID="RARs17"
        ss:Formula="=INDEX('{$vhostname}'!R2C6:R{$vuln_count+7}C6,MATCH(RC3,'{$vhostname}'!R2C14:R{$vuln_count+7}C14,0))>
        <Data ss:Type="String">
        <xsl:choose>
            <xsl:when test="ss:Formula = 'NF'">Completed</xsl:when>
            <xsl:when test="ss:Formula = 'NR'">NR</xsl:when>
            <xsl:when test="ss:Formula = 'O'">Ongoing</xsl:when>
            <xsl:when test="ss:Formula = 'NA'">NA</xsl:when>
            <xsl:otherwise><xsl:value-of select="ss:Formula" /></xsl:otherwise>
        </xsl:choose></Data>
    </Cell> <!-- Status, looks up Result -->
Sean Perryman
  • 29
  • 1
  • 1
  • 7
  • Define the formula as a function and use that in the expression. – Jim Garrison Feb 14 '16 at 03:34
  • If you are saying you want XSLT to process the results of an Excel formula, this is not possible. By the time the Excel is run, the XSLT will be long gone. XSLT is just generating Spreadsheet ML which is then later processed by Excel. Imagine you were creating the Excel XML manually in Notepad. How would you do it? You probably need two cells in your Excel. One that simply has the current formula specified, and the other that uses the Excel `IF` multiple times to convert the code to text. – Tim C Feb 14 '16 at 09:41

1 Answers1

1

You cannot refer to nodes of the output tree. Define the formula as a variable and use that in the attribute as well as in the expression.


Edit

I probably misunderstood what you meant by "reference my ss:Formula". If you want to consider the result of the actual lookup as performed by Excel, that won't work - for reasons explained by Tim C in his comment.

You could, however, perform the lookup yourself using XSLT methods such as key.

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51