Re: Bug report (Re: Merging GNU JAXP into kaffe)
Ito Kazumitsu <[email protected]>
| Newsgroups | gmane.comp.java.classpath.extensions.xml |
|---|---|
| Message-ID | <[email protected]> |
I made a simpler test program and tried it in various cases.
Java VM SAXParserFactory System Property Result
(*1) (*2)
------- ---------------- --------------- ------
JDK 1.4 JAXPFactory JAXPFactory NG
JAXPFactory unset OK
SAXParserFactory JAXPFactory NG
SAXParserFactory unset OK <-- pure JDK 1.4 JAXP
kaffe JAXPFactory JAXPFactory NG
JAXPFactory unset NG
SAXParserFactory JAXPFactory NG
SAXParserFactory unset NG
(*1)
JAXPFactory:
SAXParserFactory factory = gnu.xml.aelfred2.JAXPFactory.newInstance();
SAXParserFactory:
SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance();
(*2)
JAXPFactory:
-Djavax.xml.parsers.SAXParserFactory=gnu.xml.aelfred2.JAXPFactory
Here is the test program.
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import gnu.xml.aelfred2.JAXPFactory;
public class TestSAX2 {
private static String result;
public static void main(String[] args) throws Exception {
SAXParserFactory factory = (args[0].equals("G") ?
JAXPFactory.newInstance() : 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());
result = "OK";
xr.parse("file:attribute.xsl");
System.err.println(result);
}
private static class MyHandler extends DefaultHandler {
public void startElement(
String nsURI,
String localName,
String qName,
Attributes atts
) {
for (int a=0; a<atts.getLength(); a++) {
if (atts.getLocalName(a).equals("")) result = "NG";
}
}
}
}
When run with JDK 1.4:
bash$ CLASSPATH=. java -Djavax.xml.parsers.SAXParserFactory=gnu.xml.aelfred2.JAXPFactory TestSAX2 "G"
NG
bash$ CLASSPATH=. java TestSAX2 "G"
OK
bash$ CLASSPATH=. java -Djavax.xml.parsers.SAXParserFactory=gnu.xml.aelfred2.JAXPFactory TestSAX2 "J"
NG
bash$ CLASSPATH=. java TestSAX2 "J"
OK