From b25ac8848dea4df378861f518b562df38a77ed91 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Jul 2010 22:31:03 +0200 Subject: Work around Xerces-C++ SAX2 bug with xmlns attribute Xerces-C++ SAX does not provide proper namespace for the xmlns attribute as in xmlns="foo". --- libxsd/xsd/cxx/parser/xerces/elements.txx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libxsd/xsd/cxx/parser/xerces/elements.txx') diff --git a/libxsd/xsd/cxx/parser/xerces/elements.txx b/libxsd/xsd/cxx/parser/xerces/elements.txx index 2c1e2a1..40fb2e4 100644 --- a/libxsd/xsd/cxx/parser/xerces/elements.txx +++ b/libxsd/xsd/cxx/parser/xerces/elements.txx @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -670,6 +671,9 @@ namespace xsd const XMLCh* const /*qname*/, const xercesc::Attributes& attributes) { + using xercesc::XMLUni; + using xercesc::XMLString; + typedef std::basic_string string; { @@ -798,7 +802,17 @@ namespace xsd for (unsigned int i (0), end (attributes.getLength()); i < end; ++i) #endif { - string ns (xml::transcode (attributes.getURI (i))); + const XMLCh* xns (attributes.getURI (i)); + + // When SAX2 reports the xmlns attribute, it does not include + // the proper attribute namespace. So we have to detect and + // rectify this case. + // + if (XMLString::equals (attributes.getQName (i), + XMLUni::fgXMLNSString)) + xns = XMLUni::fgXMLNSURIName; + + string ns (xml::transcode (xns)); string name (xml::transcode (attributes.getLocalName (i))); string value (xml::transcode (attributes.getValue (i))); -- cgit v1.1