Re: Strings and apostrophies

Subject: Re: Strings and apostrophies
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 26 Nov 1999 11:07:11 GMT
> INSERT into XYZ values ('HAND''YS') 	(note: two apostrophies !)

> And a sample XML-record:
Thanks for supplying test data (it's much easier to help when people do
that, although actually that record didn't have a problem with
apostophies:-) I changed it to 

Then the style below produces

      insert into xyz
                  values (  '7545'
                          , 'PFE''RD'

which is I think what you want.

Note your example code used normalize(). In the later drafts and in the
final REC version of xsl this function is called normalize-space().
If your xsl system is old you will need to change that back and
maybe change xsl:with-param to xsl:param, or better upate your xsl
program to one that matches thew xslt 1.0 recommendation.

Anyway this is some code that works on that example at least.

<xsl:stylesheet xmlns:xsl="";

<xsl:output method="xml" indent="yes"/>

  <xsl:template match="record0">
    <xsl:if test="normalize-space(LEVEL_DESCR)='KATG'">
      insert into xyz
                  values (  '<xsl:value-of select="KATG_ID"/>'
                          , '<xsl:call-template name="apos">
                    <xsl:with-param name="x" select="KATG_DESCR"/>

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

 XSL-List info and archive:

Current Thread