I have a XSL as below :
<xsl:template match="/">
<xsl:variable name="vartext" select="''" />
....
<th>
<xsl:value-of select="$vartext"/>
</th>
I set the value of vartext using js, as below :
node = this.xsldoc.selectSingleNode('//xsl:variable[...]']');
node.setAttribute('select', sometext);
Accordint to the https://www.w3schools.com/xml/ref_xsl_el_variable.asp, If the select attribute contains a literal string, the string must be within quotes.
But the variable might containt a value like this "'Hey d'text '".
So when I wan to transform my XML using the XSL provided, it does not work. I even tried to replace ' with \'.
Update:
I tried the scape single quote in xslt concat function before posting the question and it did not help me.
The way that I use XSL is as below :
var res = xsltDo(this.xmldoc, this.xsldoc, this.html_element, iOptionParent);
xsltDo = function (xml, xsl, target, iOptionParent) {
try {
if (!iOptionParent) target.innerHTML = "";
var fragment = xml.transformNode(xsl);
target.innerHTML += fragment;
//$( window ).trigger( "XsltDone", [target] );
if (window.AC !== undefined) {
window.AC.onDomChange(target);
}
return true;
}
// si erreur on retourne une XsltError
catch (err) {
return new Error(err);
}
};