You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Mike Pogue <mp...@apache.org> on 2000/08/08 01:19:05 UTC

C2: Problems with SQLTransformer and Xerces solved

This was on the Cocoon board.  I don't know if anybody's seen this,
so I'm posting it here!

Mike
=====================================================================

Carsten Ziegeler wrote:
> 
> Hi,
> 
> after some experimenting with the SQLTransformer I found out the following:
> 
> The problems are not based on the Transformer itself but on Xerces. Using the following simple XML-File, Xerces generates wrong endElement()-Events:
> 
> <?xml version="1.0"?>
> 
> <html xmlns:sql="http://xml.apache.org/cocoon/SQL">
> <head>
> </head>
> <body>
> 
>         <sql:execute-query>
>                 <sql:query>
>                         select * from user
>                 </sql:query>
>         </sql:execute-query>
> </body>
> </html>
> 
> In version 1.1.2 of Xerces the SQLTransformer receives an endElement() event with
> uri="http://xml.apache.org/cocoon/SQL", name="sql:execute-query" and raw="sql:execute-query".
> So the name attribute is wrong and you get a SAXException: Raw/Local Name mismatch.
> 
> In version 1.1.3 of Xerves this bug is fixed but there is still another bug, as the SQLTransformer now receives an endElement() event with uri="http://xml.apache.org/cocoon/SQL", name="body" and raw="body".
> In this case the uri is wrong. The SQLTransformer now gets his uri and then assumes body is the value element.
> 
> The following diff of the SQLTransformer performs an additional check. If the incoming element is not one of those
> the SQLTransformer recognizes (execute-query, query, ancestor-value, value) the endElement() method passes this to super.
> 
> So the end of the endElement() method should look like this:
>         if (name.equals(MAGIC_EXECUTE_QUERY)) {
>                         endExecuteQueryElement();
>         } else if (name.equals(MAGIC_QUERY)) {
>                         endQueryElement();
>                 } else if (name.equals(MAGIC_ANCESTOR_VALUE)) {
>                         endAncestorValueElement();
>                 } else if (name.equals("value")) {  // THIS CHECK IS NEW
>                         endValueElement();
>                 } else {
>                     super.endElement(uri, name, raw); // SEND IT TO SUPER
>         }
> 
> This patch only works if you update from Xerces 1.1.2 to version 1.1.3. If you want to use Xerces 1.1.2 you have to add  the following lines at the beginning of endElement():
>        if (!uri.equals(my_uri)) {
>             super.endElement(uri,name,raw);
>             return;
>         }
>         int pos = name.indexOf(":");                 // THIS PATCH IS NEW
>         if (pos != -1) name = name.substring(pos+1);
> 
> I don't know if the Xerces bug is known to the Xerces development team as the mailinglists are currently still down. Perhaps someone in this list can give them a hint.
> 
> Regards
> Carsten Ziegeler
> 
> Open Source Group              sunShine - Lighting up e:Business
> ================================================================
> Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
> www.sundn.de                           mailto:cziegeler@sundn.de
> ================================================================
> 
> ------------------------------------------------------------------------------------------
> ...this mail was scanned for viruses by mailserver...

Re: Problems with SQLTransformer and Xerces solved

Posted by Eric Ye <er...@locus.apache.org>.
Yes, this is a bug. It will be fixed very soon.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Mike Pogue" <mp...@apache.org>
To: <xe...@xml.apache.org>
Sent: Monday, August 07, 2000 4:19 PM
Subject: C2: Problems with SQLTransformer and Xerces solved


> This was on the Cocoon board.  I don't know if anybody's seen this,
> so I'm posting it here!
>
> Mike
> =====================================================================
>
> Carsten Ziegeler wrote:
> >
> > Hi,
> >
> > after some experimenting with the SQLTransformer I found out the
following:
> >
> > The problems are not based on the Transformer itself but on Xerces.
Using the following simple XML-File, Xerces generates wrong
endElement()-Events:
> >
> > <?xml version="1.0"?>
> >
> > <html xmlns:sql="http://xml.apache.org/cocoon/SQL">
> > <head>
> > </head>
> > <body>
> >
> >         <sql:execute-query>
> >                 <sql:query>
> >                         select * from user
> >                 </sql:query>
> >         </sql:execute-query>
> > </body>
> > </html>
> >
> > In version 1.1.2 of Xerces the SQLTransformer receives an endElement()
event with
> > uri="http://xml.apache.org/cocoon/SQL", name="sql:execute-query" and
raw="sql:execute-query".
> > So the name attribute is wrong and you get a SAXException: Raw/Local
Name mismatch.
> >
> > In version 1.1.3 of Xerves this bug is fixed but there is still another
bug, as the SQLTransformer now receives an endElement() event with
uri="http://xml.apache.org/cocoon/SQL", name="body" and raw="body".
> > In this case the uri is wrong. The SQLTransformer now gets his uri and
then assumes body is the value element.
> >
> > The following diff of the SQLTransformer performs an additional check.
If the incoming element is not one of those
> > the SQLTransformer recognizes (execute-query, query, ancestor-value,
value) the endElement() method passes this to super.
> >
> > So the end of the endElement() method should look like this:
> >         if (name.equals(MAGIC_EXECUTE_QUERY)) {
> >                         endExecuteQueryElement();
> >         } else if (name.equals(MAGIC_QUERY)) {
> >                         endQueryElement();
> >                 } else if (name.equals(MAGIC_ANCESTOR_VALUE)) {
> >                         endAncestorValueElement();
> >                 } else if (name.equals("value")) {  // THIS CHECK IS NEW
> >                         endValueElement();
> >                 } else {
> >                     super.endElement(uri, name, raw); // SEND IT TO
SUPER
> >         }
> >
> > This patch only works if you update from Xerces 1.1.2 to version 1.1.3.
If you want to use Xerces 1.1.2 you have to add  the following lines at the
beginning of endElement():
> >        if (!uri.equals(my_uri)) {
> >             super.endElement(uri,name,raw);
> >             return;
> >         }
> >         int pos = name.indexOf(":");                 // THIS PATCH IS
NEW
> >         if (pos != -1) name = name.substring(pos+1);
> >
> > I don't know if the Xerces bug is known to the Xerces development team
as the mailinglists are currently still down. Perhaps someone in this list
can give them a hint.
> >
> > Regards
> > Carsten Ziegeler
> >
> > Open Source Group              sunShine - Lighting up e:Business
> > ================================================================
> > Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
> > www.sundn.de                           mailto:cziegeler@sundn.de
> > ================================================================
> >
>
> --------------------------------------------------------------------------
----------------
> > ...this mail was scanned for viruses by mailserver...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>