-
Bug
-
Resolution: Fixed
-
P3
-
6
-
1.4
-
generic
-
windows_xp
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2153397 | 7 | Joe Wang | P3 | Closed | Fixed | b14 |
JDK-2149407 | 6u4 | Joe Wang | P3 | Resolved | Fixed | b01 |
The problem can be reproducible using the jdk 6.
According to the spec for org.w3c.dom.Node.setPrefix(String prefix):
"
void setPrefix(String prefix)
throws DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the specified prefix is malformed per the Namespaces in XML specification, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from " http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" [XML Namespaces] .
"
In the following code example, it calls Node.setPrefix(String) on an read-only Entity node. The test expects the method to throw DOMException.NO_MODIFICATION_ALLOWED_ERR
but on jdk 6, it throws DOMException.NAMESPACE_ERR instead.
See the code example below:
=============================================================
import org.xml.sax.InputSource;
import java.io.StringReader;
public class MyDomTest2 {
public static void main(String[] args) {
String data =
"<?xml version=\"1.0\" ?>"
+ "<!DOCTYPE test:root ["
+ "<!ELEMENT test:root ANY>"
+ "<!ENTITY ent \"foo\">"
+ "<!ATTLIST test:root test:a CDATA #FIXED \"qqq\">"
+ "]>"
+ "<test:root xmlns:test=\"http://xxxx.xx/\">"
+ "</test:root>";
Document document = null;
try {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
document = docBuilder.parse(new InputSource(new StringReader(data)));
} catch (ParserConfigurationException e) {
System.out.println(e.toString());
} catch (IOException e) {
System.out.println(e.toString());
} catch (SAXException e) {
System.out.println(e.toString());
}
Entity anEntity = (Entity)document.getDoctype().getEntities().item(0);
try {
anEntity.setPrefix("test1");
System.out.println("Should throw DOMException.");
} catch(DOMException e) {
if (e.code == DOMException.NO_MODIFICATION_ALLOWED_ERR) {
System.out.println("OK");
} else {
System.out.println("should throw DOMException.NO_MODIFICATION_ALLOWED_ERR (7). The error returned is " + e.code );
}
}
}
}
------------------------------------------------------------
According to the spec for org.w3c.dom.Node.setPrefix(String prefix):
"
void setPrefix(String prefix)
throws DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the specified prefix is malformed per the Namespaces in XML specification, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from " http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" [XML Namespaces] .
"
In the following code example, it calls Node.setPrefix(String) on an read-only Entity node. The test expects the method to throw DOMException.NO_MODIFICATION_ALLOWED_ERR
but on jdk 6, it throws DOMException.NAMESPACE_ERR instead.
See the code example below:
=============================================================
import org.xml.sax.InputSource;
import java.io.StringReader;
public class MyDomTest2 {
public static void main(String[] args) {
String data =
"<?xml version=\"1.0\" ?>"
+ "<!DOCTYPE test:root ["
+ "<!ELEMENT test:root ANY>"
+ "<!ENTITY ent \"foo\">"
+ "<!ATTLIST test:root test:a CDATA #FIXED \"qqq\">"
+ "]>"
+ "<test:root xmlns:test=\"http://xxxx.xx/\">"
+ "</test:root>";
Document document = null;
try {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
document = docBuilder.parse(new InputSource(new StringReader(data)));
} catch (ParserConfigurationException e) {
System.out.println(e.toString());
} catch (IOException e) {
System.out.println(e.toString());
} catch (SAXException e) {
System.out.println(e.toString());
}
Entity anEntity = (Entity)document.getDoctype().getEntities().item(0);
try {
anEntity.setPrefix("test1");
System.out.println("Should throw DOMException.");
} catch(DOMException e) {
if (e.code == DOMException.NO_MODIFICATION_ALLOWED_ERR) {
System.out.println("OK");
} else {
System.out.println("should throw DOMException.NO_MODIFICATION_ALLOWED_ERR (7). The error returned is " + e.code );
}
}
}
}
------------------------------------------------------------
- backported by
-
JDK-2149407 org.w3c.dom.Node.setPrefix(String prefix) throws incorrect DOMException
-
- Resolved
-
-
JDK-2153397 org.w3c.dom.Node.setPrefix(String prefix) throws incorrect DOMException
-
- Closed
-