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

RE: Replace characters in a node and all of its descen

Subject: RE: Replace characters in a node and all of its descendents
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 30 Sep 2003 12:07:30 -0400
xml replace characters
[ Sergiu Ignat]
> 
> I need to generate an SQL "INSERT INTO" statement from an xml 
> document.
> One of the columns must hold the string representation of an 
> XML node with all of its descendents.

I take it that you mean the xml itself, angle brackets and all, rather
than just the concatenated character data?

> To insert this node as a string I must replace each single 
> quote with other two single quotes for conformance with SQL syntax.

The best thing would be to post process with sed, python, perl, awk,
etc.  If for some reason you cannot do that, how hard it would be
depends on whether there are any attributes.  

If there are no attributes, then you only have to change the single
quotes in element content.  With xslt 1.0, you would have to use the
processor's xxx:node-set extension to turn the copy-of result tree
fragment into a node set, which you could then process with a recursive
template - or fsxsl - there are examples on Dave Pawson's FAQ site.

If there are attributes, then things would be much harder, since if you
used escaped quotes withing a start tag, you would no longer have xml.
I think that you would have to walk the entire tree, producing escaped
text where there used to be markup, and then fixing up single quotes as
above.  That would be fairly unpleasant and probable require the use of
disable-output-escaping, which is not portable across all processors.

Post-processing would be much better!

Cheers,

Tom P

 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.