ElementImpl extends NodeImpl implements Element { public org.w3c.dom.Element asXmlNode(Document document) { return asXmlNode(document, null, null); } protected  ElementImpl(String namespaceUri, String prefix, String name); protected  ElementImpl(String namespaceUri, String name,
			org.w3c.dom.Element xmlElement); String getNamespaceUri(); String getPrefix(); String getName(); Map<String, String> getNamespacePrefixMapping(); void setNamespacePrefixMapping(Map<String, String> namespace2Prefix); Collection<? extends Attribute> getAttributes(); abstract List<? extends Node> getChildren(); org.w3c.dom.Element asXmlNode(Document document); Object clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testAsXmlNodeOverrideParentElementPrefix() { ConcreteElementImpl elem = new ConcreteElementImpl("ns1", "pre", "name"); ConcreteElementImpl child = new ConcreteElementImpl("ns2", "pre", "name"); elem.addChild(child); org.w3c.dom.Element xmlElem = elem.asXmlNode(Utils.createDocument()); org.w3c.dom.Element xmlChild = (org.w3c.dom.Element) xmlElem .getChildNodes().item(0); assertEquals("ns1", xmlElem.getAttributeNS(XMLNS_NAMESPACE, "pre")); assertEquals("ns2", xmlChild.getAttributeNS(XMLNS_NAMESPACE, "pre")); }
@Test public void textAsXmlNodeNonEmptyText() { ConcreteElementImpl elem = new ConcreteElementImpl("ns", "pre", "name"); elem.addChild(new TextImpl("abc")); org.w3c.dom.Element xmlElem = elem.asXmlNode(Utils.createDocument()); org.w3c.dom.Text text = (org.w3c.dom.Text) xmlElem.getChildNodes() .item(0); assertEquals("abc", text.getTextContent()); }
@Test public void textAsXmlNodeEmptyText() { ConcreteElementImpl elem = new ConcreteElementImpl("ns", "pre", "name"); elem.addChild(new TextImpl("")); org.w3c.dom.Element xmlElem = elem.asXmlNode(Utils.createDocument()); assertEquals(new Integer(0), new Integer(xmlElem.getChildNodes() .getLength())); }