Re: [xsl] Quoting quote

Subject: Re: [xsl] Quoting quote
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 2 Sep 2005 10:23:18 +0100
On 9/2/05, andrew welch <andrew.j.welch@xxxxxxxxx> wrote:
> On 9/2/05, Lensch, Thomas <Lensch@xxxxxxxx> wrote:
> > Hi,
> >
> > i want to escape a single quote '
> >
> > Text with such quotes is used in JavaScript Calls. How Can i do this?
> >
> > Alternatively i could throw them away (because it's not much loss of
> > information).
> >
> > But the following doesn't work:
> >
> >         <xsl:value-of select="translate($tHtml, '&#x27;', 'x')"/>
> >
> > It produces
> >
> > javax.xml.transform.TransformerConfigurationException:
> > javax.xml.transform.TransformerException:
> > javax.xml.transform.TransformerException: misquoted literal... expected
> > single quote!
> >
> > What's the problem here?
>
> The character reference gets resolved by the xml parser before the
> xslt processor gets to see it, so you have three single quotes '''
> which throws the error.
>
> The usual way round this is define a variable
>
> <xsl:variable name="apos" select="'"/>
>
> (that's a single quote between the double quotes in there)
>
> then use translate($tHtml, '$apos;', 'x')
>

Sorry still haven't woken up:

<xsl:variable name="apos">'<xsl:variable>

Current Thread