XSL to Excel: Choose not processing formula

281 Views Asked by At

I declared a variable with a simple Excel formula (not the formula I will eventually use, just something simple for testing)

<xsl:variable name="nistcci" ss:Formula="=RC19"></xsl:variable>

Then I am trying to use a Choose to determine if the attribute data is empty, then return based on that determination.

<Cell ss:StyleID="stig_rules"> <!-- IA Control(s) -->
<Data ss:Type="String">
    <xsl:choose>
        <xsl:when test="STIG_DATA/VULN_ATTRIBUTE[node()='IA_Controls']/../ATTRIBUTE_DATA != ''">
            <xsl:value-of select="STIG_DATA/VULN_ATTRIBUTE[node()='IA_Controls']/../ATTRIBUTE_DATA" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$nistcci"/>
        </xsl:otherwise>
    </xsl:choose>
</Data>

This works if I do something simple like:

<xsl:variable name="nistcci">sean</xsl:variable>

But isn't working with a formula within a referenced variable.

Thanks for the help. Sean.

1

There are 1 best solutions below

3
michael.hor257k On

It's not clear what you want your variable to contain.

It is quite clear that the xsl:variable instruction cannot have a ss:Formula attribute, or any other attribute except select and (in XSLT 2.0) as.

Your variable needs to be constructed as:

<xsl:variable name="myVar" select="myExpr"/>

where myExpr must be a valid XPath expression.

Alternatively, you could use something like:

<xsl:variable name="myVar">
  <xsl:attribute name="ss:Formula">=RC19</xsl:attribute>
</xsl:variable>

to construct a variable that holds an attribute.