cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject [BLOCKER] SQLTransformer bug 1594 - cause found
Date Wed, 02 Nov 2005 18:11:29 GMT
Hi All

I have been hunting for the cause of this blocker:

Whereby whitespace gets swallowed up in front of SQLTransformer  
substitution tags.

The cause is in the o.a.c.transformation.helpers.TextRecorder class,  
line: 45

      * @return Recorded text so far, trimmed.
     public String getText() {
         return this.buffer.toString().trim();

When this happens in the case of the SQLTransformer, the trailing  
space in the recorded text is a required part of the SQL statement  
being generated.

i.e. (from the bug report)

> The following code will fail:
> <sql:query>
>   SELECT id, name, description from department
>   LIMIT <substitute-value sql:name="start"/>,<substitute-value  
> sql:name="count"/>
> </sql:query>
> After the values are substituted, the output is:
>   SELECT id, name, description from department
>   LIMITn,m
> ... instead of
>   SELECT id, name, description from department
>   LIMIT n,m

When this is run, with the debugger turned on, you get this message :

DEBUG (2005-11-02) 17:43.17:351 [sitemap.transformer.sql.query] (/ 
bug) PoolThread-4/SQLTransformer.Query: Adding query part "SELECT id,  
name, description from department LIMIT"
^ missing space

I can see two solutions to this bug :

1. remove the .trim() from the TextRecorder.getText() method, but I  
do not know if something else relies on this.

2. Treat SQLTransformer.startSubstituteValueElement (and probably  
startAncestorValueElement as well) as a special case, and always add  
a space to the preceding text.


regards Jeremy

View raw message