/* * Runs the test case. */ void runTest() { Document doc; NodeList acronymList; Node testNode; NamedNodeMap attributes; Attr titleAttr; String value; Text textNode; Node retval; Node lastChild; doc = (Document) baseT::load("hc_staff", true); titleAttr = doc.createAttribute(SA::construct_from_utf8("title")); textNode = doc.createTextNode(SA::construct_from_utf8("Yesterday")); retval = titleAttr.appendChild(textNode); value = titleAttr.getValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); value = titleAttr.getNodeValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); value = retval.getNodeValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); lastChild = titleAttr.getLastChild(); value = lastChild.getNodeValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); }
/* * Runs the test case. */ void runTest() { Document doc; NodeList acronymList; Node testNode; NamedNodeMap attributes; Attr titleAttr; String value; Node textNode; Node retval; Node lastChild; Document otherDoc; doc = (Document) baseT::load("hc_staff", true); otherDoc = (Document) baseT::load("hc_staff", true); acronymList = doc.getElementsByTagName(SA::construct_from_utf8("acronym")); testNode = acronymList.item(3); attributes = testNode.getAttributes(); titleAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title")); textNode = otherDoc.createTextNode(SA::construct_from_utf8("terday")); { boolean success = false; try { retval = titleAttr.appendChild(textNode); } catch (const DOMException& ex) { success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR); } assertTrue(success); } }
Node* Attr::cloneNodeExport(Document* ownerDocument, bool deep) const { Attr* pNewAttr = new Attr; pNewAttr->m_ownerDocument = ownerDocument; pNewAttr->m_nodeName = m_nodeName; pNewAttr->m_prefix = m_prefix; pNewAttr->m_localName = m_localName; pNewAttr->m_namespaceURI = m_namespaceURI; // TODO: specified // Clone children (regardless of deep since we're an attribute (?)) for (unsigned int i = 0; i < m_childNodes->m_items.GetSize(); i++) { Node* node = m_childNodes->m_items[i]->cloneNodeExport(ownerDocument, true); pNewAttr->appendChild(node); } return pNewAttr; }