Added detach() method to strip off a root parent element, fixed bug in namespace...
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractXMLObject.h
index dee54be..3f2e801 100644 (file)
@@ -48,6 +48,8 @@ namespace xmltooling {
             XMLString::release(&m_schemaLocation);\r
         }\r
 \r
+        void detach();\r
+\r
         const QName& getElementQName() const {\r
             return m_elementQname;\r
         }\r
@@ -57,9 +59,11 @@ namespace xmltooling {
         }\r
     \r
         void addNamespace(const Namespace& ns) const {\r
-            if (ns.alwaysDeclare() || m_namespaces.find(ns)==m_namespaces.end()) {\r
+            std::set<Namespace>::iterator i = m_namespaces.find(ns);\r
+            if (i == m_namespaces.end())\r
                 m_namespaces.insert(ns);\r
-            }\r
+            else if (ns.alwaysDeclare())\r
+                i->setAlwaysDeclare(true);\r
         }\r
     \r
         void removeNamespace(const Namespace& ns) {\r