[kaffe] GNU JAXP Bug report: Attribute value including &
Ito Kazumitsu
ito.kazumitsu@hitachi-cable.co.jp
Mon Sep 1 01:25:03 2003
Hi,
I have found a case where an attribute value is treated
incorrectly.
If you write <a b='X&Y&Z'>, the value of attribute b
should be 'X&Y&Z', but 'X&' and 'Y&' becomes characters nodes
and only 'Z' becomes the value of b.
I am using gnu.xml.aelfred2.* included in kaffe. They are
dated as follows
-rw-rw-r-- 1 ito ito 5318 Dec 3 2002 JAXPFactory.java
-rw-rw-r-- 1 ito ito 35362 Feb 7 2003 SAXDriver.java
-rw-rw-r-- 1 ito ito 128240 Dec 3 2002 XmlParser.java
-rw-rw-r-- 1 ito ito 9792 Dec 22 2002 XmlReader.java
Here is the test case.
$ cat TestSAX2.java
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
public class TestSAX2 {
public static void main(String[] args) throws Exception {
String uri = args[0];
new TestSAX2(uri);
}
public TestSAX2(String uri) throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setFeature("http://xml.org/sax/features/namespaces", true);
factory.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
XMLReader xr = factory.newSAXParser().getXMLReader();
xr.setContentHandler(new MyHandler());
xr.parse(uri);
}
private class MyHandler extends DefaultHandler {
public void startElement(
String nsURI,
String localName,
String qName,
Attributes atts
) {
System.out.println("START ELEMENT");
System.out.println(" URI = " + nsURI);
System.out.println(" local = " + localName);
System.out.println(" qname = " + qName);
System.out.println("ATTRIBUTES");
for (int a=0; a<atts.getLength(); a++) {
System.out.println(" URI = " + atts.getURI(a));
System.out.println(" local = " + atts.getLocalName(a));
System.out.println(" qname = " + atts.getQName(a));
System.out.println(" value = " + atts.getValue(a));
}
System.out.println("END ATTRIBUTES");
}
public void endElement(
String nsURI,
String localName,
String qName
) {
System.out.println("END ELEMENT");
System.out.println(" URI = " + nsURI);
System.out.println(" local = " + localName);
System.out.println(" qname = " + qName);
}
public void characters(
char ch[],
int start,
int length
) {
System.out.println("CHARACTERS");
System.out.println(new String(ch, start, length));
System.out.println("END CHARACTERS");
}
}
}
$ cat 01.xml
<a0>
<a b='X&Y&Z'>test</a>
</a0>
$ java TestSAX2 file://$HOME/javatest/01.xml
START ELEMENT
URI =
local = a0
qname = a0
ATTRIBUTES
END ATTRIBUTES
CHARACTERS
X&
END CHARACTERS
CHARACTERS
Y&
END CHARACTERS
START ELEMENT
URI =
local = a
qname = a
ATTRIBUTES
URI =
local = b
qname = b
value = Z
END ATTRIBUTES
CHARACTERS
test
END CHARACTERS
END ELEMENT
URI =
local = a
qname = a
END ELEMENT
URI =
local = a0
qname = a0