Re: Bug report (Re: Merging GNU JAXP into kaffe)

Ito Kazumitsu <[email protected]>
Newsgroups gmane.comp.java.classpath.extensions.xml
Message-ID <[email protected]>
In message "Re: Bug report (Re: [Classpathx-xml] Merging GNU JAXP into kaffe)"
    on 02/12/06, Ito Kazumitsu <[email protected]> writes:

> > Ito, did it work for you?
> 
> No,  I got the same unexpected result.

I modified my test program so that it uses gnu.xml.aelfred2.JAXPFactory,
and run it with JDK 1.4.  Then I got a satisfactory result.

Isn't there anything around javax.xml.parsers.* ?

When run with JDK 1.4:
bash$ CLASSPATH=. java TestSAX2 file:attribute.xsl 
ELEMENT
 URI = http://www.w3.org/1999/XSL/Transform
 local = stylesheet
 qname = xsl:stylesheet
ATTRIBUTES
 URI = 
 local = version
 qname = version

When run with kaffe:
$ kaffe TestSAX2 file:attribute.xsl
ELEMENT
 URI = http://www.w3.org/1999/XSL/Transform
 local = stylesheet
 qname = xsl:stylesheet
ATTRIBUTES
 URI =
 local =
 qname = xmlns:xsl
 URI =
 local = version
 qname = version

Test program and data
bash$ cat TestSAX2.java 
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import gnu.xml.aelfred2.JAXPFactory;

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 = JAXPFactory.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("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));
        }
    }
}

}
bash$ cat attribute.xsl 
<?xml version="1.0"?>

<!DOCTYPE xsl:stylesheet>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

</xsl:stylesheet>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.