Change queries according to Niko
[SXSI/xpathcomp.git] / src / 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                  TextCollectionBuilder::index_type_t index_type
31                  );
32   XMLDocShredder(const unsigned char * data,
33                  TextReader::size_type size,
34                  int sf, bool iet, bool dtc,
35                  TextCollectionBuilder::index_type_t index_type
36                  );
37   virtual ~XMLDocShredder();
38   virtual void processStartElement();
39   virtual void processEndElement();
40   virtual void processPCDATA();
41   virtual void processAttributes();
42   virtual void processSignificantWhitespace();
43   virtual void processStartDocument(const string docName);
44   virtual void processEndDocument();
45   virtual void processComment();
46   virtual void processProcessingInstruction();
47   virtual void processDocTypeDeclaration();
48   virtual void processUnknownNodeType();
49   virtual void processCDATASection();
50   virtual void parse();
51   
52   XMLTree * getXMLTree(){
53     return tree;
54   }
55
56         
57  private:
58   XMLTreeBuilder * tb;
59   XMLTree * tree;
60   TextReader *reader_;
61   void setProperties();
62   bool last_text;
63   string buffer; 
64   // used to coalece successive text events
65   // which can occur if we discard pi and comment nodes.
66 };
67
68 #endif /*XMLDOCSHREDDER_H_*/