Commit before changing Tree.ml interface
[SXSI/xpathcomp.git] / XMLDocShredder.cpp
index c048d2e..1516c9f 100644 (file)
@@ -88,9 +88,6 @@ void XMLDocShredder::processStartElement()
        ustring name = reader_->get_name();
        bool empty = false;
        
-       storageIfc_->newText(buffer); //prevText
-       buffer.erase();
-       
        storageIfc_->newChild(name);
 
        /* We must be really carefull here. calling process attributes moves
@@ -108,8 +105,7 @@ void XMLDocShredder::processStartElement()
 
        
        if (empty){
-           storageIfc_->newText("");  //myText
-           storageIfc_->nodeFinished(name);       
+         storageIfc_->nodeFinished(name);         
        };
 
 
@@ -117,21 +113,19 @@ void XMLDocShredder::processStartElement()
 
 void XMLDocShredder::processEndElement()
 {
-  // tell the storage interface that the current node has been completely processed
-  storageIfc_->newText(buffer); //prevText
-  buffer.erase();
+  // tell the storage interface that the current node has been completely processed  
   storageIfc_->nodeFinished(reader_->get_name());
 }
 
 void XMLDocShredder::processPCDATA()
 {
-       // send the content of this PCDATA node to the storage interface as a text node
-         
-       if (reader_->has_value())
-       {
-         buffer += reader_->get_value();
-       };
-
+  // send the content of this PCDATA node to the storage interface as a text node
+  
+  if (reader_->has_value()){
+    storageIfc_->newChild("<$>");
+    storageIfc_->newText(reader_->get_value());
+    storageIfc_->nodeFinished("<$>");
+  };
 }
 
 void XMLDocShredder::processAttributes()
@@ -139,7 +133,6 @@ void XMLDocShredder::processAttributes()
        reader_->move_to_first_attribute();
                
        string nspaceStr = "xmlns";
-       storageIfc_->newText(""); //prevText
        storageIfc_->newChild("<@>");
        do
        {
@@ -163,22 +156,26 @@ void XMLDocShredder::processAttributes()
                 
                else
                {
-                 storageIfc_->newText(""); //prevText
-                 storageIfc_->newChild(name);
+                 string attname = "<@>"+name;
+                 storageIfc_->newChild(attname);
+                 storageIfc_->newChild("<@$>");
                  storageIfc_->newText(value);
-                 storageIfc_->nodeFinished(name);
+                 storageIfc_->nodeFinished("<@$>");
+                 storageIfc_->nodeFinished(attname);
                }
        }
        while (reader_->move_to_next_attribute());
-       storageIfc_->newText(""); //nextText
        storageIfc_->nodeFinished("<@>");
 }
 
 void XMLDocShredder::processSignificantWhitespace()
 {
-  // each significant whitespace sequence constructs a text node
-  buffer += reader_->get_value();      
-       
+  
+  if (reader_->has_value()){
+    storageIfc_->newChild("<$>");
+    storageIfc_->newText(reader_->get_value());
+    storageIfc_->nodeFinished("<$>");
+  };  
 }
 
 void XMLDocShredder::processStartDocument(const string docName)
@@ -192,7 +189,6 @@ void XMLDocShredder::processEndDocument()
 {
        /* tell the storage interface that document parsing has finished, and structures
         * can now be written to disk. */
-  storageIfc_->newText("");
   storageIfc_->nodeFinished("");
   storageIfc_->parsingFinished();      
 }
@@ -231,10 +227,11 @@ void XMLDocShredder::processCDATASection()
         * model.  Instead, we simply pass the converted text value to the storage interface as 
         * a text node attached to the current context node.
         */
-  
-       ustring value = reader_->get_value();
-       storageIfc_->newText(value);
-       last_text = true;
+  if (reader_->has_value()){
+    storageIfc_->newChild("<$>");
+    storageIfc_->newText(reader_->get_value());
+    storageIfc_->nodeFinished("<$>");
+  };
 
 }