\r
void AbstractXMLObjectMarshaller::marshallInto(XMLObject& xmlObject, DOMElement* targetElement) const\r
{\r
- targetElement->setPrefix(xmlObject.getElementQName().getPrefix());\r
+ if (xmlObject.getElementQName().hasPrefix())\r
+ targetElement->setPrefix(xmlObject.getElementQName().getPrefix());\r
marshallElementType(xmlObject, targetElement);\r
marshallNamespaces(xmlObject, targetElement);\r
marshallAttributes(xmlObject, targetElement);\r
\r
const XMLCh* lookupNamespaceURI(const DOMNode* n, const XMLCh* prefix) const {\r
// Return NULL if no declaration in effect. The empty string signifies the null namespace.\r
- if (!n || n->getNodeType()!=DOMNode::ELEMENT_NODE)\r
+ if (!n || n->getNodeType()!=DOMNode::ELEMENT_NODE) {\r
+ // At the root, the default namespace is set to the null namespace.\r
+ if (!prefix || !*prefix)\r
+ return &chNull;\r
return NULL; // we're done\r
+ }\r
DOMNamedNodeMap* attributes = static_cast<const DOMElement*>(n)->getAttributes();\r
if (!attributes)\r
return lookupNamespaceURI(n->getParentNode(),prefix); // defer to parent\r
if (!XMLString::equals(attribute->getNamespaceURI(),XMLConstants::XMLNS_NS))\r
continue; // not a namespace declaration\r
// Local name should be the prefix and the value would be the URI, except for the default namespace.\r
- if (!prefix && XMLString::equals(attribute->getLocalName(),XMLConstants::XMLNS_PREFIX))\r
+ if ((!prefix || !*prefix) && XMLString::equals(attribute->getLocalName(),XMLConstants::XMLNS_PREFIX))\r
return attribute->getNodeValue();\r
else if (XMLString::equals(prefix,attribute->getLocalName()))\r
return attribute->getNodeValue();\r