0

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.

Sean Perryman
  • 29
  • 1
  • 1
  • 7

1 Answers1

0

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.

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51
  • Using only XSL 1.0I'm trying to get the "=RC19" to populate into the resultant Excel worksheet as an Excel formula, not just as text. – Sean Perryman Oct 14 '16 at 13:24
  • Using only XSL 1.0. I'm trying to get the "=RC19" to populate into the resultant Excel worksheet as an Excel formula, not just as text. I'm trying to get this into the portion. Even the variable+attribute proposed above doesn't populate the excel cell(s). They are still blank. – Sean Perryman Oct 14 '16 at 13:27
  • @SeanPerryman AFAIK, in order to have a formula, you need to add a `ss:Formula` attribute to the `ss:Cell` element. Your `xsl:choose` is a child of `ss:Data`, that's too late. – michael.hor257k Oct 14 '16 at 13:36