diff --git a/DOM/SAX2DOM/SAX2DOM.h b/DOM/SAX2DOM/SAX2DOM.h index 9a7d5ee1..581367dc 100644 --- a/DOM/SAX2DOM/SAX2DOM.h +++ b/DOM/SAX2DOM/SAX2DOM.h @@ -65,14 +65,10 @@ class Parser : private SAX::basic_DefaultHandler2 parser.setErrorHandler(*this); if(entityResolver_) parser.setEntityResolver(*entityResolver_); - try - { - parser.setProperty(pNames.lexicalHandler, static_cast&>(*this)); - parser.setProperty(pNames.declHandler, static_cast&>(*this)); - } - catch(SAX::SAXException&) - { - } // catch + + setParserProperty >(parser, pNames.lexicalHandler); + setParserProperty >(parser, pNames.declHandler); + parser.setFeature(fNames.namespaces, true); parser.setFeature(fNames.namespace_prefixes, true); //parser.setFeature(fNames.external_general, true); @@ -128,6 +124,15 @@ class Parser : private SAX::basic_DefaultHandler2 SAX::AttributeTypes attributeTypes_; private: + template + void setParserProperty(SAX_parser& parser, const stringT& propertyName) + { + try { + parser.setProperty(propertyName, static_cast(*this)); + } // try + catch(SAX::SAXException&) { } + } // setParserProperty + /////////////////////////////////////////////////////////// // ContentHandler virtual void endDocument()