classpathx-xml
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug report (Re: [Classpathx-xml] Merging GNU JAXP into kaffe)


From: Ito Kazumitsu
Subject: Re: Bug report (Re: [Classpathx-xml] Merging GNU JAXP into kaffe)
Date: Fri, 6 Dec 2002 20:17:53 +0900
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (Unebigory ōmae) APEL/10.3 Emacs/20.7 (i386-*-windows98.2222) MULE/4.1 (AOI) Meadow/1.14 (AWSAKA:62)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]