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