You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by David Kavanagh <da...@dotech.com> on 2003/05/03 19:04:29 UTC

SQL transformer character escaping

I hate to bug... I could generate a patch for this issue, but I'd like 
to know from other people if they see this as an issue. If not, how do 
you work around it. (BTW, now, I've looked at the code and know where to 
do the character substitution).
.
.
I'm using the SQLTransformer to grab data from a database (no surprise 
there). The data contains the "&" character. It seems like that isn't 
being escaped in the XML being generated. When I've written 
transformers, I make sure the XML generated escapes characters like <, 
 >, &, etc.
Is there some feature in the SQLTransformer that I need to enable to 
make this happen? I think it just calls sendTextEvent() on the 
AbstractSQLTransformer. Haven't looked at that code yet.

David



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: SQL transformer character escaping

Posted by Bruno Dumon <br...@outerthought.org>.
On Sun, 2003-05-04 at 16:30, David Kavanagh wrote:
> What I have run into is that in passing the un-escaped data through
> the TraxTransformer, I get different results. IN fact I get quite
> unexpected results because the data containing the un-escaped '&'
> seems to stop processing on that part of the XML tree.

Very strange. If you could post a reproduceable (minimal) sample (i.e. a
sitemap snippet, a query document, an XSL, and some sql to create a test
table), then we could help you further (unless someone else has other
ideas...).

>  Escaping in the SQLTransformer is the only way I've found to fix the
> problem.
> I've been on the XML-INTEREST list and JDOM list for a while and
> eharacter escaping has been a topic of discussion on each list. XML is
> not well-formed if you see something like this
> 
> <tag>some data & some more data</tag> 
> 
> That just isn't well-formed XML It should read
> 
> <tag>some data &amp; some more data</tag>
> 
> That is why you have the pre-defined enties like &amp; &lt; &gt;
> &quot; &apos;
> 
> It seems to me that at any point in the pipeline, the XML should be
> well-formed.

Yes, but Cocoon's pipeline is a SAX pipeline, not an XML pipeline.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: SQL transformer character escaping

Posted by David Kavanagh <da...@dotech.com>.
What I have run into is that in passing the un-escaped data through the 
TraxTransformer, I get different results. IN fact I get quite unexpected 
results because the data containing the un-escaped '&' seems to stop 
processing on that part of the XML tree. Escaping in the SQLTransformer 
is the only way I've found to fix the problem.
I've been on the XML-INTEREST list and JDOM list for a while and 
eharacter escaping has been a topic of discussion on each list. XML is 
not well-formed if you see something like this

<tag>some data & some more data</tag>

That just isn't well-formed XML It should read

<tag>some data &amp; some more data</tag>

That is why you have the pre-defined enties like &amp; &lt; &gt; &quot; 
&apos;

It seems to me that at any point in the pipeline, the XML should be 
well-formed.

David

Bruno Dumon wrote:

>On Sat, 2003-05-03 at 19:04, David Kavanagh wrote:
>  
>
>>I hate to bug... I could generate a patch for this issue, but I'd like 
>>to know from other people if they see this as an issue. If not, how do 
>>you work around it. (BTW, now, I've looked at the code and know where to 
>>do the character substitution).
>>.
>>.
>>I'm using the SQLTransformer to grab data from a database (no surprise 
>>there). The data contains the "&" character. It seems like that isn't 
>>being escaped in the XML being generated. When I've written 
>>transformers, I make sure the XML generated escapes characters like <, 
>> >, &, etc.
>>    
>>
>
>Huh? Transformers should not escape those characters themselves, they
>are escaped by the serializer. All text passing in the characters()
>events over the pipeline is unescaped (or in xml speak: all entities are
>resolved).
>
>So the serializer is not escaping those characters for you?
>
>  
>


Re: SQL transformer character escaping

Posted by Bruno Dumon <br...@outerthought.org>.
On Sat, 2003-05-03 at 19:04, David Kavanagh wrote:
> I hate to bug... I could generate a patch for this issue, but I'd like 
> to know from other people if they see this as an issue. If not, how do 
> you work around it. (BTW, now, I've looked at the code and know where to 
> do the character substitution).
> .
> .
> I'm using the SQLTransformer to grab data from a database (no surprise 
> there). The data contains the "&" character. It seems like that isn't 
> being escaped in the XML being generated. When I've written 
> transformers, I make sure the XML generated escapes characters like <, 
>  >, &, etc.

Huh? Transformers should not escape those characters themselves, they
are escaped by the serializer. All text passing in the characters()
events over the pipeline is unescaped (or in xml speak: all entities are
resolved).

So the serializer is not escaping those characters for you?

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org