i need to do this:
<xsl:with-param name="callme" select="'validateInput(this,'an');'"/>
I've read Escape single quote in xslt concat function and it tells me to replace '
with '
I've done that yet its still not working..
Does anyone know how do we fix this?:
<xsl:with-param name="callme" select="'validateInput(this,'an');'"/>
Something simple that can be used in any version of XSLT:
I am frequently using the same technique for specifying a quote:
Then you can intersperse any of these variables into any text using the standard XPath function
concat()
:So, this transformation:
produces:
In XSLT 2.0 you can the character used as a string delimiter by doubling it, so
Another solution is to use variables:
Use " rather than ' (by using ' you are effectively nesting single quotation marks inside single quotation marks; you need to alternate single and double quotation marks as you nest, escaping as necessary).
This is a little tricky, but you need to invert the apostrophe and quotes, like this:
You're enclosing a string within one set of quotes, and the attribute value that contains it in another. In XSLT, which quotes you use are interchangeable in both cases, as long as you don't use the same one.
Previously, your
'
was being parsed as the value of thematch
attribute was being read, and it was trying to set the value of the select to'validateInput(this,'an');'
. Although this is technically a valid string value, when XSLT processes it, it fails to parse it because it's tries to read it as a string literal, which is terminated prematurely before thean
, as the same apostrophe is used there as was used to enclose the string.