Re: String replacement in Cocoon
Ah, I see. If you're using XSP and assigning the strings to variables, the escaping is taken care of automatically for you: I didn't know that. That would work if I had only a single insert statemment, but unfortunately, I'm looping over a collection of nodes in an xml document and generating an insert for each node of the collection. With this approach, it seems I'd have to write the java to extract the collection and then loop, generating an esql insert statement for each. It feels ad hoc even if I could make it work quickly. For right now, rather than generating SQL where special characters have to be escaped, I've decided to use cocoon to generate a text file where the characters do not need to be escaped and then use SQLLDR to load the data. I believe my previous problem was my failure to recognize an XSP page can only be a generator. In order to do what I want, I actually need to write a transformer, which I'll learn to do later when I have a little more time. I-Lin Kuo, Ann Arbor, MI Macromedia Certified ColdFusion 5.0 Advanced Developer Sun Certified Java 2 Programmer Ann Arbor Java Users Group (http://www.aajug.org) _ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String replacement in Cocoon
On Mon, 24 Feb 2003, I-Lin Kuo wrote: I didn't know that. That would work if I had only a single insert statemment, but unfortunately, I'm looping over a collection of nodes in an xml document and generating an insert for each node of the collection. With this approach, it seems I'd have to write the java to extract the collection and then loop, generating an esql insert statement for each. It feels ad hoc even if I could make it work quickly. Ah, ouch. One thought does occur to me: would it be worth storing the XML in an XML db like XIndice instead? It would save the XML-Text conversion step, and you'd be able to use XPath to pull text back out. I believe my previous problem was my failure to recognize an XSP page can only be a generator. In order to do what I want, I actually need to write a transformer, which I'll learn to do later when I have a little more time. Good luck! Andrew. -- Andrew SavoryEmail: [EMAIL PROTECTED] Managing Director Tel: +44 (0)870 741 6658 Luminas Internet Applications Fax: +44 (0)700 598 1135 This is not an official statement or order.Web:www.luminas.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
String replacement in Cocoon
I'm trying to replace something like SQLStatement INSERT INTO MyTable(text) VALUES (' What's the matter?') /SQLStatement with SQLStatement INSERT INTO MyTable(text) VALUES ('\ What''s the matter\?') /SQLStatement where internal 's are replaced by '' and ? and are escaped by a backslash. I know how to do this using regular expressions, so if I could assign the value of //SQLStatement into a java variable in an XSP page, I'd be OK. I'd like to take the contents of the first SQLStatement and pipe it into an XSP page (while preserving whitespace) but can't figure out how to do that. Is this the right approach, or is there another way? P.S. I've read Jeni Tennison's string replacement method at http://www.dpawson.co.uk/xsl/sect2/StringReplace.html#d7016e13 but this won't quite do it as I need to use back references I-Lin Kuo, Ann Arbor, MI Macromedia Certified ColdFusion 5.0 Advanced Developer Sun Certified Java 2 Programmer Ann Arbor Java Users Group (http://www.aajug.org) _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String replacement in Cocoon
Hi, On Sun, 23 Feb 2003, I-Lin Kuo wrote: I'm trying to replace something like SQLStatement INSERT INTO MyTable(text) VALUES (' What's the matter?') /SQLStatement with SQLStatement INSERT INTO MyTable(text) VALUES ('\ What''s the matter\?') /SQLStatement You probably don't really want to do this ... the database should hold the proper value of the text, not a value modified for display (or whatever). I'd like to take the contents of the first SQLStatement and pipe it into an XSP page (while preserving whitespace) but can't figure out how to do that. Is this the right approach, or is there another way? Not sure what you're trying to achieve here. Why do you need the \ escaping? Andrew. -- Andrew SavoryEmail: [EMAIL PROTECTED] Managing Director Tel: +44 (0)870 741 6658 Luminas Internet Applications Fax: +44 (0)700 598 1135 This is not an official statement or order.Web:www.luminas.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String replacement in Cocoon
I really do need to do this, as I'm generating insert statements for the database. My information comes in the form of XML documents which I'm partially pulling apart to enter in the database. Unfortunately, I can't just take the information between the tags and generate an insert statement, because the characters '? have special meaning and have to be escaped. I-Lin Kuo, Ann Arbor, MI Original Message Follows From: Andrew Savory [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: String replacement in Cocoon Date: Sun, 23 Feb 2003 16:33:02 + (GMT) Hi, On Sun, 23 Feb 2003, I-Lin Kuo wrote: I'm trying to replace something like SQLStatement INSERT INTO MyTable(text) VALUES (' What's the matter?') /SQLStatement with SQLStatement INSERT INTO MyTable(text) VALUES ('\ What''s the matter\?') /SQLStatement You probably don't really want to do this ... the database should hold the proper value of the text, not a value modified for display (or whatever). I'd like to take the contents of the first SQLStatement and pipe it into an XSP page (while preserving whitespace) but can't figure out how to do that. Is this the right approach, or is there another way? Not sure what you're trying to achieve here. Why do you need the \ escaping? Andrew. _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String replacement in Cocoon
On Sun, 23 Feb 2003, I-Lin Kuo wrote: I really do need to do this, as I'm generating insert statements for the database. My information comes in the form of XML documents which I'm partially pulling apart to enter in the database. Unfortunately, I can't just take the information between the tags and generate an insert statement, because the characters '? have special meaning and have to be escaped. Ah, I see. If you're using XSP and assigning the strings to variables, the escaping is taken care of automatically for you: xsp:logic String text = xsp-request:get-parameter name=text default=/; /xsp:logic esql:connection esql:poolfoo/esql:pool esql:execute-query esql:queryINSERT INTO MyTable(Text) VALUES (esql:parameterxsp:exprtext/xsp:expr/esql:parameter)/esql:query /esql:execute-query /esql:connection See http://xml.apache.org/cocoon/userdocs/xsp/esql.html for information on Prepared Statements. Hope that helps, Andrew. -- Andrew SavoryEmail: [EMAIL PROTECTED] Managing Director Tel: +44 (0)870 741 6658 Luminas Internet Applications Fax: +44 (0)700 598 1135 This is not an official statement or order.Web:www.luminas.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]