X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fio%2FAbstractXMLObjectMarshaller.cpp;h=d5c4ac01f5b97861a398a40254a33f24343130b7;hb=43b52c4ce0a76f57c5e3b17bfcd244ed64035f6c;hp=da5cf6525dd51a8e2509d30b4962ed03067e1679;hpb=3ac78427b7a4ce8c7492dcb5fcac52563c5760ec;p=shibboleth%2Fxmltooling.git diff --git a/xmltooling/io/AbstractXMLObjectMarshaller.cpp b/xmltooling/io/AbstractXMLObjectMarshaller.cpp index da5cf65..d5c4ac0 100644 --- a/xmltooling/io/AbstractXMLObjectMarshaller.cpp +++ b/xmltooling/io/AbstractXMLObjectMarshaller.cpp @@ -161,7 +161,8 @@ DOMElement* AbstractXMLObjectMarshaller::marshall(XMLObject* xmlObject, DOMEleme void AbstractXMLObjectMarshaller::marshallInto(XMLObject& xmlObject, DOMElement* targetElement) const { - targetElement->setPrefix(xmlObject.getElementQName().getPrefix()); + if (xmlObject.getElementQName().hasPrefix()) + targetElement->setPrefix(xmlObject.getElementQName().getPrefix()); marshallElementType(xmlObject, targetElement); marshallNamespaces(xmlObject, targetElement); marshallAttributes(xmlObject, targetElement); @@ -242,8 +243,12 @@ public: const XMLCh* lookupNamespaceURI(const DOMNode* n, const XMLCh* prefix) const { // Return NULL if no declaration in effect. The empty string signifies the null namespace. - if (!n || n->getNodeType()!=DOMNode::ELEMENT_NODE) + if (!n || n->getNodeType()!=DOMNode::ELEMENT_NODE) { + // At the root, the default namespace is set to the null namespace. + if (!prefix || !*prefix) + return &chNull; return NULL; // we're done + } DOMNamedNodeMap* attributes = static_cast(n)->getAttributes(); if (!attributes) return lookupNamespaceURI(n->getParentNode(),prefix); // defer to parent @@ -257,7 +262,7 @@ public: if (!XMLString::equals(attribute->getNamespaceURI(),XMLConstants::XMLNS_NS)) continue; // not a namespace declaration // Local name should be the prefix and the value would be the URI, except for the default namespace. - if (!prefix && XMLString::equals(attribute->getLocalName(),XMLConstants::XMLNS_PREFIX)) + if ((!prefix || !*prefix) && XMLString::equals(attribute->getLocalName(),XMLConstants::XMLNS_PREFIX)) return attribute->getNodeValue(); else if (XMLString::equals(prefix,attribute->getLocalName())) return attribute->getNodeValue();