diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-07-02 22:31:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-07-02 22:31:03 +0200 |
commit | b25ac8848dea4df378861f518b562df38a77ed91 (patch) | |
tree | ab902978066de03396f6afd67147fd3d2a927975 /libxsd/xsd | |
parent | d2500d91f19608de98b07d55fa02a7ab3cf03b1c (diff) |
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".
Diffstat (limited to 'libxsd/xsd')
-rw-r--r-- | libxsd/xsd/cxx/parser/xerces/elements.txx | 16 |
1 files changed, 15 insertions, 1 deletions
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 <xercesc/sax2/XMLReaderFactory.hpp> #include <xercesc/validators/schema/SchemaSymbols.hpp> #include <xercesc/util/XMLUni.hpp> +#include <xercesc/util/XMLString.hpp> #include <xsd/cxx/xml/string.hxx> #include <xsd/cxx/xml/sax/std-input-source.hxx> @@ -670,6 +671,9 @@ namespace xsd const XMLCh* const /*qname*/, const xercesc::Attributes& attributes) { + using xercesc::XMLUni; + using xercesc::XMLString; + typedef std::basic_string<C> string; { @@ -798,7 +802,17 @@ namespace xsd for (unsigned int i (0), end (attributes.getLength()); i < end; ++i) #endif { - string ns (xml::transcode<C> (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<C> (xns)); string name (xml::transcode<C> (attributes.getLocalName (i))); string value (xml::transcode<C> (attributes.getValue (i))); |