How to escape a semicolon in xsl:param?

2019-07-19 03:13发布

问题:

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.

回答1:

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.



回答2:

Have you tried this?

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


回答3:

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

&#59;


回答4:

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.