-1

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"})
Sean Perryman
  • 29
  • 1
  • 1
  • 7
  • 2
    Is this question about an XSLT stylesheet? If so, please show that code. Also show the XML input and expected Excel output. Help: http://stackoverflow.com/help/mcve. – Mathias Müller Feb 14 '16 at 16:53

1 Answers1

1

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})"/>
michael.hor257k
  • 113,275
  • 6
  • 33
  • 51