Handle IDness during (un)marshalling, move more work to base class.
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractAttributeExtensibleXMLObject.cpp
index 7b7fd32..3ebf6c5 100644 (file)
@@ -76,3 +76,26 @@ void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedNa
         } \r
     }\r
 }\r
+\r
+void AbstractAttributeExtensibleXMLObject::unmarshallExtensionAttribute(const DOMAttr* attribute)\r
+{\r
+    QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix());\r
+    bool ID = isRegisteredIDAttribute(q); \r
+    setAttribute(q,attribute->getNodeValue(),ID);\r
+    if (ID) {\r
+        attribute->getOwnerElement()->setIdAttributeNode(attribute);\r
+    }\r
+}\r
+\r
+void AbstractAttributeExtensibleXMLObject::marshallExtensionAttributes(DOMElement* domElement) const\r
+{\r
+    for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {\r
+        DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());\r
+        if (i->first.hasPrefix())\r
+            attr->setPrefix(i->first.getPrefix());\r
+        attr->setNodeValue(i->second);\r
+        domElement->setAttributeNode(attr);\r
+        if (m_idAttribute==i)\r
+            domElement->setIdAttributeNode(attr);\r
+    }\r
+}\r