cherry pick from local- branch
[SXSI/xpathcomp.git] / XMLDocShredder.h
1 /**************************************
2  * XMLDocShredder.h
3  * --------------------
4  * Header file for the shredder routine that invokes the XML parser and 
5  * calls the appropriate construction methods of the storage interface in
6  * correspondence with received parsing events.
7  * 
8  * Author: Greg Leighton
9  * Date: 02/11/08
10  */
11
12 #ifndef XMLDOCSHREDDER_H_
13 #define XMLDOCSHREDDER_H_
14
15 #include <libxml++/libxml++.h>
16 #include <libxml++/parsers/textreader.h>
17 #include <string>
18 #include "XMLTree.h"
19 #include "XMLTreeBuilder.h"
20
21 using namespace std;
22 using namespace xmlpp;
23
24
25 class XMLDocShredder
26 {
27   void doText();
28 public:
29   XMLDocShredder(const string inFileName,int sf, bool iet, bool dtc);
30   XMLDocShredder(const unsigned char * data, TextReader::size_type size,int sf, bool iet, bool dtc);
31   virtual ~XMLDocShredder();
32   virtual void processStartElement();
33   virtual void processEndElement();
34   virtual void processPCDATA();
35   virtual void processAttributes();
36   virtual void processSignificantWhitespace();
37   virtual void processStartDocument(const string docName);
38   virtual void processEndDocument();
39   virtual void processComment();
40   virtual void processProcessingInstruction();
41   virtual void processDocTypeDeclaration();
42   virtual void processUnknownNodeType();
43   virtual void processCDATASection();
44   virtual void parse();
45   
46   XMLTree * getXMLTree(){
47     return tree;
48   }
49
50         
51  private:
52   XMLTreeBuilder * tb;
53   XMLTree * tree;
54   TextReader *reader_;
55   void setProperties();
56   bool last_text;
57   string buffer; 
58   // used to coalece successive text events
59   // which can occur if we discard pi and comment nodes.
60 };
61
62 #endif /*XMLDOCSHREDDER_H_*/