|
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
<KATG_DESCR><![CDATA[PFE'RD]]></KATG_DESCR>
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="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<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:call-template>'
);
</xsl:if>
</xsl:template>
<xsl:template name="apos">
<xsl:param name="x"/>
<xsl:choose>
<xsl:when test="contains($x,"'")">
<xsl:value-of select="substring-before($x,"'")"/>
<xsl:text>''</xsl:text>
<xsl:call-template name="apos">
<xsl:with-param name="x"
select="substring-after($x,"'")"/>"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$x"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Strings and apostrophies, Beat . Schaller | Thread | Re: Strings and apostrophies, Paul Prescod |
| Another problem with visibility of , Wolfgang May | Date | Re: Another problem with visibility, David Carlisle |
| Month |