views:

468

answers:

4

I'm writing an XSL transform in Visual Studio. It is reporting that the semicolon in the following is an "unexpected token":

<xsl:param name="delimiters" select=";#" />

Does anyone know how to escape the semicolon? It hasn't shown up on any character lists I've found so far.

A: 

Try the following entity (semi-colon is ASCII character 59)...

&#59;
Josh Stodola
+4  A: 

Have you tried this?

<xsl:param name="delimiters" select="';#'"/>
wallenborn
+1 A common mistake and often harder to spot than this one.
Ishmael
+3  A: 

You presumably want the param delimiters to have the string ;# as it's value, given that that isn't a valid XPath expression? If so, you need to quote the attribute value:

<xsl:param name="delimiters" select="';#'" />

Note that the value is now wrapped in single quotes; this causes the attribute value to be interpreted as an XPath expression which returns a string.

NickFitz
This is also a possible alternative `<xsl:param name="delimeters">;#</xsl:param>`. This sometimes is more clear in some editors which smoosh together quote and apostrophe together.
Alexander Pogrebnyak
In that case, the value of the variable is actually a Result Tree Fragment containing a single text node, rather than a string. Of course this makes absolutely no difference in most cases, but it's worth noting. http://www.w3.org/TR/1999/REC-xslt-19991116#section-Result-Tree-Fragments
NickFitz
@NickFitz: Thanks, I didn't know that. Now that you say it, it is absolutely logical. :)
Tomalak
A: 

wallenborn is right. The reason is that a select attribute in XSL always expects an XPath expression. If you want to put a string literal there, you need to quote it.

Dan