nodesetprefix04public final class nodesetprefix04 extends org.w3c.domts.DOMTestCase The method setPrefix raises a NAMESPACE_ERR if the namespaceURI of this node is null.
Retreive the a default Attribute node which does not have a namespace prefix. Call the setPrefix
method on it. Check if a NAMESPACE_ERR is thrown. |
Constructors Summary |
---|
public nodesetprefix04(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
org.w3c.domts.DocumentBuilderSetting[] settings =
new org.w3c.domts.DocumentBuilderSetting[] {
org.w3c.domts.DocumentBuilderSetting.namespaceAware,
org.w3c.domts.DocumentBuilderSetting.validating
};
DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
setFactory(testFactory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staffNS", true);
|
Methods Summary |
---|
public java.lang.String | getTargetURI()Gets URI that identifies the test.
return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix04";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(nodesetprefix04.class, args);
| public void | runTest()Runs the test case.
Document doc;
Element element;
Attr attribute;
NodeList elementList;
String nullNS = null;
doc = (Document) load("staffNS", true);
elementList = doc.getElementsByTagName("emp:employee");
element = (Element) elementList.item(0);
assertNotNull("empEmployeeNotNull", element);
attribute = element.getAttributeNodeNS(nullNS, "defaultAttr");
{
boolean success = false;
try {
attribute.setPrefix("test");
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("nodesetprefix04", success);
}
|
|