X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=xmltooling%2FAbstractXMLObject.cpp;h=9944a96e5558e89b63fdd1ba6db5e081f78b041e;hb=ce200eaef5c771e132b64437d78540bfd4683572;hp=58efedaf04fd262e73ed74da83e779caf86af1a7;hpb=c27736816c230e8ee45349e8834fd8a7bd7b071c;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/AbstractXMLObject.cpp b/xmltooling/AbstractXMLObject.cpp index 58efeda..9944a96 100644 --- a/xmltooling/AbstractXMLObject.cpp +++ b/xmltooling/AbstractXMLObject.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2001-2009 Internet2 +* Copyright 2001-2010 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,8 @@ AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, addNamespace(Namespace(nsURI, prefix)); if (schemaType) { m_typeQname = new QName(*schemaType); - addNamespace(Namespace(m_typeQname->getNamespaceURI(), m_typeQname->getPrefix())); + // Attach a non-visibly used namespace. + addNamespace(Namespace(m_typeQname->getNamespaceURI(), m_typeQname->getPrefix(), false, false)); } } @@ -133,8 +134,12 @@ void AbstractXMLObject::addNamespace(const Namespace& ns) const std::set::iterator i = m_namespaces.find(ns); if (i == m_namespaces.end()) m_namespaces.insert(ns); - else if (ns.alwaysDeclare()) - const_cast(*i).setAlwaysDeclare(true); + else { + if (ns.alwaysDeclare()) + const_cast(*i).setAlwaysDeclare(true); + if (ns.visiblyUsed()) + const_cast(*i).setVisiblyUsed(true); + } } void AbstractXMLObject::removeNamespace(const Namespace& ns) @@ -196,8 +201,8 @@ QName* AbstractXMLObject::prepareForAssignment(QName* oldValue, const QName* new if (!oldValue) { if (newValue) { releaseThisandParentDOM(); - Namespace newNamespace(newValue->getNamespaceURI(), newValue->getPrefix()); - addNamespace(newNamespace); + // Attach a non-visibly used namespace. + addNamespace(Namespace(newValue->getNamespaceURI(), newValue->getPrefix(), false, false)); return new QName(*newValue); } return NULL; @@ -206,8 +211,8 @@ QName* AbstractXMLObject::prepareForAssignment(QName* oldValue, const QName* new delete oldValue; releaseThisandParentDOM(); if (newValue) { - Namespace newNamespace(newValue->getNamespaceURI(), newValue->getPrefix()); - addNamespace(newNamespace); + // Attach a non-visibly used namespace. + addNamespace(Namespace(newValue->getNamespaceURI(), newValue->getPrefix(), false, false)); return new QName(*newValue); } return NULL;