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

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

Regards,

------------------------------------------
               Luca Morandini
               GIS Consultant
              [EMAIL PROTECTED]
http://space.virgilio.it/kumora/index.html
------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to