cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@sundn.de>
Subject C2: Problems with SQLTransformer and Xerces solved
Date Fri, 04 Aug 2000 12:39:30 GMT
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...

Mime
View raw message