-
Bug
-
Resolution: Fixed
-
P4
-
1.1.3, 1.4.1
-
1.2.0
-
generic
-
generic
-
Verified
Name: eaR10174 Date: 11/13/2001
The method org.w3c.dom.Node.setPrefix(String prefix) throws the DOMException with
INVALID_CHARACTER_ERR error code instead of the NAMESPACE_ERR error code in case when
the prefix is "test:" (See test.java below). The javadoc specification reads
(jdk1.4.0beta-b85):
"public void setPrefix(String prefix)
throws DOMException
...
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified prefix contains
an illegal character, per the XML 1.0 specification."
The prefix "test:" contains characters allowed by the XML 1.0 specification, but this
prefix doesn't meet the requirements of specification 'Namespaces in XML'. The
specification prohibits from having the colon in the prefix. In this case the javadoc
specification reads
"Throws:
DOMException - ...
...
NAMESPACE_ERR: Raised if the specified prefix is malformed per the Namespaces
in XML specification."
This bug is found in the builds jdk1.4.0-rc-b85, jaxp-1.1.3-b02-30_oct_2001 and
affects the new JCK1.4 tests
api/org_w3c/dom/Node/index.html#SetPrefix[SetPrefix003]
api/org_w3c/dom/Node/index.html#SetPrefix[SetPrefix009]
------------------------------------test.java-----------------------------
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
public class test {
public static void main(String argv[]) {
try {
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Node element = null;
element = document.createElementNS("http://xx.xx", "t:element");
element.setPrefix("test:");
System.out.println("DOMException not thrown");
} catch (DOMException e) {
if (e.code != DOMException.NAMESPACE_ERR) {
System.out.println("error code: " + e.code);
System.out.println("error code is not NAMESPACE_ERR");
} else {
System.out.println("OK");
}
} catch (Exception e) {
System.out.println(e);
}
}
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
% java -showversion test
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b85)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b85, mixed mode)
error code: 5
error code is not NAMESPACE_ERR
---------------------------------------------------------------------------
======================================================================
- relates to
-
JDK-4398948 Node.setPrefix() doesn't throw an exception on bad argument
- Closed