|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Strings and apostrophies
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








