You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Pier Fumagalli <pi...@betaversion.org> on 2003/03/13 15:14:04 UTC

Re: cvs commit: cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

"Carsten Ziegeler" <cz...@s-und-n.de> wrote:

>> Was there a special reason you did this?
>
> Yes, another bug (I don't remember the number know). The query string
> can contain whitespaces that have to be filtered out, like cariage
> returns etc. Ok, thinking of this, it's not that easy.

Hmmm... If you need it, somewhere I have a "collapseWhitespace"
implementation that we use... It's equivalent to trim plus replaces n
occurrences of Char.isWhitespace(x) with a single space char...

Where is the deleteWhitespace() method? I don't see it anywhere in the
JavaDocs...

    Pier


Re: cvscommit:cocoon-2.0/src/java/org/apache/cocoon/transformationSQLTransforme r.java

Posted by Pier Fumagalli <pi...@betaversion.org>.
"Carsten Ziegeler" <cz...@s-und-n.de> wrote:

> Pier Fumagalli wrote:
>>> Luca just suggested to simply use a
>>> String query = StringUtils.replace(sb.toString(), "\r", " ", -1);
>>> 
>>> which could solve the problems as well.
>> 
>> Shouldn't it raise the same problem of when stuff is in "" strings???
>> 
> Yes, it should, but I assume that \r is never alone; it always comes
> with a \n and therefore only removing \r should be ok, I guess.

That if you don't own a Macintosh, of course...

    Pier (who owns a Macintosh)


RE: cvscommit:cocoon-2.0/src/java/org/apache/cocoon/transformationSQLTransformer.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Pier Fumagalli wrote:
> > Luca just suggested to simply use a
> > String query = StringUtils.replace(sb.toString(), "\r", " ", -1);
> > 
> > which could solve the problems as well.
> 
> Shouldn't it raise the same problem of when stuff is in "" strings???
> 
Yes, it should, but I assume that \r is never alone; it always comes
with a \n and therefore only removing \r should be ok, I guess.

Carsten


Re: cvs commit:cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

Posted by Pier Fumagalli <pi...@betaversion.org>.
"Carsten Ziegeler" <cz...@s-und-n.de> wrote:

> 
> 
>>> Hmmm... If you need it, somewhere I have a "collapseWhitespace"
>>> implementation that we use... It's equivalent to trim plus replaces n
>>> occurrences of Char.isWhitespace(x) with a single space char...
>>> 
>> Great! I guess that's exactly what we need.
>> Ehm, just one thought: Is it ok to collapse all whitespaces of the
>> sql query? Or should we only collapse whitespaces outside of " or ',
>> so for example a statement like   text = "ggg  hhh  yyy", should
>> not be collapsed to text = "ggg hhh yyy". This is really more
>> complicated than it should.

Nope, I don't escape quotes! :-)

> Luca just suggested to simply use a
> String query = StringUtils.replace(sb.toString(), "\r", " ", -1);
> 
> which could solve the problems as well.

Shouldn't it raise the same problem of when stuff is in "" strings???

    Pier


Re: cvs commit:cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, March 13, 2003, at 02:27 PM, Carsten Ziegeler wrote:

> Just another addition, I just committed the change Luca proposed.
> It works for him, so perhaps you can try as well.
>

Our patches crossed ;)

I was going to put a .trim() on ....

Your new patch, compiled, tested but does not work.

I will commit with:

String query = StringUtils.replace(sb.toString().trim(), "\r", " ", -1);

Which does work OMM.

Thanks for your help.

regards Jeremy


RE: cvs commit:cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Just another addition, I just committed the change Luca proposed.
It works for him, so perhaps you can try as well.

Thanks
Carsten

> -----Original Message-----
> From: Carsten Ziegeler [mailto:cziegeler@s-und-n.de]
> Sent: Thursday, March 13, 2003 3:19 PM
> To: cocoon-dev@xml.apache.org
> Subject: RE: cvs
> commit:cocoon-2.0/src/java/org/apache/cocoon/transformation
> SQLTransformer.java
> 
> 
> 
> 
> > > Hmmm... If you need it, somewhere I have a "collapseWhitespace"
> > > implementation that we use... It's equivalent to trim plus replaces n
> > > occurrences of Char.isWhitespace(x) with a single space char...
> > > 
> > Great! I guess that's exactly what we need.
> > Ehm, just one thought: Is it ok to collapse all whitespaces of the
> > sql query? Or should we only collapse whitespaces outside of " or ',
> > so for example a statement like   text = "ggg  hhh  yyy", should
> > not be collapsed to text = "ggg hhh yyy". This is really more
> > complicated than it should.
> > 
> Luca just suggested to simply use a 
> String query = StringUtils.replace(sb.toString(), "\r", " ", -1);
> 
> which could solve the problems as well.
> 
> Hmm
> Carsten
> 
> 

Re: cvs commit:cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, March 13, 2003, at 02:18 PM, Carsten Ziegeler wrote:

>
>
>>> Hmmm... If you need it, somewhere I have a "collapseWhitespace"
>>> implementation that we use... It's equivalent to trim plus replaces n
>>> occurrences of Char.isWhitespace(x) with a single space char...
>>>
>> Great! I guess that's exactly what we need.
>> Ehm, just one thought: Is it ok to collapse all whitespaces of the
>> sql query? Or should we only collapse whitespaces outside of " or ',
>> so for example a statement like   text = "ggg  hhh  yyy", should
>> not be collapsed to text = "ggg hhh yyy". This is really more
>> complicated than it should.

is there not some kind of 'normalise string' method, or am I getting 
confused with XSLT ? ;)

>>
> Luca just suggested to simply use a
> String query = StringUtils.replace(sb.toString(), "\r", " ", -1);

So I will try :

- String query = StringUtils.deleteWhitespace(sb.toString());

+ String query = StringUtils.replace(sb.toString(), "\r", " ", 
-1).trim();


and commit if it works.

Incidentally, '\r' in my Queries never caused me a problem with MySQL.

Thanks for your help.

regards Jeremy


RE: cvs commit:cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.

> > Hmmm... If you need it, somewhere I have a "collapseWhitespace"
> > implementation that we use... It's equivalent to trim plus replaces n
> > occurrences of Char.isWhitespace(x) with a single space char...
> > 
> Great! I guess that's exactly what we need.
> Ehm, just one thought: Is it ok to collapse all whitespaces of the
> sql query? Or should we only collapse whitespaces outside of " or ',
> so for example a statement like   text = "ggg  hhh  yyy", should
> not be collapsed to text = "ggg hhh yyy". This is really more
> complicated than it should.
> 
Luca just suggested to simply use a 
String query = StringUtils.replace(sb.toString(), "\r", " ", -1);

which could solve the problems as well.

Hmm
Carsten



RE: cvs commit:cocoon-2.0/src/java/org/apache/cocoon/transformation SQLTransformer.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Pier Fumagalli wrote
> 
> "Carsten Ziegeler" <cz...@s-und-n.de> wrote:
> 
> >> Was there a special reason you did this?
> >
> > Yes, another bug (I don't remember the number know). The query string
> > can contain whitespaces that have to be filtered out, like cariage
> > returns etc. Ok, thinking of this, it's not that easy.
> 
> Hmmm... If you need it, somewhere I have a "collapseWhitespace"
> implementation that we use... It's equivalent to trim plus replaces n
> occurrences of Char.isWhitespace(x) with a single space char...
> 
Great! I guess that's exactly what we need.
Ehm, just one thought: Is it ok to collapse all whitespaces of the
sql query? Or should we only collapse whitespaces outside of " or ',
so for example a statement like   text = "ggg  hhh  yyy", should
not be collapsed to text = "ggg hhh yyy". This is really more
complicated than it should.


> Where is the deleteWhitespace() method? I don't see it anywhere in the
> JavaDocs...
It's from the commons-lang subproject.

Carsten