XSL for XML to Excel: Using a Curly Bracket in Formula

311 Views Asked by At

How do I use curly brackets in an XSL which generates an Excel file from an XML?

I can accomplish what I want with an Excel formula, but it needs to use curly brackets list like:

    =LOOKUP(XXXX, {"NA","NF","NR","O"},{"NA","Completed","NR","Ongoing"}

Which I can not get the XSL to accept even when using the HTML indicators for the brackets and commas, I still get an error on the first comma after the first curly bracket.

    =LOOKUP(XXXX,{"NA","NF","NR","O"},{"NA","Completed","NR","OngoingNA"})

&123; = {
&#$$; = , (comma)

But I get an XML Error on the first command saying: "Expected token '{' found ','.

    =LOOKUP(XXXX,{"NA"-->,<--"NF,"NR","O"},{"NA","Completed","NR","Ongoing","NA"})
1

There are 1 best solutions below

0
On BEST ANSWER

I am guessing (!) you are trying to create a literal result element with an attribute containing curly braces. This is problematic, because the curly braces are interpreted as an attribute value template - i.e. the XSLT processor tries to evaluate the expression contained within.

To avoid this, you must either escape the curly braces by doubling them, or use the xsl:attribute instruction to specify the value as text. For example, both:

<elem attr="=SUM({{1,2}}*{{4,5}})"/>

and:

<elem>
    <xsl:attribute name="attr">=SUM({1,2}*{4,5})</xsl:attribute>
</elem>

will return the same result:

<elem attr="=SUM({1,2}*{4,5})"/>