[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Strings and apostrophies

Subject: Re: Strings and apostrophies
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 26 Nov 1999 11:07:11 GMT
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,&quot;&apos;&quot;)">
<xsl:value-of select="substring-before($x,&quot;&apos;&quot;)"/>
<xsl:text>''</xsl:text>
<xsl:call-template name="apos">
     <xsl:with-param name="x"
          select="substring-after($x,&quot;&apos;&quot;)"/>"/>
</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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.