[xslt] Escaping both types of quotes in a single string



I have a script-generator that stuffs a string into a variable like:

    <xsl:variable name="x" select="'boring string'"/>

This works fine unless the string is not-so-boring, like
the string:

  Don't drop the "ball".

Since both types of quotes are used, I can't just use
&quot; and &apos; to escape the string:

    <xsl:variable name="x" select="&quot;Don&apos;t drop the &quot;ball&quot;.&quot;"/>

XPath error : Invalid expression
"Don't drop the "ball"."
                 ^

Using &#x22; and &#x27; have similar issues.

I could stuff the expression inside the variable, but there
are other cases where the string is an expression, like:

    <xsl:variable name="x" select="my:foo(&quot;&quot;&apos;&quot;)"/>

(Where I want the string to be "\"\'").

I don't see a means to escape both types of quotes inside a single
attribute.  Is there no straight-forward means of doing this?

Thanks,
 Phil

% xsltproc --version
Using libxml 20703, libxslt 10124 and libexslt 813
xsltproc was compiled against libxml 20703, libxslt 10124 and libexslt 813
libxslt 10124 was compiled against libxml 20703
libexslt 813 was compiled against libxml 20703


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]