axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Ruby" <ru...@us.ibm.com>
Subject Re: cvs commit: xml-axis/java/src/org/apache/axis/utils Admin.java
Date Tue, 12 Jun 2001 12:50:31 GMT
Glen Daniels wrote:
>
>> The assumption that localName == tagName for un-namespace qualified
>> elements does not appear to hold across parser implementations.  The
>> updated code works with Crimson, Xerces 1, and Xerces 2.
>
> Interesting!  What were you getting before?

As always, suggestions for a better fix are welcome.

Below is a test program based on the latest Xerces 1 and Xerces 2 from CVS,
and Crimson from the JAXP 1.1 reference implementation.  Note that Xerces 1
and Xerces 2 are moving towards DOM level 3.  Also, note the wording in the
following description:

   http://dom4j.org/javadoc/org/w3c/dom/Node.html#getLocalName()

================================================================

// JAVA API for XML Parsing
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

// DOM
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;

// SAX
import org.xml.sax.InputSource;

// Java
import java.io.Reader;
import java.io.StringReader;

public class test {
    public static void main(String args[]) throws Exception {
        Reader reader = new StringReader("<root/>");

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        dbf.setNamespaceAware(true);
        Document doc = db.parse(new InputSource(reader));

        Element elem = doc.getDocumentElement();
        System.out.println("tag:   " + elem.getTagName());
        System.out.println("local: " + elem.getLocalName());
    }
}

================================================================

D:\tmp>SET CLASSPATH=.;C:\jdk1.3.1\lib\tools.jar;D:\jakarta\xml-xerces\java\build\xerces.jar

D:\tmp>java test
tag:   root
local: null

D:\tmp>SET CLASSPATH=.;C:\jdk1.3.1\lib\tools.jar;D:\jakarta\xml-xerces2\java\build\xerces.jar

D:\tmp>java test
tag:   root
local: null

D:\tmp>SET CLASSPATH=.;C:\jdk1.3.1\lib\tools.jar;C:\jaxp-1.1\jaxp.jar;C:\jaxp-1.1\crimson.jar

D:\tmp>java test
tag:   root
local: root

================================================================

- Sam Ruby


Mime
View raw message