473,383 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Replacing a single quote with 2 single quotes in XSL

The @name field can contain a single quote in it such as: Mike O'Grady.
Since this is creating and SQL statement on the server side, it will not process the name if it has a single quote in it. Id' like to replace that single quote with 2 single quotes without destroying th rest of th data in the field. Currently I replace a single quote with a "^" and then do a replace of that on the server side, see last <zz>. That statement is ecexuted on the other side. Please help, if there is help......Don.
Here;s the crude XSL doc:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2.  <!-- ******************************************************************** -->
  3.  <!-- * This XSL is used to transform the mampcp document to * -->
  4.  <!-- * SQL script that will insert the decomposed data to our mampcpwrk file * -->
  5.  <!-- * table. * -->
  6.  <!-- ******************************************************************** -->
  7.  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
  8.     xmlns:php="http://php.net/xsl">
  9.     <xsl:output method="text" indent = "no" encoding="UTF-8"/>
  10.     <!-- Process complete tree starting from root-->
  11.     <xsl:template match="pccList">
  12.    <!-- Process each repeating MEMBER-INFO -->
  13.     <xsl:variable name="old">'</xsl:variable>
  14.     <xsl:variable name="new">^</xsl:variable>
  15.       <xsl:for-each select="pcc">
  16.     insert into  mampcpwrk (name,prcode,wrkph2,adrln1,zipcod,zipcod4,titlcd,
  17.      provno,wrkph1,adrln2,citycd,stacod) 
  18.     values (&apos;<xsl:value-of                                                 select="translate(@name,$old,$new)"/>&apos;,
  19.     &apos;<xsl:value-of select="translate(@cde_service_loc,$old,$new)"/>&apos;,
  20.     &apos;<xsl:value-of select="translate(@num_phone,$old,$new)"/>&apos;,
  21.     &apos;<xsl:value-of select="translate(@adr_mail_strt1,$old,$new)"/>&apos;,
  22.     &apos;<xsl:value-of select="translate(@adr_mail_zip,$old,$new)"/>&apos;,
  23.     &apos;<xsl:value-of select="translate(@adr_mail_zip_4,$old,$new)"/>&apos;,
  24.     &apos;<xsl:value-of select="translate(@nam_title,$old,$new)"/>&apos;,
  25.     &apos;<xsl:value-of select="translate(@id_provider,$old,$new)"/>&apos;,
  26.     &apos;<xsl:value-of select="translate(@num_area_code,$old,$new)"/>&apos;,
  27.     &apos;<xsl:value-of select="translate(@adr_mail_strt2,$old,$new)"/>&apos;,
  28.     &apos;<xsl:value-of select="translate(@adr_mail_city,$old,$new)"/>&apos;,
  29.     &apos;<xsl:value-of select="translate(@adr_mail_state,$old,$new)"/>&apos;);
  30.      </xsl:for-each> 
  31.      <zz>update mampcpwrk set name=replace(name,&apos;^&apos;,&apos;&apos;&apos;&apos;);</zz>
  32.     </xsl:template>
  33.  </xsl:stylesheet>
Dec 20 '07 #1
0 2072

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
4
by: sankofa | last post by:
hi, i can't seem to be able to escape my single quote properly... is it even possible in javascript? this is a portion of my code.. var DLEWIS="Pastor Lewis"; .... Sermon is a yser-defined...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
1
by: asd987 | last post by:
Hi, Ihave to print a field (type memo) to a file. I know how to do that ;-), but there's one complication: all single quotes (') in the record must be replaced by <backslash> + <single quote>...
7
by: gar | last post by:
Hi, I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code text= Replace(text, """", "'" This works fine (for normal double quotes).The problem...
4
by: Justin Fancy | last post by:
Hi everyone, I need to replace all instances of a double quote(") with two single quotes('') in a text file. I already have some replacements of strings going on, but I tried this one, but the...
2
by: Reporter | last post by:
I got the following example from http://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/index.html : echo '<tr><td>First name:</td><td><input type="text" name="first_name"...
5
by: samslists | last post by:
Hi... Here's a weird problem...I'm trying to escape a bunch of data to put into a database. Here's what I have: def escape(string): """ Escape both single quotes and blackslashes
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.