You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by I-Lin Kuo <ik...@hotmail.com> on 2003/02/23 15:57:26 UTC

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: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: String replacement in Cocoon

Posted by Andrew Savory <an...@luminas.co.uk>.
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 Savory                                Email: andrew@luminas.co.uk
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: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org