473,325 Members | 2,608 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,325 software developers and data experts.

Leave " alone in transformation

I have an XML file that has a free form comment field in which the
data provider, very kindly, already uses """ when writing
"doesn't", I have doesn't .

it's PERFECT, because that xml is then fed to an XSLT sheet that
transforms this text into a sql insert statement. UNFORTUNATELY, XSLT
translates doesn't into doesn't in the output, which then
destroys my sql statement. How do I tell my XSLT to leave well-enough
alone ? I know it has to be easy, but I just don't get it right now
in spite of looking online.

Also, bear in mind I'm your friendly neighborhood XSLT newbie. :)

Thanks a lot.
Nov 14 '08 #1
3 2350
Li**********@gmail.com wrote:
I have an XML file that has a free form comment field in which the
data provider, very kindly, already uses """ when writing
"doesn't", I have doesn't .

it's PERFECT, because that xml is then fed to an XSLT sheet that
transforms this text into a sql insert statement. UNFORTUNATELY, XSLT
translates doesn't into doesn't in the output, which then
destroys my sql statement. How do I tell my XSLT to leave well-enough
alone ? I know it has to be easy, but I just don't get it right now
in spite of looking online.
No, it is not easy. You can't preserve entity references when parsing
XML and using XSLT as the XSLT data model does not know any entity
references. So XSLT uses an XML parser to build its data model, an input
tree, and then transforms that input tree into a result tree. The result
tree can then optionally be serialized as XML or HTML or plain text.
If you want to ensure that certain characters are escaped with entity
references in the output the XSLT processor creates then you need to
look at processor specific extensions to do that. Or you can look into
XSLT 2.0 and character maps http://www.w3.org/TR/xslt20/#character-maps.
Note that both ways will not simply allow you to preserve entity
references in the input, instead you will create entity references in
the output.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 15 '08 #2
Martin Honnen <ma*******@yahoo.dewrites:
Li**********@gmail.com wrote:
.. . .
>... UNFORTUNATELY, XSLT
translates doesn&apos;t into doesn't in the output, which then
destroys my sql statement. How do I tell my XSLT to leave well-enough
alone ? ...
.. . .
references in the output the XSLT processor creates then you need to
look at processor specific extensions to do that. Or you can look into
XSLT 2.0 and character maps
http://www.w3.org/TR/xslt20/#character-maps. Note that both ways will
not simply allow you to preserve entity references in the input,
instead you will create entity references in the output.
I suppose sql language is not usually envisioned as a translation
target in the xml world.

Nuggets of CDATA in an xml document are not supposed to be decision
points. Nonetheless it's possible but cpu-expensive to look at
individual characters. (The expense may be reasonable in the OP's
context.)

This is why the exclusion of SDATA character entities was controversial
in early days.

-- Bill

Nov 17 '08 #3


"William F Hammond" <ha*****@csc.albany.eduwrote in message
news:i7************@hilbert.math.albany.edu...
Martin Honnen <ma*******@yahoo.dewrites:
>Li**********@gmail.com wrote:
. . .
>>... UNFORTUNATELY, XSLT
translates doesn&apos;t into doesn't in the output, which then
destroys my sql statement. How do I tell my XSLT to leave well-enough
alone ? ...
. . .
>references in the output the XSLT processor creates then you need to
look at processor specific extensions to do that. Or you can look into
XSLT 2.0 and character maps
http://www.w3.org/TR/xslt20/#character-maps. Note that both ways will
not simply allow you to preserve entity references in the input,
instead you will create entity references in the output.

I suppose sql language is not usually envisioned as a translation
target in the xml world.
I think it quite a common requirement though.
I just do the usual sanitisation on the SQL though, replacing a single quote
with two single quotes before running it.
If the OP is is using XSLT 2.0 it's trivial with the replace function, if
not there are plenty of example templates online that do string replacement.

--

Joe Fawcett
http://joe.fawcett.name

Nov 21 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DC Gringo | last post by:
I have an image control (that pulls an image off an ESRI map server): <ASP:IMAGE ID="imgZonedCountry" RUNAT="server"></ASP:IMAGE> In the code behind I am setting the ImageURL to a String value...
2
by: Eric Osman | last post by:
Hi, I'm looking for a javascript function that will convert input such as this: <CLUB Code=" into this: &lt;CLUB Code=&quot;
4
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following...
5
by: martin | last post by:
Hi, I would be extremly grateful for some help on producing an xml fragemt. The fragment that I wish to produce should look like this <Addresses> <Address>&qout;Somebody's Name&quot;...
7
by: DC Gringo | last post by:
I am having a bear of a time with setting a URL query string as a text value in a dropdownlist and Server.URLEncode does not seem to do its job. theFullLink = theLinkPrefix &...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
13
by: Ragnar | last post by:
Hi, 2 issues left with my tidy-work: 1) Tidy transforms a "&amp;" in the source-xml into a "&" in the tidied version. My XML-Importer cannot handle it 2) in a long <title>-string a wrap is...
11
by: LionelAndJen | last post by:
I have an XML file that has a comment field in which the data provider, very kindly, already uses "&quot;" when writing "doesn't", I have doesn&apos;t . it's PERFECT, because that xml is then fed to...
0
by: LionelAndJen | last post by:
I have an XML file that has a free form comment field in which the data provider, very kindly, already uses "&quot;" when writing "doesn't", I have doesn&apos;t . it's PERFECT, because that xml is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.