Completely removed XMLReader setProperty and getProperty member functions.

For nearly everyone, their use can be replaced by either setLexicalHandler
or setDeclHandler. For the particular case of the Xerces extended properties
I'll loop back round and add specific member methods for those.
This commit is contained in:
Jez Higgins 2020-04-16 20:23:59 +01:00
parent 18e1da2f93
commit 6bf75264de
24 changed files with 101 additions and 662 deletions

View file

@ -196,7 +196,6 @@ set(PUBLIC_HEADER_FILES
include/SAX/helpers/InputSourceResolver.hpp
include/SAX/helpers/LocatorImpl.hpp
include/SAX/helpers/NamespaceSupport.hpp
include/SAX/helpers/PropertyNames.hpp
include/SAX/helpers/XMLBaseSupport.hpp
include/SAX/helpers/XMLFilterImpl.hpp
include/SAX/parsers/saxgarden.hpp

View file

@ -5,7 +5,6 @@
#include "SimpleHandler.hpp"
#include <SAX/InputSource.hpp>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <iostream>
#include <sstream>
@ -20,7 +19,6 @@ int main(int argc, char* argv[])
SimpleHandler myHandler;
Arabica::SAX::FeatureNames<std::string> fNames;
Arabica::SAX::PropertyNames<std::string> pNames;
for(int i = 1; i < argc; ++i)
{

View file

@ -13,7 +13,6 @@
#include <DOM/SAX2DOM/DocumentTypeImpl.hpp>
#include <map>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <SAX/SAXParseException.hpp>
namespace Arabica
@ -97,8 +96,6 @@ class Parser : protected Arabica::SAX::DefaultHandler<stringT, typename ParserTy
bool parse(InputSourceT& source)
{
Arabica::SAX::PropertyNames<stringT, string_adaptorT> pNames;
DOM::DOMImplementation<stringT, string_adaptorT> di = Arabica::SimpleDOM::DOMImplementation<stringT, string_adaptorT>::getDOMImplementation();
document_ = di.createDocument(string_adaptorT::construct_from_utf8(""), string_adaptorT::construct_from_utf8(""), 0);
currentNode_ = document_;

View file

@ -42,7 +42,6 @@ sax_headers = SAX/SAXParseException.hpp \
SAX/helpers/LocatorImpl.hpp \
SAX/helpers/NamespaceSupport.hpp \
SAX/helpers/XMLFilterImpl.hpp \
SAX/helpers/PropertyNames.hpp \
SAX/helpers/AttributesImpl.hpp \
SAX/helpers/DefaultHandler.hpp \
SAX/helpers/InputSourceResolver.hpp \

View file

@ -1,12 +1,94 @@
#ifndef ARABICA_ARABICA_CONFIG_H
#define ARABICA_ARABICA_CONFIG_H
/* include/SAX/ArabicaConfig.hpp.in. Generated from configure.ac by autoheader. */
#cmakedefine ARABICA_NO_WCHAR_T
#cmakedefine ARABICA_VS6_WORKAROUND
#cmakedefine ARABICA_NO_CODECVT_SPECIALISATIONS
#cmakedefine ARABICA_USE_WINSOCK
#cmakedefine ARABICA_WINDOWS
#cmakedefine ARABICA_HAVE_BOOST
#define ARABICA_@ARABICA_XML_BACKEND@
/* define if the Boost library is available */
#undef HAVE_BOOST
#endif // ARABICA_ARABICA_CONFIG_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* define to use the Elephant memory leak detector */
#undef HAVE_ELEPHANT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* defined if we don't need extra codecvt template specialisations */
#undef NO_CODECVT_SPECIALISATIONS
/* no mbstate_t */
#undef NO_MBSTATE_T
/* no std::mbstate_t */
#undef NO_STD_MBSTATE_T
/* disables wchar_t */
#undef NO_WCHAR_T
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* define to build against Expat */
#define USE_EXPAT
/* define to build using Garden */
#undef USE_GARDEN
/* define to build against LibXML2 */
#undef USE_LIBXML2
/* defined for Windows builds using Winsock rather than BSD-style sockets */
#undef USE_WINSOCK
/* define to build against Xerces */
#undef USE_XERCES
/* Version number of package */
#undef VERSION

View file

@ -336,106 +336,6 @@ public:
* @see #setErrorHandler
*/
virtual void parse(InputSourceT& input) = 0;
////////////////////////////////////////////////////
// property implementation
protected:
class PropertyBase
{
public:
virtual ~PropertyBase() { }
}; // PropertyBase
template<typename propertyTypeT>
class Property : public PropertyBase
{
public:
Property(propertyTypeT wrappee) : wrappee_(wrappee) { }
propertyTypeT get() { return wrappee_; }
private:
propertyTypeT wrappee_;
}; // class Property
public:
virtual std::auto_ptr<PropertyBase> doGetProperty(const string_type& name) = 0;
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBase> value) = 0;
/**
* Look up the value of a property.
*
* <p>The property name is any fully-qualified URI. It is
* possible for an XMLReader to recognize a property name but
* to be unable to return its state; this is especially true
* in the case of an adapter for a SAX1 {@link Parser
* Parser}.</p>
*
* <p>XMLReaders are not required to recognize any specific
* property names, though an initial core set is documented for
* SAX2.</p>
*
* <p>Some property values may be available only in specific
* contexts, such as before, during, or after a parse.</p>
*
* <p>Implementors are free (and encouraged) to invent their own properties,
* using names built on their own URIs.</p>
*
* @param name The property name, which is a fully-qualified URI.
* @return The current value of the property.
* @exception SAXNotRecognizedException When the
* XMLReader does not recognize the property name.
* @exception SAXNotSupportedException When the
* XMLReader recognizes the property name but
* cannot determine its value at this time.
* @see #setProperty
*/
template<typename propertyTypeT>
propertyTypeT& getProperty(const string_type& name) const
{
std::auto_ptr<PropertyBase> pb = doGetProperty(name);
Property<propertyTypeT&>* prop = dynamic_cast<Property<propertyTypeT&>* >(pb.get());
if(!prop)
throw SAX::SAXNotSupportedException("Property " + name + " is wrong type.");
return prop->get();
} // getProperty
/**
* Set the value of a property.
*
* <p>The property name is any fully-qualified URI. It is
* possible for an XMLReader to recognize a property name but
* to be unable to set its value; this is especially true
* in the case of an adapter for a SAX1 {@link Parser
* Parser}.</p>
*
* <p>XMLReaders are not required to recognize setting
* any specific property names, though a core set is provided with
* SAX2.</p>
*
* <p>Some property values may be immutable or mutable only
* in specific contexts, such as before, during, or after
* a parse.</p>
*
* <p>This method is also the standard mechanism for setting
* extended handlers.</p>
*
* @param name The property name, which is a fully-qualified URI.
* @param value The requested value for the property.
* @exception SAXNotRecognizedException When the
* XMLReader does not recognize the property name.
* @exception SAXNotSupportedException When the
* XMLReader recognizes the property name but
* cannot set the requested value.
*/
template<typename propertyTypeT>
void setProperty(const string_type& name, propertyTypeT& value)
{
Property<propertyTypeT&>* prop = new Property<propertyTypeT&>(value);
doSetProperty(name, std::auto_ptr<PropertyBase>(prop));
} // setProperty
}; // class XMLReaderInterface
} // namespace SAX

View file

@ -31,13 +31,7 @@ namespace SAX
* {@link LexicalHandler#endDTD endDTD} events.</p>
*
* <p>To set the DeclHandler for an XML reader, use the
* {@link XMLReader#setProperty setProperty} method
* with the propertyId "http://xml.org/sax/properties/declaration-handler".
* If the reader does not support declaration events, it will throw a
* {@link SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p>
* {@link XMLReader#setDeclHandler setDeclHandler}.</P>
*
* @since 2.0
* @author Jez Higgins,

View file

@ -28,21 +28,13 @@ namespace SAX
* endDocument events.</p>
*
* <p>To set the LexicalHandler for an XML reader, use the
* {@link XMLReader#setProperty setProperty} method
* with the propertyId "http://xml.org/sax/properties/lexical-handler".
* If the reader does not support lexical events, it will throw a
* {@link SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p>
* {@link XMLReader#setLexicalHandler setLexicalHandler} method.</p>
*
* @since 2.0
* @author Jez Higgins,
* <a href="mailto:jez@jezuk.co.uk">jez@jezuk.co.uk</a>
* @version 1.0
* @see XMLReader#setProperty
* @see SAXNotRecognizedException
* @see SAXNotSupportedException
* @see XMLReader#setLexicalHandler
*/
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
class LexicalHandler

View file

@ -8,7 +8,6 @@
#include <SAX/ext/LexicalHandler.hpp>
#include <SAX/ext/DeclHandler.hpp>
#include <text/UnicodeCharacters.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <XML/escaper.hpp>
#include <Arabica/StringAdaptor.hpp>
#include <Arabica/getparam.hpp>
@ -42,7 +41,6 @@ class Writer : public XMLFilterImpl<string_type, string_adaptor>
typedef LexicalHandler<string_type, string_adaptor> LexicalHandlerT;
typedef DeclHandler<string_type, string_adaptor> DeclHandlerT;
typedef typename XMLReaderT::InputSourceT InputSourceT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
using XMLFilterT::getParent;
public:
@ -167,8 +165,6 @@ class Writer : public XMLFilterImpl<string_type, string_adaptor>
ostreamT* stream_;
string_type encoding_;
enum { startTag, endTag, docTag } lastTag_;
const SAX::PropertyNames<string_type> properties_;
}; // class Writer
template<class string_type, class string_adaptor>

View file

@ -1,53 +0,0 @@
#ifndef ARABICA_PROPERTY_NAMES_H
#define ARABICA_PROPERTY_NAMES_H
/*
* $Id$
*/
#include <SAX/ArabicaConfig.hpp>
#include <SAX/XMLReader.hpp>
#include <Arabica/StringAdaptor.hpp>
namespace Arabica
{
namespace SAX
{
/** The core SAX 2 parser properties. */
template<class string_type, class string_adaptor_type = Arabica::default_string_adaptor<string_type> >
struct PropertyNames
{
/** @name SAX 2 Properties
* @{ */
/** Register a lexical handler.
*
* The Lexical Handler is used to see some syntax events that are essential
* in some applications: comments, CDATA delimiters, selected general
* entity inclusions, and the start and end of the DTD (and declaration of
* document element name).
*
* The value assigned must implement SAX::LexicalHandler.
*/
const string_type lexicalHandler;
/** Register a Declaration Handler.
*
* Used to see most DTD declarations except those treated as lexical
* ("document element name is ...") or which are mandatory for all SAX
* parsers (DTDHandler).
*
* The value assigned must implement SAX::DeclHandler */
const string_type declHandler;
/** @} */
PropertyNames() :
lexicalHandler(string_adaptor_type::construct_from_utf8("http://xml.org/sax/handlers/LexicalHandler")),
declHandler(string_adaptor_type::construct_from_utf8("http://xml.org/sax/handlers/DeclHandler"))
{
} // PropertyNames
}; // struct PropertyNames
} // namespace SAX
} // namespace Arabica
#endif
// end of file

View file

@ -223,29 +223,6 @@ public:
parent_->parse(input);
} // parse
virtual std::auto_ptr<typename XMLReaderT::PropertyBase> doGetProperty(const string_type& name)
{
if(parent_)
return parent_->doGetProperty(name);
string_type ex = string_adaptor::construct_from_utf8("Property: ");
string_adaptor::append(ex, name);
throw SAXNotRecognizedException(string_adaptor::asStdString(ex));
} // doGetProperty
virtual void doSetProperty(const string_type& name, typename std::auto_ptr<typename XMLReaderT::PropertyBase> value)
{
if(parent_)
{
parent_->doSetProperty(name, value);
return;
} // if(parent_)
string_type ex = string_adaptor::construct_from_utf8("Property: ");
string_adaptor::append(ex, name);
throw SAXNotRecognizedException(string_adaptor::asStdString(ex));
} // doSetProperty
public:
//////////////////////////////////////////////////
// EntityResolver

View file

@ -48,7 +48,6 @@ public:
typedef ErrorHandler<string_type, string_adaptor> ErrorHandlerT;
typedef DeclHandler<string_type, string_adaptor> declHandlerT;
typedef LexicalHandler<string_type, string_adaptor> lexicalHandlerT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
Garden();
@ -70,9 +69,6 @@ public:
virtual void parse(InputSourceT& input);
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value);
private:
void reportError(const std::string& message, bool fatal = false);
@ -256,20 +252,6 @@ void Garden<string_type, T0, T1>::setFeature(const string_type& name, bool value
throw SAXNotRecognizedException(string_adaptor::asStdString(name));
} // setFeature
///////////////////////////////////////
// properties
template<class string_type, class T0, class T1>
std::auto_ptr<typename Garden<string_type, T0, T1>::PropertyBaseT> Garden<string_type, T0, T1>::doGetProperty(const string_type& name)
{
throw SAXNotRecognizedException(string_adaptor::asStdString(name));
} // doGetProperty
template<class string_type, class T0, class T1>
void Garden<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value)
{
throw SAXNotRecognizedException(string_adaptor::asStdString(name));
} // doSetProperty
//////////////////////////////////////////
// parse
template<class string_type, class T0, class T1>

View file

@ -5,7 +5,6 @@
*/
#include <Arabica/StringAdaptor.hpp>
#include <SAX/helpers/PropertyNames.hpp>
namespace Arabica
{
@ -13,8 +12,7 @@ namespace SAX
{
template<class string_type,
class string_adaptor_type = Arabica::default_string_adaptor<string_type> >
struct XercesPropertyNames : public PropertyNames<string_type,
string_adaptor_type>
struct XercesPropertyNames
{
/** \name Xerces properties.
* @{ */

View file

@ -19,7 +19,6 @@
#include <SAX/helpers/NamespaceSupport.hpp>
#include <SAX/helpers/InputSourceResolver.hpp>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <Arabica/StringAdaptor.hpp>
#include <SAX/helpers/AttributeDefaults.hpp>
#include <typeinfo>
@ -226,11 +225,6 @@ class expat_wrapper :
typedef SAX::NamespaceSupport<string_type, string_adaptor> namespaceSupportT;
typedef SAX::ErrorHandler<string_type, string_adaptor> errorHandlerT;
typedef SAX::SAXParseException<string_type, string_adaptor> SAXParseExceptionT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
typedef typename XMLReaderT::template Property<lexicalHandlerT*> getLexicalHandlerT;
typedef typename XMLReaderT::template Property<lexicalHandlerT&> setLexicalHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT*> getDeclHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT&> setDeclHandlerT;
typedef XML::QualifiedName<string_type, string_adaptor> qualifiedNameT;
expat_wrapper();
@ -270,11 +264,6 @@ class expat_wrapper :
virtual size_t getLineNumber() const;
virtual size_t getColumnNumber() const;
///////////////////////////////////////////////////
// properties
protected:
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value);
private:
qualifiedNameT processName(const string_type& qName, bool isAttribute);
void reportError(const std::string& message, bool fatal = false);
@ -347,7 +336,6 @@ class expat_wrapper :
string_type emptyString_;
const SAX::FeatureNames<string_type, string_adaptor> features_;
const SAX::PropertyNames<string_type, string_adaptor> properties_;
const SAX::NamespaceConstants<string_type, string_adaptor> nsc_;
const SAX::AttributeDefaults<string_type, string_adaptor> attrDefaults_;
@ -520,52 +508,6 @@ bool expat_wrapper<string_type, T0, T1>::do_parse(inputSourceT& source, XML_Pars
return true;
} // do_parse
template<class string_type, class T0, class T1>
std::auto_ptr<typename expat_wrapper<string_type, T0, T1>::PropertyBaseT> expat_wrapper<string_type, T0, T1>::doGetProperty(const string_type& name)
{
if(name == properties_.lexicalHandler)
{
getLexicalHandlerT* prop = new getLexicalHandlerT(lexicalHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
if(name == properties_.declHandler)
{
getDeclHandlerT* prop = new getDeclHandlerT(declHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + SA::asStdString(name));
} // doGetProperty
template<class string_type, class T0, class T1>
void expat_wrapper<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value)
{
if(name == properties_.lexicalHandler)
{
setLexicalHandlerT* prop = dynamic_cast<setLexicalHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
lexicalHandler_ = &(prop->get());
}
else if(name == properties_.declHandler)
{
setDeclHandlerT* prop = dynamic_cast<setDeclHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
declHandler_ = &(prop->get());
}
else
{
std::ostringstream os;
os << "Property not recognized " << SA::asStdString(name);
throw SAX::SAXNotRecognizedException(os.str());
}
} // doSetProperty
// Locator implementation
template<class string_type, class T0, class T1>
string_type expat_wrapper<string_type, T0, T1>::getPublicId() const

View file

@ -17,7 +17,6 @@
#include <typeinfo>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <SAX/helpers/NamespaceSupport.hpp>
#include <SAX/helpers/AttributeDefaults.hpp>
#include <SAX/helpers/AttributeTypes.hpp>
@ -145,11 +144,6 @@ class libxml2_wrapper :
typedef SAX::NamespaceSupport<string_type, string_adaptor> namespaceSupportT;
typedef SAX::ErrorHandler<string_type, string_adaptor> errorHandlerT;
typedef SAX::SAXParseException<string_type, string_adaptor> SAXParseExceptionT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
typedef typename XMLReaderT::template Property<lexicalHandlerT*> getLexicalHandlerT;
typedef typename XMLReaderT::template Property<lexicalHandlerT&> setLexicalHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT*> getDeclHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT&> setDeclHandlerT;
typedef XML::QualifiedName<string_type, string_adaptor> qualifiedNameT;
libxml2_wrapper();
@ -179,12 +173,6 @@ class libxml2_wrapper :
// parsing
virtual void parse(inputSourceT& source);
protected:
////////////////////////////////////////////////
// properties
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value);
public:
virtual string_type getPublicId() const;
virtual string_type getSystemId() const;
@ -245,7 +233,6 @@ class libxml2_wrapper :
string_type emptyString_;
const FeatureNames<string_type, string_adaptor> features_;
const PropertyNames<string_type, string_adaptor> properties_;
const NamespaceConstants<string_type, string_adaptor> nsc_;
const AttributeDefaults<string_type, string_adaptor> attrDefaults_;
const AttributeTypes<string_type, string_adaptor> attrTypes_;
@ -354,48 +341,6 @@ void libxml2_wrapper<string_type, T0, T1>::setFeature(const string_type& name, b
}
} // setFeature
template<class string_type, class T0, class T1>
std::auto_ptr<typename libxml2_wrapper<string_type, T0, T1>::PropertyBaseT> libxml2_wrapper<string_type, T0, T1>::doGetProperty(const string_type& name)
{
if(name == properties_.declHandler)
{
getDeclHandlerT* prop = new getDeclHandlerT(declHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
if(name == properties_.lexicalHandler)
{
getLexicalHandlerT* prop = new getLexicalHandlerT(lexicalHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptor::asStdString(name));
} // doGetProperty
template<class string_type, class T0, class T1>
void libxml2_wrapper<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value)
{
if(name == properties_.declHandler)
{
setDeclHandlerT* prop = dynamic_cast<setDeclHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
declHandler_ = &(prop->get());
}
if(name == properties_.lexicalHandler)
{
setLexicalHandlerT* prop = dynamic_cast<setLexicalHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
lexicalHandler_ = &(prop->get());
}
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptor::asStdString(name));
} // doSetProperty
template<class string_type, class T0, class T1>
typename XML::QualifiedName<string_type, typename libxml2_wrapper<string_type, T0, T1>::string_adaptor> libxml2_wrapper<string_type, T0, T1>::processName(const string_type& qName, bool isAttribute)
{

View file

@ -10,7 +10,6 @@
#include <SAX/SAXParseException.hpp>
#include <SAX/SAXNotRecognizedException.hpp>
#include <SAX/SAXNotSupportedException.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <Arabica/StringAdaptor.hpp>
#include <iostream>
#include <Arabica/getparam.hpp>
@ -118,48 +117,7 @@ class msxml2_wrapper :
// Parsing
virtual void parse(inputSourceT& input);
protected:
virtual std::auto_ptr<typename XMLReaderT::PropertyBase> doGetProperty(const string_type& name)
{
if(name == properties_.lexicalHandler)
{
Property<lexicalHandlerT*>* prop = new Property<lexicalHandlerT*>(lexicalHandler_.getLexicalHandler());
return std::auto_ptr<XMLReaderT::PropertyBase>(prop);
}
if(name == properties_.declHandler)
{
Property<declHandlerT*>* prop = new Property<declHandlerT*>(declHandler_.getDeclHandler());
return std::auto_ptr<XMLReaderT::PropertyBase>(prop);
}
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doGetProperty
virtual void doSetProperty(const string_type& name, std::auto_ptr<typename XMLReaderT::PropertyBase> value)
{
if(name == properties_.lexicalHandler)
{
Property<lexicalHandlerT&>* prop = dynamic_cast<Property<lexicalHandlerT&>*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property LexicalHandler is wrong type, should be SAX::LexicalHandler&");
lexicalHandler_.setLexicalHandler(prop->get());
return;
} // if ...
if(name == properties_.declHandler)
{
Property<declHandlerT&>* prop = dynamic_cast<Property<declHandlerT&>*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property DeclHandler is wrong type, should be SAX::DeclHandler&");
declHandler_.setDeclHandler(prop->get());
return;
} // if ...
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doSetProperty
private:
private:
//////////////////////////////////////////////////////
// COM interface -> C++ interface adaptors
class LocatorAdaptor : public locatorT
@ -987,7 +945,6 @@ class msxml2_wrapper :
DeclHandlerAdaptor declHandler_;
ISAXXMLReaderPtr reader_;
SAX::PropertyNames<string_type, string_adaptor> properties_;
}; // class msxml
template<class string_type, class T0, class T1>
@ -998,8 +955,7 @@ msxml2_wrapper<string_type, T0, T1>::msxml2_wrapper() :
contentHandler_(errorHandler_),
lexicalHandler_(),
declHandler_(),
reader_(),
properties_()
reader_()
{
reader_.CreateInstance("Msxml2.SAXXMLReader.6.0");
if(reader_.GetInterfacePtr() == 0)

View file

@ -4,35 +4,6 @@
// A SAX2 wrapper class for Xerces.
//---------------------------------------------------------------------------
// Debugging code for the doSetProperty and doGetProperty methods.
// Since these methods use runtime casting, it is often helpful to
// know the exact type of a method's arguments to compare with
// what is expected. This is hard, even with current (2003)
// debuggers, so this code can print it out, assuming you've
// compiled with gcc 3.2
//
// Example usage is given in doSetProperty
// Use only with GCC 3.2
#ifdef SAXXERCES_DEBUG
#include <iostream>
#include <typeinfo>
#include <cxxabi.h>
// Demangle Run-Time Type Information std::type_info struct.
std::ostream& operator<<(std::ostream& o, const std::type_info& ti)
{
int status;
char *realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
if (status != 0)
o.setstate(std::ios_base::failbit);
o << realname;
free(realname);
return o;
}
#endif
#include <iterator>
#include <memory>
#include <string>
@ -189,10 +160,6 @@ class xerces_wrapper : public ProgressiveParser<string_type, typename Arabica::g
virtual void parseReset(XMLPScanToken& token);
//@}
protected:
virtual std::auto_ptr<typename XMLReaderT::PropertyBase> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<typename XMLReaderT::PropertyBase> value);
private:
///////////////////////////////
// String adaptor for XMLCh
@ -933,143 +900,6 @@ void xerces_wrapper<string_type, T0, T1>::setFeature(const string_type& name, bo
} // catch(SAXNotRecognizedException& e)
} // setFeature
template<class string_type, class T0, class T1>
std::auto_ptr<typename xerces_wrapper<string_type, T0, T1>::XMLReaderT::PropertyBase> xerces_wrapper<string_type, T0, T1>::doGetProperty(const string_type& name)
{
if(name == properties_.lexicalHandler)
{
typedef typename XMLReaderT::template Property<LexicalHandlerT *> Prop;
Prop *prop = new Prop(lexicalHandlerAdaptor_.getLexicalHandler());
return std::auto_ptr<typename XMLReaderT::PropertyBase>(prop);
}
if(name == properties_.declHandler)
{
typedef typename XMLReaderT::template Property<DeclHandlerT*> Prop;
Prop* prop = new Prop(declHandlerAdaptor_.getDeclHandler());
return std::auto_ptr<typename XMLReaderT::PropertyBase>(prop);
}
if (name == properties_.externalSchemaLocation)
{
typedef typename XMLReaderT::template Property<string_type&> StringPropertyType;
XMLCh* xercesExternalSchemaLocation =
static_cast<XMLCh*>(xerces_->getProperty(
XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalSchemaLocation));
externalSchemaLocation_ = XSA::makeStringT(xercesExternalSchemaLocation);
std::auto_ptr<typename XMLReaderT::PropertyBase> toReturn(new StringPropertyType(externalSchemaLocation_));
#ifdef SAXXERCES_DEBUG
std::cerr << "Returning " << typeid(toReturn)
<< "(*(" << typeid(*toReturn.get()) << ")"
<< toReturn.get() << ")"
<< " containing value [" << externalSchemaLocation_ << "]"
<< std::endl;
#endif
return toReturn;
}
if (name == properties_.externalNoNamespaceSchemaLocation)
{
typedef typename XMLReaderT::template Property<string_type&> StringPropertyType;
XMLCh* xercesExternalNoNamespaceSchemaLocation =
static_cast<XMLCh*>(xerces_->getProperty(
XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation));
externalNoNamespaceSchemaLocation_ = XSA::makeStringT(xercesExternalNoNamespaceSchemaLocation);
return std::auto_ptr<typename XMLReaderT::PropertyBase>(new StringPropertyType(externalNoNamespaceSchemaLocation_));
}
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doGetProperty
template<class string_type, class T0, class T1>
void xerces_wrapper<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<typename XMLReaderT::PropertyBase> value)
{
if(name == properties_.lexicalHandler)
{
typedef typename XMLReaderT::template Property<LexicalHandlerT&> Prop;
Prop* prop = dynamic_cast<Prop*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property LexicalHandler is wrong type, should be SAX::LexicalHandler&");
lexicalHandlerAdaptor_.setLexicalHandler(prop->get());
return;
} // if ...
if(name == properties_.declHandler)
{
typedef typename XMLReaderT::template Property<DeclHandlerT&> Prop;
Prop* prop = dynamic_cast<Prop*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property DeclHandler is wrong type, should be SAX::DeclHandler&");
declHandlerAdaptor_.setDeclHandler(prop->get());
return;
} // if ...
if (name == properties_.externalSchemaLocation)
{
typename XMLReaderT::PropertyBase* propBase = value.get();
#ifdef SAXXERCES_DEBUG
std::cerr << "doSetProperty(externalSchemaLocation, &("
<< typeid(*propBase) << "))" << std::endl;
#endif
typedef typename XMLReaderT::template Property<string_type&> propertyType;
propertyType* prop = dynamic_cast<propertyType*>(propBase);
#ifdef SAXXERCES_DEBUG
std::cerr << " Extracted property to " << typeid(prop)
<< "(" << prop << ")" << std::endl;
#endif
if (prop)
{
externalSchemaLocation_ = prop->get();
#ifdef SAXXERCES_DEBUG
std::cerr << " Setting property to " << externalSchemaLocation_ << std::endl;
#endif
xerces_string_janitor<XMLCh> toDelete(XSA::asXMLChString(externalSchemaLocation_));
xerces_->setProperty(XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(toDelete.get()));
}
else
{
throw SAXNotSupportedException("Property ExternalShemaLocation is wrong type, should be string_type");
}
return;
}
if (name == properties_.externalNoNamespaceSchemaLocation)
{
typename XMLReaderT::PropertyBase* propBase = value.get();
typedef typename XMLReaderT::template Property<string_type&> propertyType;
#ifdef SAXXERCES_DEBUG
std::cerr << "doSetProperty(externalNoNamespaceSchemaLocation, &("
<< typeid(*propBase) << "))" << std::endl;
#endif
propertyType* prop = dynamic_cast<propertyType*>(propBase);
#ifdef SAXXERCES_DEBUG
std::cerr << " Extracted property to " << typeid(prop)
<< "(" << prop << ")" << std::endl;
#endif
if (prop)
{
externalNoNamespaceSchemaLocation_ = prop->get();
#ifdef SAXXERCES_DEBUG
std::cerr << " Setting property to " << externalNoNamespaceSchemaLocation_ << std::endl;
#endif
xerces_string_janitor<XMLCh> toDelete(XSA::asXMLChString(externalNoNamespaceSchemaLocation_));
xerces_->setProperty(XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, const_cast<XMLCh*>(toDelete.get()));
}
else
{
throw SAXNotSupportedException("Property ExternalNoNamespaceSchemaLocation is wrong type, should be string_type");
}
return;
}
throw SAX::SAXNotRecognizedException("Property not recognized ");
}
template<class string_type, class T0, class T1>
void xerces_wrapper<string_type, T0, T1>::parse(InputSourceT& source)
{

View file

@ -396,89 +396,6 @@ public:
CDATAElements = value;
} // setFeature
typedef typename XMLReaderInterface<string_type, string_adaptor_type>::PropertyBase PropertyBaseT;
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& /*name*/)
{
return std::auto_ptr<PropertyBaseT>(0);
} // doGetProperty
virtual void doSetProperty(const string_type& /*name*/, std::auto_ptr<PropertyBaseT> /*value*/)
{
} // doSetProperty
/*
Object getProperty (std::string name)
{
if(name.equals(lexicalHandlerProperty))
{
return lexicalHandler_ == this ? null : lexicalHandler_;
}
else if(name.equals(scannerProperty))
{
return scanner_;
}
else if(name.equals(schemaProperty))
{
return schema_;
}
else if(name.equals(autoDetectorProperty))
{
return theAutoDetector;
}
else
{
throw new SAXNotRecognizedException("Unknown property " + name);
}
} // getProperty
void setProperty (std::string name, Object value)
{
if(name.equals(lexicalHandlerProperty))
{
if(value == null)
{
lexicalHandler_ = this;
}
else if(value instanceof LexicalHandler)
{
lexicalHandler_ = (LexicalHandler)value;
}
else
{
throw new SAXNotSupportedException("Your lexical handler is not a LexicalHandler");
}
}
else if(name.equals(scannerProperty))
{
if(value instanceof Scanner) {
scanner_ = (Scanner)value;
}
else {
throw new SAXNotSupportedException("Your scanner is not a Scanner");
}
}
else if(name.equals(schemaProperty)) {
if(value instanceof Schema) {
schema_ = (Schema)value;
}
else {
throw new SAXNotSupportedException("Your schema is not a Schema");
}
}
else if(name.equals(autoDetectorProperty)) {
if(value instanceof AutoDetector) {
theAutoDetector = (AutoDetector)value;
}
else {
throw new SAXNotSupportedException("Your auto-detector is not an AutoDetector");
}
}
else {
throw new SAXNotRecognizedException("Unknown property " + name);
}
}
*/
virtual void setEntityResolver(EntityResolverT& resolver)
{
entityResolver_ = &resolver;

View file

@ -151,7 +151,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />

View file

@ -153,7 +153,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />

View file

@ -154,7 +154,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />

View file

@ -154,7 +154,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />

View file

@ -354,10 +354,6 @@
RelativePath="..\include\Sax\helpers\NamespaceSupport.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\PropertyNames.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\XMLBaseSupport.hpp"
>

View file

@ -354,10 +354,6 @@
RelativePath="..\include\Sax\helpers\NamespaceSupport.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\PropertyNames.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\XMLBaseSupport.hpp"
>