cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Morandini <>
Subject Re: escaping characters
Date Thu, 24 Jul 2003 08:06:12 GMT
Mustafa Yalniz wrote:

> I get the info lets say lastname (Irish name could cause problem) from
>   <lastname><sunshine:getxml context="request" 
> path="/parameter/lastname"/></lastname>
> and apply sunshine transformer.
> later I insert it into the database as below.
>         insert into user_tb
>            set name = '<xsl:value-of select="name"/>',
>               ...
>                lastname = '<xsl:value-of select="lastname"/>'
> And the lastname has syntax error in case last name is e.g. O'Reilly.
> My question is is there a way in cocoon to process and replace the 
> characters with escape ones.

Since you're using XSL to prepare the SQL string, it makes sense to call 
an XSL template escaping those single quotes: such a template follows:

<xsl:template name="escape-apos">
   <xsl:param name="string" />
        <xsl:when test='contains($string, "&apos;")'>
	 <xsl:value-of select='substring-before($string, "&apos;")'/>
          <xsl:call-template name="escape-apos">
            <xsl:with-param name="string"
              select='substring-after($string, "&apos;")'/>
          <xsl:value-of select="$string"/>

Warning: this is not a fast approach ! A better one may be calling java 
methods within XSL (see XSL Extensions in Xalan).


                Luca Morandini
                GIS Consultant

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message