- From: Curt Arnold <curta@houston.rr.com>
- Date: Wed, 12 Dec 2001 12:10:39 -0500 (EST)
- To: "XML technologies in the Java Platform" <XML-INTEREST@JAVA.SUN.COM>
- Cc: <www-dom-ts@w3.org>
Xerces-Oracle DOM incompatibilityI believe this is a non-conformance with
the spec and that using createElementNS("","tagname") to create an
unqualified element is outside of the behavior specifically mentioned in the
DOM spec which only mentions null.
The W3C and NIST have a project (http://www.w3.org/DOM/Test) to create test
suites for the various DOM related specifications. The current draft test
suite does support Oracle's parsers, but we haven't worked up a summary of
the issues with the test suite. The behavior you describe should result in
a failure of test level2/core/createElementNS02
As for a workaround, I would try the standard behavior first and only if
that fails to fall back to using "". Maybe something like (embedded in a
utility function):
static String nullNamespaceURI = null;
....
Element element;
try
{
element = doc.createElementNS(nullNamespaceURI,"root");
}
catch(NullPointerException)
{
nullNamespaceURI = "";
element = doc.createElementNS(nullNamespaceURI,"root");
}
----- Original Message -----
From: Peter Coppens
To: XML-INTEREST@JAVA.SUN.COM
Sent: Wednesday, December 12, 2001 8:52 AM
Subject: Xerces-Oracle DOM incompatibility
The following application reproduces a problem we are currently struggling
with.
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.*;
public class tdom
{
static void main ( String argv[] )
{
try
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
// Document builder factory properties
dbf.setNamespaceAware ( true );
dbf.setValidating ( false );
// Create document builder
DocumentBuilder db = dbf.newDocumentBuilder ();
// Create document
Document doc = db.newDocument ();
// Add node
Element element = doc.createElementNS ( null, "root" );
}
catch ( Exception e)
{
e.printStackTrace ();
}
}
}
When running this with either the Crimson or Xerces parser it works just
fine. But when running it with the Oracle parser (tried latest version ,
being 9.0.2.0.0C (Beta) ) it gives a NPE, on the following
Element element = doc.createElementNS ( null, "root" );
I posted the question in the Oracle OTN XML related forum
(http://www.oracle.com/forums/message.jsp?id=417988-you need a otn login),
where I was first given the impression this was recognized as a problem in
the Oracle DOM implementation (a bug was filed). A few months later the
release
info for 9.0.2.0.0C (Beta) listed the bug as being closed, but after
retrying,
the problem persists.
I tried to get more information from the Oracle forum but
until now nobody has reacted.
So I guess my question is whether the program above is correct, or whether
I should update the application to use an empty string iso null when
creating elements and no namespace information is available (the w3c spec
does seem to indicate null should be accepted).
Thanks,
Peter
Received on Monday, 17 December 2001 16:41:57 UTC