Index: DBSAXHandler.java
===================================================================
--- DBSAXHandler.java	(revision 17)
+++ DBSAXHandler.java	(revision 18)
@@ -13,6 +13,7 @@
 
 import java.sql.*;
 import java.util.Stack;
+import java.util.EmptyStackException;
 
 // Extensions to the SAX Interfaces for Namespace support.
 import oracle.xml.parser.v2.DefaultXMLDocumentHandler;
@@ -31,8 +32,6 @@
 
    public DBSAXHandler(Connection conn)
    {
-      System.out.println("\nINITIALIZING HANDLER....\n");
-
       this.conn = conn;
 
       // Create the stack for keeping track of element context
@@ -55,6 +54,7 @@
       String localName;
       String nsName;
       String expName;
+      DBSAXElement parentElement;
       DBSAXElement currentElement;
 
       qName = name.getQualifiedName();
@@ -62,8 +62,17 @@
       nsName = name.getNamespace();
       expName = name.getExpandedName();
       
+      // Get a reference to the parent element for the id
+      long parent_id;
+      try {
+        parentElement = (DBSAXElement)elementStack.peek();
+        parent_id = parentElement.getElementID();
+      } catch (EmptyStackException e) {
+        parent_id = 0;
+      }
+
       // Create the current element representation
-      currentElement = new DBSAXElement(conn, 1, localName, false, 0);
+      currentElement = new DBSAXElement(conn, localName, parent_id);
       System.out.println("Element created:" + currentElement.getTagName());
 
       // Add all of the attributes
@@ -91,7 +100,6 @@
          System.out.println("                 Type:" + type);
          System.out.println("                Value:" + value);
          System.out.println();
-
       }      
 
       // Add the element to the stack, so that any text data can be 
@@ -118,11 +126,13 @@
       // Use the methods getQualifiedName(), getLocalName(), getNamespace()
       // and getExpandedName() in NSName interface to get Namespace
       // information.
-
       String expName = name.getExpandedName();
 
-      // Remove the element from the stack
+      // Get the element from the stack
       DBSAXElement currentElement = (DBSAXElement)elementStack.pop();
+      
+      // Write the content of the element to the database
+      currentElement.writeContentToDB();
 
       System.out.println("Final content: " + currentElement.getContent());
       System.out.println("Closing element: " + expName);
Index: src/edu/ucsb/nceas/metacat/DBSAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 17)
+++ src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 18)
@@ -13,6 +13,7 @@
 
 import java.sql.*;
 import java.util.Stack;
+import java.util.EmptyStackException;
 
 // Extensions to the SAX Interfaces for Namespace support.
 import oracle.xml.parser.v2.DefaultXMLDocumentHandler;
@@ -31,8 +32,6 @@
 
    public DBSAXHandler(Connection conn)
    {
-      System.out.println("\nINITIALIZING HANDLER....\n");
-
       this.conn = conn;
 
       // Create the stack for keeping track of element context
@@ -55,6 +54,7 @@
       String localName;
       String nsName;
       String expName;
+      DBSAXElement parentElement;
       DBSAXElement currentElement;
 
       qName = name.getQualifiedName();
@@ -62,8 +62,17 @@
       nsName = name.getNamespace();
       expName = name.getExpandedName();
       
+      // Get a reference to the parent element for the id
+      long parent_id;
+      try {
+        parentElement = (DBSAXElement)elementStack.peek();
+        parent_id = parentElement.getElementID();
+      } catch (EmptyStackException e) {
+        parent_id = 0;
+      }
+
       // Create the current element representation
-      currentElement = new DBSAXElement(conn, 1, localName, false, 0);
+      currentElement = new DBSAXElement(conn, localName, parent_id);
       System.out.println("Element created:" + currentElement.getTagName());
 
       // Add all of the attributes
@@ -91,7 +100,6 @@
          System.out.println("                 Type:" + type);
          System.out.println("                Value:" + value);
          System.out.println();
-
       }      
 
       // Add the element to the stack, so that any text data can be 
@@ -118,11 +126,13 @@
       // Use the methods getQualifiedName(), getLocalName(), getNamespace()
       // and getExpandedName() in NSName interface to get Namespace
       // information.
-
       String expName = name.getExpandedName();
 
-      // Remove the element from the stack
+      // Get the element from the stack
       DBSAXElement currentElement = (DBSAXElement)elementStack.pop();
+      
+      // Write the content of the element to the database
+      currentElement.writeContentToDB();
 
       System.out.println("Final content: " + currentElement.getContent());
       System.out.println("Closing element: " + expName);
Index: src/edu/ucsb/nceas/metacat/DBSAXNode.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 17)
+++ src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 18)
@@ -20,24 +20,20 @@
     private long		element_id;
     private String		tagname;
     private StringBuffer	content;
-    private boolean		isEmpty;
     private long		parent_id;
     private Hashtable		attributes;
     private Connection		conn;
 
-    public DBSAXElement (Connection conn, long element_id, String tagname, 
-                         boolean isEmpty, long parent_id) {
+    public DBSAXElement (Connection conn, String tagname, 
+                         long parent_id) {
       this.conn = conn;
       this.element_id = assignElementID();
 
       this.tagname = tagname;
-      this.isEmpty = isEmpty;
       this.parent_id = parent_id;
       content = new StringBuffer();
       attributes = new Hashtable(); 
       writeElementToDB();
-
-      System.out.println("******ELEMENT_ID: " + this.element_id);
     };
     
     private long assignElementID() {
@@ -111,6 +107,9 @@
 	return value.toString ();
     }
 
+    /** Get the id of this element */
+    public long  getElementID() { return element_id; }
+
     /** Get the name of this element */
     public String  getTagName() { return tagname; }
 
@@ -157,4 +156,24 @@
     public String getContent() {
       return this.content.toString();
     }
+
+    /** Write the element content to the db connection */
+    public void writeContentToDB() {
+        try {
+          PreparedStatement pstmt = conn.prepareStatement(
+                "UPDATE xml_elements SET nodedata = ? WHERE nodeid = ?");
+
+          // Bind the values to the query
+          pstmt.setString(1, getContent());// The first ? is for NODEDATA
+          pstmt.setLong(2, element_id); // The second ? is for NODEID
+
+          // Do the update
+          pstmt.execute();
+          pstmt.close();
+
+        } catch (SQLException e) {
+          System.out.println(e.getMessage());
+        }
+    }
+
 }
Index: src/edu/ucsb/nceas/metacat/DBSAXElement.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXElement.java	(revision 17)
+++ src/edu/ucsb/nceas/metacat/DBSAXElement.java	(revision 18)
@@ -20,24 +20,20 @@
     private long		element_id;
     private String		tagname;
     private StringBuffer	content;
-    private boolean		isEmpty;
     private long		parent_id;
     private Hashtable		attributes;
     private Connection		conn;
 
-    public DBSAXElement (Connection conn, long element_id, String tagname, 
-                         boolean isEmpty, long parent_id) {
+    public DBSAXElement (Connection conn, String tagname, 
+                         long parent_id) {
       this.conn = conn;
       this.element_id = assignElementID();
 
       this.tagname = tagname;
-      this.isEmpty = isEmpty;
       this.parent_id = parent_id;
       content = new StringBuffer();
       attributes = new Hashtable(); 
       writeElementToDB();
-
-      System.out.println("******ELEMENT_ID: " + this.element_id);
     };
     
     private long assignElementID() {
@@ -111,6 +107,9 @@
 	return value.toString ();
     }
 
+    /** Get the id of this element */
+    public long  getElementID() { return element_id; }
+
     /** Get the name of this element */
     public String  getTagName() { return tagname; }
 
@@ -157,4 +156,24 @@
     public String getContent() {
       return this.content.toString();
     }
+
+    /** Write the element content to the db connection */
+    public void writeContentToDB() {
+        try {
+          PreparedStatement pstmt = conn.prepareStatement(
+                "UPDATE xml_elements SET nodedata = ? WHERE nodeid = ?");
+
+          // Bind the values to the query
+          pstmt.setString(1, getContent());// The first ? is for NODEDATA
+          pstmt.setLong(2, element_id); // The second ? is for NODEID
+
+          // Do the update
+          pstmt.execute();
+          pstmt.close();
+
+        } catch (SQLException e) {
+          System.out.println(e.getMessage());
+        }
+    }
+
 }
Index: DBSAXElement.java
===================================================================
--- DBSAXElement.java	(revision 17)
+++ DBSAXElement.java	(revision 18)
@@ -20,24 +20,20 @@
     private long		element_id;
     private String		tagname;
     private StringBuffer	content;
-    private boolean		isEmpty;
     private long		parent_id;
     private Hashtable		attributes;
     private Connection		conn;
 
-    public DBSAXElement (Connection conn, long element_id, String tagname, 
-                         boolean isEmpty, long parent_id) {
+    public DBSAXElement (Connection conn, String tagname, 
+                         long parent_id) {
       this.conn = conn;
       this.element_id = assignElementID();
 
       this.tagname = tagname;
-      this.isEmpty = isEmpty;
       this.parent_id = parent_id;
       content = new StringBuffer();
       attributes = new Hashtable(); 
       writeElementToDB();
-
-      System.out.println("******ELEMENT_ID: " + this.element_id);
     };
     
     private long assignElementID() {
@@ -111,6 +107,9 @@
 	return value.toString ();
     }
 
+    /** Get the id of this element */
+    public long  getElementID() { return element_id; }
+
     /** Get the name of this element */
     public String  getTagName() { return tagname; }
 
@@ -157,4 +156,24 @@
     public String getContent() {
       return this.content.toString();
     }
+
+    /** Write the element content to the db connection */
+    public void writeContentToDB() {
+        try {
+          PreparedStatement pstmt = conn.prepareStatement(
+                "UPDATE xml_elements SET nodedata = ? WHERE nodeid = ?");
+
+          // Bind the values to the query
+          pstmt.setString(1, getContent());// The first ? is for NODEDATA
+          pstmt.setLong(2, element_id); // The second ? is for NODEID
+
+          // Do the update
+          pstmt.execute();
+          pstmt.close();
+
+        } catch (SQLException e) {
+          System.out.println(e.getMessage());
+        }
+    }
+
 }
