00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_XML_HANDLERS_BASE_HH
00019 # define VCSN_XML_HANDLERS_BASE_HH
00020
00031 # include <map>
00032 # include <string>
00033
00034 # include <xercesc/sax2/SAX2XMLReader.hpp>
00035 # include <xercesc/sax2/XMLReaderFactory.hpp>
00036 # include <xercesc/sax2/DefaultHandler.hpp>
00037 # include <xercesc/sax2/Attributes.hpp>
00038
00039 # include <xercesc/sax/SAXException.hpp>
00040 # include <xercesc/util/XMLString.hpp>
00041
00042 # include <vaucanson/xml/xmleq.hh>
00043 # include <vaucanson/xml/strings.hh>
00044
00045 namespace vcsn
00046 {
00047 namespace xml
00048 {
00049
00050
00051
00052 class ErrHandler : public xercesc::DefaultHandler
00053 {
00054 public:
00055 ErrHandler () : DefaultHandler() {}
00056
00057 void
00058 warning (const xercesc::SAXParseException& exc);
00059
00060 void
00061 error (const xercesc::SAXParseException& exc);
00062
00063 void
00064 fatalError (const xercesc::SAXParseException& exc);
00065
00066 void
00067 resetErrors () {}
00068
00069 };
00070
00071 namespace error
00072 {
00073 void token(const XMLCh* const localname);
00074 void attrs(const XMLCh* const localname,
00075 const std::string& name,
00076 const std::string& value);
00077 void missattrs(const XMLCh* const localname,
00078 const std::string& name);
00079 }
00080
00081
00082
00083 class Handler : public xercesc::DefaultHandler
00084 {
00085 public:
00086 Handler (xercesc::SAX2XMLReader* parser,
00087 Handler& root);
00088 Handler (xercesc::SAX2XMLReader* parser,
00089 xercesc::DefaultHandler& root,
00090 XMLEq& eq);
00091
00092 void
00093 startElement (const XMLCh* const uri,
00094 const XMLCh* const localname,
00095 const XMLCh* const qname,
00096 const xercesc::Attributes& attrs);
00097 void
00098 endElement (const XMLCh* const uri,
00099 const XMLCh* const localname,
00100 const XMLCh* const qname);
00101
00102 virtual void
00103 start (const XMLCh* const uri,
00104 const XMLCh* const localname,
00105 const XMLCh* const qname,
00106 const xercesc::Attributes& attrs) = 0;
00107 virtual void
00108 end (const XMLCh* const uri,
00109 const XMLCh* const localname,
00110 const XMLCh* const qname) = 0;
00111
00112 XMLEq& eq() { return eq_; };
00113 # ifdef DEBUG
00114 static int indent_;
00115 # endif
00116 protected:
00117
00118 xercesc::SAX2XMLReader* parser_;
00119 xercesc::DefaultHandler& root_;
00120
00121 XMLEq& eq_;
00122 };
00123 # ifdef DEBUG
00124 int Handler::indent_ = 0;
00125 # endif
00126
00131 class UnsupHandler : public Handler
00132 {
00133 public:
00134 UnsupHandler(xercesc::SAX2XMLReader* parser,
00135 Handler& root);
00136
00137 void
00138 start (const XMLCh* const uri,
00139 const XMLCh* const localname,
00140 const XMLCh* const qname,
00141 const xercesc::Attributes& attrs);
00142 void
00143 end (const XMLCh* const uri,
00144 const XMLCh* const localname,
00145 const XMLCh* const qname);
00146 private:
00147 int depth_;
00148 };
00149 }
00150 }
00151
00152 # if ! defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00153 # include <vaucanson/xml/handlers_base.hxx>
00154 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
00155
00156 #endif // !VCSN_XML_HANDLERS_BASE_HH