From e33535905af7f2f35e9588ecaa6611b2f2dad1a8 Mon Sep 17 00:00:00 2001 From: jez Date: Thu, 26 Feb 2009 14:04:41 +0000 Subject: [PATCH] propagating qualified name changes --- include/SAX/wrappers/saxlibxml2.hpp | 32 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/include/SAX/wrappers/saxlibxml2.hpp b/include/SAX/wrappers/saxlibxml2.hpp index 530c372d..33d0f196 100644 --- a/include/SAX/wrappers/saxlibxml2.hpp +++ b/include/SAX/wrappers/saxlibxml2.hpp @@ -140,6 +140,8 @@ class libxml2_wrapper : typedef typename XMLReaderT::template Property setLexicalHandlerT; typedef typename XMLReaderT::template Property getDeclHandlerT; typedef typename XMLReaderT::template Property setDeclHandlerT; + typedef XML::QualifiedName qualifiedNameT; + libxml2_wrapper(); ~libxml2_wrapper(); @@ -203,7 +205,7 @@ class libxml2_wrapper : virtual void SAXentityDecl(const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content); virtual xmlParserInputPtr SAXresolveEntity(const xmlChar* publicId, const xmlChar* systemId); - typename NamespaceSupport::Parts processName(const string_type& qName, bool isAttribute); + qualifiedNameT processName(const string_type& qName, bool isAttribute); void reportError(const std::string& message, bool fatal = false); void checkNotParsing(const string_type& type, const string_type& name) const; @@ -375,11 +377,10 @@ void libxml2_wrapper::doSetProperty(const string_type& name } // doSetProperty template -typename SAX::NamespaceSupport::string_adaptor>::Parts libxml2_wrapper::processName(const string_type& qName, bool isAttribute) +typename XML::QualifiedName::string_adaptor> libxml2_wrapper::processName(const string_type& qName, bool isAttribute) { - typename NamespaceSupport::Parts p = - nsSupport_.processName(qName, isAttribute); - if(string_adaptor::empty(p.URI) && !string_adaptor::empty(p.prefix)) + qualifiedNameT p = nsSupport_.processName(qName, isAttribute); + if(string_adaptor::empty(p.namespaceUri()) && !string_adaptor::empty(p.prefix())) reportError(std::string("Undeclared prefix ") + string_adaptor::asStdString(qName)); return p; } // processName @@ -580,10 +581,10 @@ void libxml2_wrapper::SAXstartElement(const xmlChar* qName, // declaration? if(string_adaptor::find(attQName, nsc_.xmlns) != 0) { - typename NamespaceSupport::Parts attName = processName(attQName, true); - attributes.addAttribute(attName.URI, - attName.localName, - attName.rawName, + qualifiedNameT attName = processName(attQName, true); + attributes.addAttribute(attName.namespaceUri(), + attName.localName(), + attName.rawName(), attributeTypeT::CDATA, value); } @@ -591,8 +592,11 @@ void libxml2_wrapper::SAXstartElement(const xmlChar* qName, } // if ... // at last! report the event - typename NamespaceSupport::Parts name = processName(string_adaptor::construct_from_utf8(reinterpret_cast(qName)), false); - contentHandler_->startElement(name.URI, name.localName, name.rawName, attributes); + qualifiedNameT name = processName(string_adaptor::construct_from_utf8(reinterpret_cast(qName)), false); + contentHandler_->startElement(name.namespaceUri(), + name.localName(), + name.rawName(), + attributes); } // SAXstartElement template @@ -630,8 +634,10 @@ void libxml2_wrapper::SAXendElement(const xmlChar* qName) return; } // if(!namespaces_) - typename NamespaceSupport::Parts name = processName(string_adaptor::construct_from_utf8(reinterpret_cast(qName)), false); - contentHandler_->endElement(name.URI, name.localName, name.rawName); + qualifiedNameT name = processName(string_adaptor::construct_from_utf8(reinterpret_cast(qName)), false); + contentHandler_->endElement(name.namespaceUri(), + name.localName(), + name.rawName()); typename NamespaceSupport::stringListT prefixes = nsSupport_.getDeclaredPrefixes(); for(size_t i = 0, end = prefixes.size(); i < end; ++i) contentHandler_->endPrefixMapping(prefixes[i]);