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);
}
};
node.setAttributethen you shouldn't have to worry about escaping, as that would only apply to the initial XSLT file before it is parsed and processed. I think you might need to explain more about the process you are using (for example, how are you reading and applying the XSLT), and explain exactly what you mean by "it does not work". Thanks!xsl:param) instead of trying to manipulate the XSLT in this way.xsl:paramparameter? Remember that modifying source always creates a risk of injection attacks unless you take immense care.xsl:paramdeclaration as suggested by Dr. Kay. Although not standard, in Javascript there is a good cross browser interface XSLTProcessor.