diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-04 18:17:27 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-04 18:17:27 +0200 |
commit | 297b4bd2c5bd5ed5e62f560a8b60c1d04903455b (patch) | |
tree | 986142747efcdd53f477da7ad0c4490ca01b4b27 | |
parent | 11912c8683d41e98eedbb3ded1b036aa92248add (diff) |
If attribute is xmlns, supply proper namespace to DOM
Xerces-C++ SAX does not provide proper namespace for the xmlns attribute
as in xmlns="foo" or xmlns="".
-rw-r--r-- | examples/cxx/tree/streaming/parser.cxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/examples/cxx/tree/streaming/parser.cxx b/examples/cxx/tree/streaming/parser.cxx index b0d9df7..f593a14 100644 --- a/examples/cxx/tree/streaming/parser.cxx +++ b/examples/cxx/tree/streaming/parser.cxx @@ -220,9 +220,17 @@ startElement (const XMLCh* const uri, for (unsigned int i (0), end (attr.getLength()); i < end; ++i) #endif { - cur_->setAttributeNS (attr.getURI (i), - attr.getQName (i), - attr.getValue (i)); + const XMLCh* qn (attr.getQName (i)); + const XMLCh* ns (attr.getURI (i)); + + // When SAX2 reports the xmlns attribute, it does not include + // the proper attribute namespace. So we have to detect and + // handle this case. + // + if (XMLString::equals (qn, XMLUni::fgXMLNSString)) + ns = XMLUni::fgXMLNSURIName; + + cur_->setAttributeNS (ns, qn, attr.getValue (i)); } depth_++; |