https://issues.shibboleth.net/jira/browse/CPPXT-41
authorScott Cantor <cantor.2@osu.edu>
Mon, 31 Aug 2009 19:12:27 +0000 (19:12 +0000)
committerScott Cantor <cantor.2@osu.edu>
Mon, 31 Aug 2009 19:12:27 +0000 (19:12 +0000)
xmltooling/AbstractXMLObject.cpp
xmltooling/AbstractXMLObject.h
xmltooling/io/AbstractXMLObjectMarshaller.cpp
xmltooling/io/AbstractXMLObjectUnmarshaller.cpp

index aeb0817..1a51a44 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright 2001-2007 Internet2
+*  Copyright 2001-2009 Internet2
  *
 * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,8 @@ AbstractXMLObject::~AbstractXMLObject()
     xercesc::XMLString::release(&m_noNamespaceSchemaLocation);
 }
 
-void XMLObject::setNil(const XMLCh* value) {
+void XMLObject::setNil(const XMLCh* value)
+{
     if (value) {
         switch (*value) {
             case xercesc::chLatin_t:
@@ -82,6 +83,15 @@ void XMLObject::setNil(const XMLCh* value) {
     }
 }
 
+void AbstractXMLObject::addNamespace(const Namespace& ns) const
+{
+    std::set<Namespace>::iterator i = m_namespaces.find(ns);
+    if (i == m_namespaces.end())
+        m_namespaces.insert(ns);
+    else if (ns.alwaysDeclare())
+        const_cast<Namespace&>(*i).setAlwaysDeclare(true);
+}
+
 XMLCh* AbstractXMLObject::prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue)
 {
     if (!XMLString::equals(oldValue,newValue)) {
index fc4c23b..9d6319e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright 2001-2007 Internet2
+*  Copyright 2001-2009 Internet2
  *
 * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,13 +56,7 @@ namespace xmltooling {
             return m_namespaces;
         }
 
-        void addNamespace(const Namespace& ns) const {
-            std::set<Namespace>::iterator i = m_namespaces.find(ns);
-            if (i == m_namespaces.end())
-                m_namespaces.insert(ns);
-            else if (ns.alwaysDeclare())
-                const_cast<Namespace&>(*i).setAlwaysDeclare(true);
-        }
+        void addNamespace(const Namespace& ns) const;
 
         void removeNamespace(const Namespace& ns) {
             m_namespaces.erase(ns);
index 7e2cf3c..0157327 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright 2001-2007 Internet2
+*  Copyright 2001-2009 Internet2
  * 
 * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -269,6 +269,10 @@ public:
         const XMLCh* prefix=ns.getNamespacePrefix();
         const XMLCh* uri=ns.getNamespaceURI();
         
+        // Check for xmlns:xml.
+        if (XMLString::equals(prefix, XML_PREFIX) && XMLString::equals(uri, XML_NS))
+            return;
+
         // Check to see if the prefix is already declared properly above this node.
         if (!ns.alwaysDeclare()) {
             const XMLCh* declared=lookupNamespaceURI(domElement->getParentNode(),prefix);
@@ -284,7 +288,7 @@ public:
             XMLString::catString(xmlns,colon);
             XMLString::catString(xmlns,prefix);
             domElement->setAttributeNS(XMLNS_NS, xmlns, uri);
-            XMLString::release(&xmlns);
+            delete[] xmlns;
         }
         else {
             domElement->setAttributeNS(XMLNS_NS, XMLNS_PREFIX, uri);
index 66ae055..e633b70 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright 2001-2007 Internet2
+*  Copyright 2001-2009 Internet2
  * 
 * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,13 +100,15 @@ void AbstractXMLObjectUnmarshaller::unmarshallAttributes(const DOMElement* domEl
             if (XMLString::equals(attribute->getLocalName(),XMLNS_PREFIX)) {
                 m_log.debug("found default namespace declaration, adding it to the list of namespaces on the XMLObject");
                 addNamespace(Namespace(attribute->getValue(), NULL, true));
-                continue;
+            }
+            else if (XMLString::equals(attribute->getLocalName(),XML_PREFIX) && XMLString::equals(attribute->getNodeValue(),XML_NS)) {
+                m_log.debug("found standard xml prefix declaration, ignoring as superfluous");
             }
             else {
                 m_log.debug("found namespace declaration, adding it to the list of namespaces on the XMLObject");
                 addNamespace(Namespace(attribute->getValue(), attribute->getLocalName(), true));
-                continue;
             }
+            continue;
         }
         else if (XMLString::equals(nsuri,XSI_NS)) {
             static const XMLCh type[]= UNICODE_LITERAL_4(t,y,p,e);