documentimportnode20public final class documentimportnode20 extends org.w3c.domts.DOMTestCase The importNode method imports a node from another document to this document.
The returned node has no parent; (parentNode is null). The source node is not
altered or removed from the original document but a new copy of the source node
is created.
Using the method importNode with deep=true, import a entity node ent4
from this document to a new document object. The replacement text of this entity is an element
node, a cdata node and a pi. Verify if the nodes have been
imported correctly by checking the nodeNames of the imported element node, the data for the
cdata nodes and the PItarget and PIData for the pi nodes. |
Constructors Summary |
---|
public documentimportnode20(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.notExpandEntityReferences
};
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/documentimportnode20";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(documentimportnode20.class, args);
| public void | runTest()Runs the test case.
Document doc;
Document docImp;
DOMImplementation domImpl;
DocumentType docType;
DocumentType docTypeNull = null;
NamedNodeMap nodeMap;
Entity entity4;
Entity entityImp4;
Element element;
CharacterData cdata;
ProcessingInstruction pi;
NodeList childList;
NodeList elemchildList;
String ent4Name;
String ent4ImpName;
String cdataVal;
String piTargetVal;
String piDataVal;
doc = (Document) load("staffNS", true);
domImpl = doc.getImplementation();
docType = doc.getDoctype();
docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b", docTypeNull);
nodeMap = docType.getEntities();
entity4 = (Entity) nodeMap.getNamedItem("ent4");
entityImp4 = (Entity) docImp.importNode(entity4, true);
childList = entityImp4.getChildNodes();
element = (Element) childList.item(0);
elemchildList = element.getChildNodes();
cdata = (CharacterData) elemchildList.item(0);
pi = (ProcessingInstruction) childList.item(1);
ent4Name = entity4.getNodeName();
ent4ImpName = entityImp4.getNodeName();
cdataVal = cdata.getData();
piTargetVal = pi.getTarget();
piDataVal = pi.getData();
assertEquals("documentimportnode20_Ent4NodeName", ent4Name, ent4ImpName);
assertEquals("documentimportnode20_Cdata", "Element data", cdataVal);
assertEquals("documentimportnode20_PITarget", "PItarget", piTargetVal);
assertEquals("documentimportnode20_PIData", "PIdata", piDataVal);
|
|