diff --git a/examples/SAX/pyx.cpp b/examples/SAX/pyx.cpp index 3396375b..536ca907 100644 --- a/examples/SAX/pyx.cpp +++ b/examples/SAX/pyx.cpp @@ -53,7 +53,11 @@ int main(int argc, char* argv[]) Arabica::SAX::XMLReader myParser; myParser.setContentHandler(handler); myParser.setErrorHandler(handler); - myParser.setFeature("prohibit-dtd", false); + try { + myParser.setFeature("prohibit-dtd", false); + } + catch(...) { + } Arabica::SAX::InputSource is(argv[i]); myParser.parse(is); diff --git a/include/SAX/wrappers/saxexpat.hpp b/include/SAX/wrappers/saxexpat.hpp index 97f6058b..00d63fc3 100644 --- a/include/SAX/wrappers/saxexpat.hpp +++ b/include/SAX/wrappers/saxexpat.hpp @@ -201,13 +201,12 @@ template class expat_wrapper : public SAX::XMLReaderInterface, - public expat_wrapper_impl_mumbojumbo::expat2base + public SAX::Locator::string_adaptor>, + public expat_wrapper_impl_mumbojumbo::expat2base { public: - typedef typename Arabica::get_param, - T0, - T1>::type string_adaptor; + typedef SAX::XMLReaderInterface XMLReaderT; + typedef typename XMLReaderT::string_adaptor string_adaptor; typedef string_adaptor SA; typedef SAX::EntityResolver entityResolverT; typedef SAX::DTDHandler dtdHandlerT; @@ -219,7 +218,6 @@ class expat_wrapper : public SAX::XMLReaderInterface, typedef SAX::NamespaceSupport namespaceSupportT; typedef SAX::ErrorHandler errorHandlerT; typedef SAX::SAXParseException SAXParseExceptionT; - typedef SAX::XMLReaderInterface XMLReaderT; typedef typename XMLReaderT::PropertyBase PropertyBaseT; typedef typename XMLReaderT::template Property getLexicalHandlerT; typedef typename XMLReaderT::template Property setLexicalHandlerT; @@ -255,29 +253,13 @@ class expat_wrapper : public SAX::XMLReaderInterface, private: bool do_parse(inputSourceT& source, XML_Parser parser); - private: + public: ////////////////////////////////////////////////// // Locator - class Locator : public SAX::Locator - { - public: - Locator(const expat_wrapper& e) : e_(e) { } - virtual string_type getPublicId() const { return e_.getPublicId(); } - virtual string_type getSystemId() const { return e_.getSystemId(); } - virtual int getLineNumber() const { return e_.getLineNumber(); } - virtual int getColumnNumber() const { return e_.getColumnNumber(); } - private: - const expat_wrapper& e_; - }; // class Locator - - friend class Locator; - - Locator locator_; - - string_type getPublicId() const; - string_type getSystemId() const; - int getLineNumber() const; - int getColumnNumber() const; + virtual string_type getPublicId() const; + virtual string_type getSystemId() const; + virtual int getLineNumber() const; + virtual int getColumnNumber() const; /////////////////////////////////////////////////// // properties @@ -376,8 +358,7 @@ expat_wrapper::expat_wrapper() : parsing_(false), namespaces_(true), prefixes_(true), - externalResolving_(false), - locator_(*this) + externalResolving_(false) { } // expat @@ -476,7 +457,7 @@ void expat_wrapper::parse(inputSourceT& source) systemId_ = source.getSystemId(); if(contentHandler_) - contentHandler_->setDocumentLocator(locator_); + contentHandler_->setDocumentLocator(*this); parsing_ = true; diff --git a/include/SAX/wrappers/saxlibxml2.hpp b/include/SAX/wrappers/saxlibxml2.hpp index fc927976..438e24bb 100644 --- a/include/SAX/wrappers/saxlibxml2.hpp +++ b/include/SAX/wrappers/saxlibxml2.hpp @@ -115,28 +115,23 @@ xmlSAXHandler* lwit_SaxHandler(); template -class libxml2_wrapper : public XMLReaderInterface, - public Locator, +class libxml2_wrapper : public XMLReaderInterface, + public Locator::string_adaptor>, protected libxml2_wrapper_impl_tiddle::libxml2_base { public: - typedef string_type stringT; - typedef typename Arabica::get_param, - T0, - T1>::type string_adaptor_type; - typedef string_adaptor_type string_adaptorT; - typedef SAX::EntityResolver entityResolverT; - typedef SAX::DTDHandler dtdHandlerT; - typedef SAX::ContentHandler contentHandlerT; - typedef SAX::DeclHandler declHandlerT; - typedef SAX::LexicalHandler lexicalHandlerT; - typedef SAX::InputSource inputSourceT; - typedef SAX::Locator locatorT; - typedef SAX::NamespaceSupport namespaceSupportT; - typedef SAX::ErrorHandler errorHandlerT; - typedef SAX::SAXParseException SAXParseExceptionT; - typedef SAX::XMLReaderInterface XMLReaderT; + typedef XMLReaderInterface XMLReaderT; + typedef typename XMLReaderT::string_adaptor string_adaptor; + typedef SAX::EntityResolver entityResolverT; + typedef SAX::DTDHandler dtdHandlerT; + typedef SAX::ContentHandler contentHandlerT; + typedef SAX::DeclHandler declHandlerT; + typedef SAX::LexicalHandler lexicalHandlerT; + typedef SAX::InputSource inputSourceT; + typedef SAX::Locator locatorT; + typedef SAX::NamespaceSupport namespaceSupportT; + typedef SAX::ErrorHandler errorHandlerT; + typedef SAX::SAXParseException SAXParseExceptionT; typedef typename XMLReaderT::PropertyBase PropertyBaseT; typedef typename XMLReaderT::template Property getLexicalHandlerT; typedef typename XMLReaderT::template Property setLexicalHandlerT; @@ -147,17 +142,17 @@ class libxml2_wrapper : public XMLReaderInterface, //////////////////////////////////////////////// // configuration - virtual bool getFeature(const stringT& name) const; - virtual void setFeature(const stringT& name, bool value); + virtual bool getFeature(const string_type& name) const; + virtual void setFeature(const string_type& name, bool value); //////////////////////////////////////////////// // Event Handlers - virtual void setEntityResolver(EntityResolver& resolver) { entityResolver_ = &resolver; } - virtual EntityResolver* getEntityResolver() const { return entityResolver_; } - virtual void setDTDHandler(DTDHandler& handler) { dtdHandler_ = &handler; } - virtual DTDHandler* getDTDHandler() const { return dtdHandler_; } - virtual void setContentHandler(ContentHandler& handler) { contentHandler_ = &handler; } - virtual ContentHandler* getContentHandler() const { return contentHandler_; } + virtual void setEntityResolver(EntityResolver& resolver) { entityResolver_ = &resolver; } + virtual EntityResolver* getEntityResolver() const { return entityResolver_; } + virtual void setDTDHandler(DTDHandler& handler) { dtdHandler_ = &handler; } + virtual DTDHandler* getDTDHandler() const { return dtdHandler_; } + virtual void setContentHandler(ContentHandler& handler) { contentHandler_ = &handler; } + virtual ContentHandler* getContentHandler() const { return contentHandler_; } virtual void setErrorHandler(errorHandlerT& handler) { errorHandler_ = &handler; } virtual errorHandlerT* getErrorHandler() const { return errorHandler_; } virtual void setDeclHandler(declHandlerT& handler) { declHandler_ = &handler; } @@ -167,17 +162,17 @@ class libxml2_wrapper : public XMLReaderInterface, //////////////////////////////////////////////// // parsing - virtual void parse(InputSource& source); + virtual void parse(InputSource& source); protected: //////////////////////////////////////////////// // properties - virtual std::auto_ptr doGetProperty(const stringT& name); - virtual void doSetProperty(const stringT& name, std::auto_ptr value); + virtual std::auto_ptr doGetProperty(const string_type& name); + virtual void doSetProperty(const string_type& name, std::auto_ptr value); public: - virtual stringT getPublicId() const; - virtual stringT getSystemId() const; + virtual string_type getPublicId() const; + virtual string_type getSystemId() const; virtual int getLineNumber() const; virtual int getColumnNumber() const; @@ -201,13 +196,13 @@ class libxml2_wrapper : public XMLReaderInterface, virtual void SAXelementDecl(const xmlChar* name, int type, xmlElementContentPtr content); void convertXML_Content(std::ostream& os, int type, xmlElementContentPtr model, bool isChild) const; virtual void SAXattributeDecl(const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree); - stringT stringAttrEnum(xmlEnumerationPtr tree, bool leadingSpace) const; + string_type stringAttrEnum(xmlEnumerationPtr tree, bool leadingSpace) const; 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 stringT& qName, bool isAttribute); + typename NamespaceSupport::Parts processName(const string_type& qName, bool isAttribute); void reportError(const std::string& message, bool fatal = false); - void checkNotParsing(const stringT& type, const stringT& name) const; + void checkNotParsing(const string_type& type, const string_type& name) const; private: // member variables @@ -227,16 +222,16 @@ class libxml2_wrapper : public XMLReaderInterface, bool namespaces_; bool prefixes_; - stringT emptyString_; - const FeatureNames features_; - const PropertyNames properties_; - const NamespaceConstants nsc_; - const AttributeDefaults attrDefaults_; - const AttributeTypes attrTypes_; + string_type emptyString_; + const FeatureNames features_; + const PropertyNames properties_; + const NamespaceConstants nsc_; + const AttributeDefaults attrDefaults_; + const AttributeTypes attrTypes_; }; // class libxml2_wrapper -template -libxml2_wrapper::libxml2_wrapper() : +template +libxml2_wrapper::libxml2_wrapper() : entityResolver_(0), dtdHandler_(0), contentHandler_(0), @@ -255,14 +250,14 @@ libxml2_wrapper::libxml2_wrapper() : xmlCtxtUseOptions(context_, XML_PARSE_DTDLOAD + XML_PARSE_DTDVALID + XML_PARSE_NOBLANKS); } // libxml2_wrapper -template -libxml2_wrapper::~libxml2_wrapper() +template +libxml2_wrapper::~libxml2_wrapper() { xmlFreeParserCtxt(context_); } // ~libxml2_wrapper -template -bool libxml2_wrapper::getFeature(const stringT& name) const +template +bool libxml2_wrapper::getFeature(const string_type& name) const { if(name == features_.namespaces) return namespaces_; @@ -278,20 +273,20 @@ bool libxml2_wrapper::getFeature(const stringT& name) const if(name == features_.external_parameter) { - throw SAX::SAXNotSupportedException(std::string("Feature not supported ") + string_adaptorT::asStdString(name)); + throw SAX::SAXNotSupportedException(std::string("Feature not supported ") + string_adaptor::asStdString(name)); } else { - throw SAX::SAXNotRecognizedException(std::string("Feature not recognized ") + string_adaptorT::asStdString(name)); + throw SAX::SAXNotRecognizedException(std::string("Feature not recognized ") + string_adaptor::asStdString(name)); } } // getFeature -template -void libxml2_wrapper::setFeature(const stringT& name, bool value) +template +void libxml2_wrapper::setFeature(const string_type& name, bool value) { if(name == features_.namespaces) { - checkNotParsing(string_adaptorT::construct_from_utf8("feature"), name); + checkNotParsing(string_adaptor::construct_from_utf8("feature"), name); namespaces_ = value; if(!namespaces_ && !prefixes_) prefixes_ = true; @@ -300,7 +295,7 @@ void libxml2_wrapper::setFeature(const stringT& name, bool valu if(name == features_.namespace_prefixes) { - checkNotParsing(string_adaptorT::construct_from_utf8("feature"), name); + checkNotParsing(string_adaptor::construct_from_utf8("feature"), name); prefixes_ = value; if(prefixes_ && !namespaces_) namespaces_ = true; @@ -322,22 +317,22 @@ void libxml2_wrapper::setFeature(const stringT& name, bool valu if(name == features_.external_parameter) { std::ostringstream os; - os << "Feature not supported " << string_adaptorT::asStdString(name); + os << "Feature not supported " << string_adaptor::asStdString(name); throw SAX::SAXNotSupportedException(os.str()); } else { std::ostringstream os; - os << "Feature not recognized " << string_adaptorT::asStdString(name); + os << "Feature not recognized " << string_adaptor::asStdString(name); throw SAX::SAXNotRecognizedException(os.str()); } } // setFeature -template +template #ifndef ARABICA_VS6_WORKAROUND -std::auto_ptr::PropertyBaseT> libxml2_wrapper::doGetProperty(const stringT& name) +std::auto_ptr::PropertyBaseT> libxml2_wrapper::doGetProperty(const string_type& name) #else -std::auto_ptr::PropertyBaseT> libxml2_wrapper::doGetProperty(const stringT& name) +std::auto_ptr::PropertyBaseT> libxml2_wrapper::doGetProperty(const string_type& name) #endif { if(name == properties_.declHandler) @@ -351,11 +346,11 @@ std::auto_ptr::PropertyBaseT> libxml2_wrapper(prop); } - throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptorT::asStdString(name)); + throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptor::asStdString(name)); } // doGetProperty -template -void libxml2_wrapper::doSetProperty(const stringT& name, std::auto_ptr value) +template +void libxml2_wrapper::doSetProperty(const string_type& name, std::auto_ptr value) { if(name == properties_.declHandler) { @@ -376,82 +371,82 @@ void libxml2_wrapper::doSetProperty(const stringT& name, std::a lexicalHandler_ = &(prop->get()); } - throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptorT::asStdString(name)); + throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptor::asStdString(name)); } // doSetProperty -template -typename SAX::NamespaceSupport::string_adaptorT>::Parts libxml2_wrapper::processName(const stringT& qName, bool isAttribute) +template +typename SAX::NamespaceSupport::string_adaptor>::Parts libxml2_wrapper::processName(const string_type& qName, bool isAttribute) { - typename NamespaceSupport::Parts p = + typename NamespaceSupport::Parts p = nsSupport_.processName(qName, isAttribute); - if(string_adaptorT::empty(p.URI) && !string_adaptorT::empty(p.prefix)) - reportError(std::string("Undeclared prefix ") + string_adaptorT::asStdString(qName)); + if(string_adaptor::empty(p.URI) && !string_adaptor::empty(p.prefix)) + reportError(std::string("Undeclared prefix ") + string_adaptor::asStdString(qName)); return p; } // processName -template -void libxml2_wrapper::reportError(const std::string& message, bool fatal) +template +void libxml2_wrapper::reportError(const std::string& message, bool fatal) { if(!errorHandler_) return; - SAXParseException e(message, *this); + SAXParseException e(message, *this); if(fatal) errorHandler_->fatalError(e); else errorHandler_->error(e); } // reportError -template -void libxml2_wrapper::checkNotParsing(const stringT& type, const stringT& name) const +template +void libxml2_wrapper::checkNotParsing(const string_type& type, const string_type& name) const { if(parsing_) { std::ostringstream os; - os << "Can't change " << string_adaptorT::asStdString(type) << " " << string_adaptorT::asStdString(name) << " while parsing"; + os << "Can't change " << string_adaptor::asStdString(type) << " " << string_adaptor::asStdString(name) << " while parsing"; throw SAX::SAXNotSupportedException(os.str()); } // if(parsing_) } // checkNotParsing -template -stringT libxml2_wrapper::getPublicId() const +template +string_type libxml2_wrapper::getPublicId() const { if(locator_) - return string_adaptorT::construct_from_utf8(reinterpret_cast(locator_->getPublicId(context_))); - return stringT(); + return string_adaptor::construct_from_utf8(reinterpret_cast(locator_->getPublicId(context_))); + return string_type(); } // getPublicId -template -stringT libxml2_wrapper::getSystemId() const +template +string_type libxml2_wrapper::getSystemId() const { if(locator_) - return string_adaptorT::construct_from_utf8(reinterpret_cast(locator_->getSystemId(context_))); - return stringT(); + return string_adaptor::construct_from_utf8(reinterpret_cast(locator_->getSystemId(context_))); + return string_type(); } // getSystemId -template -int libxml2_wrapper::getLineNumber() const +template +int libxml2_wrapper::getLineNumber() const { if(locator_) return locator_->getLineNumber(context_); return -1; } // getLineNumber -template -int libxml2_wrapper::getColumnNumber() const +template +int libxml2_wrapper::getColumnNumber() const { if(locator_) return locator_->getColumnNumber(context_); return -1; } // getColumnNumber -template -void libxml2_wrapper::parse(InputSource& source) +template +void libxml2_wrapper::parse(InputSource& source) { if(contentHandler_) contentHandler_->setDocumentLocator(*this); - InputSourceResolver is(source, string_adaptorT()); + InputSourceResolver is(source, string_adaptor()); if(is.resolve() == 0) return; @@ -469,72 +464,72 @@ void libxml2_wrapper::parse(InputSource& source) parsing_ = false; } // parse -template -void libxml2_wrapper::SAXstartDocument() +template +void libxml2_wrapper::SAXstartDocument() { if(contentHandler_) contentHandler_->startDocument(); } // SAXstartDocument -template -void libxml2_wrapper::SAXendDocument() +template +void libxml2_wrapper::SAXendDocument() { if(contentHandler_) contentHandler_->endDocument(); } // SAXendDocument -template -void libxml2_wrapper::SAXcharacters(const xmlChar* ch, int len) +template +void libxml2_wrapper::SAXcharacters(const xmlChar* ch, int len) { if(contentHandler_) - contentHandler_->characters(string_adaptorT::construct_from_utf8(reinterpret_cast(ch), len)); + contentHandler_->characters(string_adaptor::construct_from_utf8(reinterpret_cast(ch), len)); } // SAXcharacters -template -void libxml2_wrapper::SAXignorableWhitespace(const xmlChar* ch, int len) +template +void libxml2_wrapper::SAXignorableWhitespace(const xmlChar* ch, int len) { if(contentHandler_) - contentHandler_->ignorableWhitespace(string_adaptorT::construct_from_utf8(reinterpret_cast(ch), len)); + contentHandler_->ignorableWhitespace(string_adaptor::construct_from_utf8(reinterpret_cast(ch), len)); } // SAXignorableWhitespace -template -void libxml2_wrapper::SAXwarning(const std::string& warning) +template +void libxml2_wrapper::SAXwarning(const std::string& warning) { if(errorHandler_) - errorHandler_->warning(SAXParseException(warning, *this)); + errorHandler_->warning(SAXParseException(warning, *this)); } // warning -template -void libxml2_wrapper::SAXerror(const std::string& error) +template +void libxml2_wrapper::SAXerror(const std::string& error) { if(errorHandler_) - errorHandler_->error(SAXParseException(error, *this)); + errorHandler_->error(SAXParseException(error, *this)); } // error -template -void libxml2_wrapper::SAXfatalError(const std::string& fatal) +template +void libxml2_wrapper::SAXfatalError(const std::string& fatal) { if(errorHandler_) - errorHandler_->fatalError(SAXParseException(fatal, *this)); + errorHandler_->fatalError(SAXParseException(fatal, *this)); } // fatal -template -void libxml2_wrapper::SAXprocessingInstruction(const xmlChar* target, const xmlChar* data) +template +void libxml2_wrapper::SAXprocessingInstruction(const xmlChar* target, const xmlChar* data) { if(contentHandler_) - contentHandler_->processingInstruction(string_adaptorT::construct_from_utf8(reinterpret_cast(target)), - string_adaptorT::construct_from_utf8(reinterpret_cast(data))); + contentHandler_->processingInstruction(string_adaptor::construct_from_utf8(reinterpret_cast(target)), + string_adaptor::construct_from_utf8(reinterpret_cast(data))); } // SAXprocessingInstruction -template -void libxml2_wrapper::SAXcomment(const xmlChar* comment) +template +void libxml2_wrapper::SAXcomment(const xmlChar* comment) { if(lexicalHandler_) - lexicalHandler_->comment(string_adaptorT::construct_from_utf8(reinterpret_cast(comment))); + lexicalHandler_->comment(string_adaptor::construct_from_utf8(reinterpret_cast(comment))); } // SAXcomment -template -void libxml2_wrapper::SAXstartElement(const xmlChar* qName, const xmlChar** atts) +template +void libxml2_wrapper::SAXstartElement(const xmlChar* qName, const xmlChar** atts) { if(!contentHandler_) return; @@ -547,7 +542,7 @@ void libxml2_wrapper::SAXstartElement(const xmlChar* qName, con // OK we're doing Namespaces nsSupport_.pushContext(); - SAX::AttributesImpl attributes; + SAX::AttributesImpl attributes; // take a first pass and copy all the attributes, noting any declarations if(atts && *atts != 0) @@ -555,18 +550,18 @@ void libxml2_wrapper::SAXstartElement(const xmlChar* qName, con const xmlChar** a1 = atts; while(*a1 != 0) { - stringT attQName = string_adaptorT::construct_from_utf8(reinterpret_cast(*a1++)); - stringT value = string_adaptorT::construct_from_utf8(reinterpret_cast(*a1++)); + string_type attQName = string_adaptor::construct_from_utf8(reinterpret_cast(*a1++)); + string_type value = string_adaptor::construct_from_utf8(reinterpret_cast(*a1++)); // declaration? - if(string_adaptorT::find(attQName, nsc_.xmlns) == 0) + if(string_adaptor::find(attQName, nsc_.xmlns) == 0) { - stringT prefix; - typename string_adaptorT::size_type n = string_adaptorT::find(attQName, nsc_.colon); - if(n != string_adaptorT::npos()) - prefix = string_adaptorT::construct(string_adaptorT::begin(attQName) + n + 1, string_adaptorT::end(attQName)); + string_type prefix; + typename string_adaptor::size_type n = string_adaptor::find(attQName, nsc_.colon); + if(n != string_adaptor::npos()) + prefix = string_adaptor::construct(string_adaptor::begin(attQName) + n + 1, string_adaptor::end(attQName)); if(!nsSupport_.declarePrefix(prefix, value)) - reportError(std::string("Illegal Namespace prefix ") + string_adaptorT::asStdString(prefix)); + reportError(std::string("Illegal Namespace prefix ") + string_adaptor::asStdString(prefix)); contentHandler_->startPrefixMapping(prefix, value); if(prefixes_) attributes.addAttribute(emptyString_, @@ -579,44 +574,44 @@ void libxml2_wrapper::SAXstartElement(const xmlChar* qName, con while(*atts != 0) { - stringT attQName = string_adaptorT::construct_from_utf8(reinterpret_cast(*atts++)); - stringT value = string_adaptorT::construct_from_utf8(reinterpret_cast(*atts++)); + string_type attQName = string_adaptor::construct_from_utf8(reinterpret_cast(*atts++)); + string_type value = string_adaptor::construct_from_utf8(reinterpret_cast(*atts++)); // declaration? - if(string_adaptorT::find(attQName, nsc_.xmlns) != 0) + if(string_adaptor::find(attQName, nsc_.xmlns) != 0) { - typename NamespaceSupport::Parts attName = processName(attQName, true); + typename NamespaceSupport::Parts attName = processName(attQName, true); attributes.addAttribute(attName.URI, attName.localName, attName.rawName, emptyString_, value); } } // while ... } // if ... // at last! report the event - typename NamespaceSupport::Parts name = processName(string_adaptorT::construct_from_utf8(reinterpret_cast(qName)), false); + typename NamespaceSupport::Parts name = processName(string_adaptor::construct_from_utf8(reinterpret_cast(qName)), false); contentHandler_->startElement(name.URI, name.localName, name.rawName, attributes); } // SAXstartElement -template -void libxml2_wrapper::SAXstartElementNoNS(const xmlChar* qName, const xmlChar** atts) +template +void libxml2_wrapper::SAXstartElementNoNS(const xmlChar* qName, const xmlChar** atts) { - SAX::AttributesImpl attributes; + SAX::AttributesImpl attributes; if(atts && *atts != 0) { while(*atts != 0) { - stringT attQName = string_adaptorT::construct_from_utf8(reinterpret_cast(*atts++)); - stringT value = string_adaptorT::construct_from_utf8(reinterpret_cast(*atts++)); + string_type attQName = string_adaptor::construct_from_utf8(reinterpret_cast(*atts++)); + string_type value = string_adaptor::construct_from_utf8(reinterpret_cast(*atts++)); attributes.addAttribute(emptyString_, emptyString_, attQName, emptyString_, value); } // while .. } // if ... - contentHandler_->startElement(emptyString_, emptyString_, string_adaptorT::construct_from_utf8((reinterpret_cast(qName))), attributes); + contentHandler_->startElement(emptyString_, emptyString_, string_adaptor::construct_from_utf8((reinterpret_cast(qName))), attributes); } // SAXstartElementNoNS -template -void libxml2_wrapper::SAXendElement(const xmlChar* qName) +template +void libxml2_wrapper::SAXendElement(const xmlChar* qName) { if(!contentHandler_) return; @@ -627,53 +622,53 @@ void libxml2_wrapper::SAXendElement(const xmlChar* qName) return; } // if(!namespaces_) - typename NamespaceSupport::Parts name = processName(string_adaptorT::construct_from_utf8(reinterpret_cast(qName)), false); + typename NamespaceSupport::Parts name = processName(string_adaptor::construct_from_utf8(reinterpret_cast(qName)), false); contentHandler_->endElement(name.URI, name.localName, name.rawName); - typename NamespaceSupport::stringListT prefixes = nsSupport_.getDeclaredPrefixes(); + typename NamespaceSupport::stringListT prefixes = nsSupport_.getDeclaredPrefixes(); for(size_t i = 0, end = prefixes.size(); i < end; ++i) contentHandler_->endPrefixMapping(prefixes[i]); nsSupport_.popContext(); } // SAXendElement -template -void libxml2_wrapper::SAXendElementNoNS(const xmlChar* qName) +template +void libxml2_wrapper::SAXendElementNoNS(const xmlChar* qName) { if(contentHandler_) - contentHandler_->endElement(emptyString_, emptyString_, string_adaptorT::construct_from_utf8(reinterpret_cast(qName))); + contentHandler_->endElement(emptyString_, emptyString_, string_adaptor::construct_from_utf8(reinterpret_cast(qName))); } // SAXendElementNoNS -template -void libxml2_wrapper::SAXnotationDecl(const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) +template +void libxml2_wrapper::SAXnotationDecl(const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) { if(dtdHandler_) - dtdHandler_->notationDecl(string_adaptorT::construct_from_utf8(reinterpret_cast(name)), - string_adaptorT::construct_from_utf8(reinterpret_cast(publicId)), - string_adaptorT::construct_from_utf8(reinterpret_cast(systemId))); + dtdHandler_->notationDecl(string_adaptor::construct_from_utf8(reinterpret_cast(name)), + string_adaptor::construct_from_utf8(reinterpret_cast(publicId)), + string_adaptor::construct_from_utf8(reinterpret_cast(systemId))); } // SAXnotationDecl -template -void libxml2_wrapper::SAXunparsedEntityDecl(const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) +template +void libxml2_wrapper::SAXunparsedEntityDecl(const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) { if(dtdHandler_) - dtdHandler_->unparsedEntityDecl(string_adaptorT::construct_from_utf8(reinterpret_cast(name)), - string_adaptorT::construct_from_utf8(reinterpret_cast(publicId)), - string_adaptorT::construct_from_utf8(reinterpret_cast(systemId)), - string_adaptorT::construct_from_utf8(reinterpret_cast(notationName))); + dtdHandler_->unparsedEntityDecl(string_adaptor::construct_from_utf8(reinterpret_cast(name)), + string_adaptor::construct_from_utf8(reinterpret_cast(publicId)), + string_adaptor::construct_from_utf8(reinterpret_cast(systemId)), + string_adaptor::construct_from_utf8(reinterpret_cast(notationName))); } // SAXunparsedEntityDecl -template -void libxml2_wrapper::SAXelementDecl(const xmlChar* name, int type, xmlElementContentPtr content) +template +void libxml2_wrapper::SAXelementDecl(const xmlChar* name, int type, xmlElementContentPtr content) { if(!declHandler_) return; std::ostringstream os; convertXML_Content(os, type, content, false); - declHandler_->elementDecl(string_adaptorT::construct_from_utf8(reinterpret_cast(name)), string_adaptorT::construct_from_utf8(os.str().c_str())); + declHandler_->elementDecl(string_adaptor::construct_from_utf8(reinterpret_cast(name)), string_adaptor::construct_from_utf8(os.str().c_str())); } // elementDeclaration -template -void libxml2_wrapper::convertXML_Content(std::ostream& os, int type, xmlElementContentPtr model, bool isChild) const +template +void libxml2_wrapper::convertXML_Content(std::ostream& os, int type, xmlElementContentPtr model, bool isChild) const { char concatenator = ' '; @@ -745,17 +740,17 @@ void libxml2_wrapper::convertXML_Content(std::ostream& os, int } // switch } // convertXML_Content -template -void libxml2_wrapper::SAXattributeDecl(const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree) +template +void libxml2_wrapper::SAXattributeDecl(const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree) { if(!declHandler_) return; - const stringT* defType = &attrDefaults_.implied; + const string_type* defType = &attrDefaults_.implied; if(def) defType = (defaultValue) ? &attrDefaults_.fixed : &attrDefaults_.required; - stringT typeStr; + string_type typeStr; switch(type) { case XML_ATTRIBUTE_CDATA: @@ -786,20 +781,20 @@ void libxml2_wrapper::SAXattributeDecl(const xmlChar *elem, con typeStr = stringAttrEnum(tree, false); break; case XML_ATTRIBUTE_NOTATION: - string_adaptorT::append(typeStr, attrTypes_.notation); - string_adaptorT::append(typeStr, stringAttrEnum(tree, true)); + string_adaptor::append(typeStr, attrTypes_.notation); + string_adaptor::append(typeStr, stringAttrEnum(tree, true)); break; } // switch(type) - declHandler_->attributeDecl(string_adaptorT::construct_from_utf8(reinterpret_cast(elem)), - string_adaptorT::construct_from_utf8(reinterpret_cast(fullname)), + declHandler_->attributeDecl(string_adaptor::construct_from_utf8(reinterpret_cast(elem)), + string_adaptor::construct_from_utf8(reinterpret_cast(fullname)), typeStr, *defType, - string_adaptorT::construct_from_utf8(reinterpret_cast(defaultValue))); + string_adaptor::construct_from_utf8(reinterpret_cast(defaultValue))); } // SAXattributeDecl -template -stringT libxml2_wrapper::stringAttrEnum(xmlEnumerationPtr tree, bool leadingSpace) const +template +string_type libxml2_wrapper::stringAttrEnum(xmlEnumerationPtr tree, bool leadingSpace) const { std::ostringstream os; if(leadingSpace) @@ -814,11 +809,11 @@ stringT libxml2_wrapper::stringAttrEnum(xmlEnumerationPtr tree } // while os << ")"; - return string_adaptorT::construct_from_utf8(os.str().c_str()); + return string_adaptor::construct_from_utf8(os.str().c_str()); } // stringAttrEnum -template -void libxml2_wrapper::SAXentityDecl(const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) +template +void libxml2_wrapper::SAXentityDecl(const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) { if(!declHandler_) return; @@ -826,19 +821,19 @@ void libxml2_wrapper::SAXentityDecl(const xmlChar *name, int ty switch(type) { case 1: // internal - declHandler_->internalEntityDecl(string_adaptorT::construct_from_utf8(reinterpret_cast(name)), - string_adaptorT::construct_from_utf8(reinterpret_cast(content))); + declHandler_->internalEntityDecl(string_adaptor::construct_from_utf8(reinterpret_cast(name)), + string_adaptor::construct_from_utf8(reinterpret_cast(content))); break; case 2: // external - declHandler_->externalEntityDecl(string_adaptorT::construct_from_utf8(reinterpret_cast(name)), - string_adaptorT::construct_from_utf8(reinterpret_cast(publicId)), - string_adaptorT::construct_from_utf8(reinterpret_cast(systemId))); + declHandler_->externalEntityDecl(string_adaptor::construct_from_utf8(reinterpret_cast(name)), + string_adaptor::construct_from_utf8(reinterpret_cast(publicId)), + string_adaptor::construct_from_utf8(reinterpret_cast(systemId))); break; } // switch } // SAXentityDecl -template -xmlParserInputPtr libxml2_wrapper::SAXresolveEntity(const xmlChar* publicId, const xmlChar* systemId) +template +xmlParserInputPtr libxml2_wrapper::SAXresolveEntity(const xmlChar* publicId, const xmlChar* systemId) { if(!entityResolver_) return xmlLoadExternalEntity(reinterpret_cast(systemId), diff --git a/src/SAX/helpers/InputSourceResolver.cpp b/src/SAX/helpers/InputSourceResolver.cpp index d51f0136..255895b6 100644 --- a/src/SAX/helpers/InputSourceResolver.cpp +++ b/src/SAX/helpers/InputSourceResolver.cpp @@ -15,15 +15,6 @@ using namespace Arabica::SAX; -InputSourceResolver::InputSourceResolver(const Arabica::SAX::InputSource& inputSource) : - deleteStream_(false), - byteStream_(0) -{ - open(inputSource.getPublicId(), - inputSource.getSystemId(), - inputSource.getByteStream()); -} // InputSourceResolver - void InputSourceResolver::open(const std::string& publicId, const std::string& systemId, std::istream* byteStream)