1 | #include <xercesc/sax2/DefaultHandler.hpp> |
---|
2 | #include <xercesc/framework/XMLFormatter.hpp> |
---|
3 | |
---|
4 | XERCES_GLIBCXX_NAMESPACE_USE |
---|
5 | |
---|
6 | class MySAXHandler : public DefaultHandler, private XMLFormatTarget { |
---|
7 | private: |
---|
8 | XMLFormatter fFormatter; |
---|
9 | const char *outFileName; |
---|
10 | ofstream &out; |
---|
11 | |
---|
12 | public: |
---|
13 | char *buffer; |
---|
14 | MySAXHandler(const char* const encodingName, const XMLFormatter::UnRepFlags unRepFlags, ofstream &outFile); |
---|
15 | ~MySAXHandler() OVERRIDE; |
---|
16 | |
---|
17 | // Implementations of the format target interface |
---|
18 | // ----------------------------------------------------------------------- |
---|
19 | void writeChars(const XMLByte* const toWrite ); |
---|
20 | |
---|
21 | void writeChars(const XMLByte* const toWrite, const unsigned int count, |
---|
22 | XMLFormatter* const formatter); |
---|
23 | |
---|
24 | |
---|
25 | // Implementations of the SAX DocumentHandler interface |
---|
26 | //-------------------------------------------------------------------------------- |
---|
27 | void startDocument(); |
---|
28 | void endDocument(); |
---|
29 | |
---|
30 | void startElement(const XMLCh* const uri, const XMLCh* const localname, |
---|
31 | const XMLCh* const qname, const Attributes& attributes); |
---|
32 | void endElement (const XMLCh* const uri, const XMLCh* const localname, |
---|
33 | const XMLCh* const qname); |
---|
34 | |
---|
35 | void characters (const XMLCh* const chars, const unsigned int length); |
---|
36 | void ignorableWhitespace (const XMLCh* const chars, const unsigned int length ); |
---|
37 | void processingInstruction (const XMLCh* const target, const XMLCh* const data ); |
---|
38 | |
---|
39 | // Implementations of the SAX ErrorHandler interface |
---|
40 | //-------------------------------------------------------------------------------- |
---|
41 | void warning (const SAXParseException& exception); |
---|
42 | void error (const SAXParseException& exception); |
---|
43 | void fatalError (const SAXParseException& exception); |
---|
44 | }; |
---|