X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2FAbstractAttributeExtensibleXMLObject.cpp;h=c144fa9a3e820a9e40d53450be3f2888d7b4123e;hb=81b488b2790e7bdeb2f43560b1d4a7d22c3dfdf5;hp=eae509f2b5009f77b87f2855dce4378e8081d671;hpb=bd026f07e729e66127b3efd48aee443fba815af3;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/AbstractAttributeExtensibleXMLObject.cpp b/xmltooling/AbstractAttributeExtensibleXMLObject.cpp index eae509f..c144fa9 100644 --- a/xmltooling/AbstractAttributeExtensibleXMLObject.cpp +++ b/xmltooling/AbstractAttributeExtensibleXMLObject.cpp @@ -1,17 +1,21 @@ -/* - * 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. - * You may obtain a copy of the License at +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. */ /** @@ -27,9 +31,11 @@ #include #include +#include using namespace xmltooling; using namespace std; +using xercesc::chColon; using xercesc::DOMAttr; using xercesc::DOMElement; @@ -112,7 +118,7 @@ AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject() const XMLCh* AbstractAttributeExtensibleXMLObject::getAttribute(const QName& qualifiedName) const { map::const_iterator i=m_attributeMap.find(qualifiedName); - return (i==m_attributeMap.end()) ? NULL : i->second; + return (i==m_attributeMap.end()) ? nullptr : i->second; } void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID) @@ -137,7 +143,27 @@ void AbstractAttributeExtensibleXMLObject::setAttribute(const QName& qualifiedNa m_attributeMap[qualifiedName]=XMLString::replicate(value); if (ID) m_idAttribute = m_attributeMap.find(qualifiedName); + Namespace newNamespace(qualifiedName.getNamespaceURI(), qualifiedName.getPrefix(), false, Namespace::VisiblyUsed); + addNamespace(newNamespace); + } +} + +void AttributeExtensibleXMLObject::setAttribute(const QName& qualifiedName, const QName& value) +{ + if (!value.hasLocalPart()) + return; + + if (value.hasPrefix()) { + xstring buf(value.getPrefix()); + buf = buf + chColon + value.getLocalPart(); + setAttribute(qualifiedName, buf.c_str()); } + else { + setAttribute(qualifiedName, value.getLocalPart()); + } + + Namespace newNamespace(value.getNamespaceURI(), value.getPrefix(), false, Namespace::NonVisiblyUsed); + addNamespace(newNamespace); } const map& AbstractAttributeExtensibleXMLObject::getExtensionAttributes() const @@ -146,7 +172,7 @@ const map& AbstractAttributeExtensibleXMLObject::getExtensionAttri } const XMLCh* AbstractAttributeExtensibleXMLObject::getXMLID() const { - return (m_idAttribute == m_attributeMap.end()) ? NULL : m_idAttribute->second; + return (m_idAttribute == m_attributeMap.end()) ? nullptr : m_idAttribute->second; } void AbstractAttributeExtensibleXMLObject::unmarshallExtensionAttribute(const DOMAttr* attribute)