Index: src/edu/ucsb/nceas/metacat/DBSAXDocument.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXDocument.java	(revision 395)
+++ src/edu/ucsb/nceas/metacat/DBSAXDocument.java	(nonexistent)
@@ -1,321 +0,0 @@
-/**
- *  '$RCSfile$'
- *    Purpose: A Class that writes an XML document main data
- *  Copyright: 2000 Regents of the University of California and the
- *             National Center for Ecological Analysis and Synthesis
- *    Authors: Jivka Bojilova, Matt Jones
- *    Release: @release@
- *
- *   '$Author$'
- *     '$Date$'
- * '$Revision$'
- */
-
-package edu.ucsb.nceas.metacat;
-
-import java.sql.*;
-import java.io.IOException;
-import java.util.Hashtable;
-import java.util.Enumeration;
-
-/** 
- * A Class that writes an XML document main data to a database connection
- */
-public class DBSAXDocument {
-
-    private Connection      conn;
-    private long            rootnodeid;
-    private String          docname;
-    private String          doctype;
-    private String          doctitle;
-    private String          docid;
-
-    /** 
-     * Construct a new document instance
-     *
-     * @param conn the JDBC Connection to which all information is written
-     * @param rootnodeid - sequence id of the root node in the document
-     * @param docname - the name of DTD, i.e. the name immediately following 
-     *        the DOCTYPE keyword ( should be the root element name ) or
-     *        the root element name if no DOCTYPE declaration provided
-     *        (Oracle's and IBM parsers are not aware if it is not the 
-     *        root element name)
-     * @param doctype - Public ID of the DTD, i.e. the name immediately 
-     *                  following the PUBLIC keyword in DOCTYPE declaration or
-     *                  the docname if no Public ID provided or
-     *                  null if no DOCTYPE declaration provided
-     *
-     */
-    public DBSAXDocument (Connection conn, long rootnodeid, String docname, 
-                          String doctype, String docid, String action)
-                          throws AccessionNumberException {
-      this.conn = conn;
-      this.rootnodeid = rootnodeid;
-      this.docname = docname;
-      this.doctype = doctype;
-      this.docid = docid;
-      writeDocumentToDB(action);
-    }
-    
-    /** 
-     * Construct a new document instance, used for deleting documents
-     *
-     * @param conn the JDBC Connection to which all information is written
-     */
-    public DBSAXDocument (Connection conn) {
-      this.conn = conn;
-    }
-
-    /** creates SQL code and inserts new document into DB connection */
-    private void writeDocumentToDB(String action) 
-                          throws AccessionNumberException {
-        try {
-          PreparedStatement pstmt = null;
-
-          if (action.equals("INSERT")) {
-            this.docid = AccessionNumber.generate(docid, "INSERT");
-            pstmt = conn.prepareStatement(
-                "INSERT INTO xml_documents " +
-                "(docid, rootnodeid, docname, doctype, " +
-                "date_created, date_updated) " +
-                "VALUES (?, ?, ?, ?, sysdate, sysdate)");
-            // Bind the values to the query
-            pstmt.setString(1, this.docid);
-            pstmt.setLong(2, rootnodeid);
-            pstmt.setString(3, docname);
-            pstmt.setString(4, doctype);
-          } else if (action.equals("UPDATE")) {
-
-            // Determine if the docid is OK for an UPDATE
-            this.docid = AccessionNumber.generate(docid, "UPDATE");
-
-            // Save the old document entry in a backup table
-            saveDocument(docid);
-
-            // Update the new document to reflect the new node tree
-            pstmt = conn.prepareStatement(
-                "UPDATE xml_documents " +
-                "SET rootnodeid = ?, docname = ?, doctype = ?, " +
-                "date_updated = sysdate WHERE docid LIKE ?");
-            // Bind the values to the query
-            pstmt.setLong(1, rootnodeid);
-            pstmt.setString(2, docname);
-            pstmt.setString(3, doctype);
-            pstmt.setString(4, this.docid);
-          } else {
-            System.err.println("Action not supported: " + action);
-          }
-
-          // Do the insertion
-          pstmt.execute();
-          pstmt.close();
-
-        } catch (SQLException e) {
-          System.out.println(e.getMessage());
-        } catch (AccessionNumberException ane) {
-          MetaCatUtil.debugMessage("Invalid accession number.");
-          MetaCatUtil.debugMessage(ane.getMessage());
-          throw ane;
-        } catch (Exception e) {
-          System.out.println(e.getMessage());
-        }
-    }
-
-    /** Get doctype */
-    public String getDoctype() {
-      return doctype;
-    }
-
-    /** Get doc id */
-    public String getDocID() {
-      return docid;
-    }
-
-    /** Get root node id */
-    public long getRootNodeID() {
-      return rootnodeid;
-    }
-
-    /**
-     * Get the document title
-     */
-    public String getTitle() {
-      return doctitle;
-    }
-
-    /**
-     * Set the document title
-     *
-     * @param title the new title for the document
-     */
-    public void setTitle( String title ) {
-      this.doctitle = title;
-      try {
-        PreparedStatement pstmt;
-        pstmt = conn.prepareStatement(
-              "UPDATE xml_documents " +
-              " SET doctitle = ? " +
-              "WHERE docid = ?");
-
-        // Bind the values to the query
-        pstmt.setString(1, doctitle);
-        pstmt.setString(2, docid);
-
-        // Do the insertion
-        pstmt.execute();
-        pstmt.close();
-      } catch (SQLException e) {
-        System.out.println(e.getMessage());
-      }
-    }
-
-    /**
-     * Look up the title of the first child element named "title"
-     * and record it as the document title
-     */
-    public void setTitleFromChildElement() {
-        String title = null;
-        long assigned_id=0;
-        PreparedStatement pstmt;
-        try {
-          pstmt = conn.prepareStatement(
-                  "SELECT nodedata FROM xml_nodes " +
-                  "WHERE nodetype = 'TEXT' " +
-                  "AND rootnodeid = ? " +
-                  "AND parentnodeid IN " +
-                  "  (SELECT nodeid FROM xml_nodes " +
-                  "  WHERE nodename = 'title' " +
-                  "  AND nodetype =  'ELEMENT' " +
-                  "  AND rootnodeid = ? ) " +
-                  "ORDER BY nodeid");
-
-          // The above query might be slow, and probably will be because
-          // it gets ALL of the title elements while searching for one
-          // title in a small subtree but it avoids the problem of using
-          // Oracle's Hierarchical Query syntax which is not portable --
-          // the commented out SQL that follows shows an equivalent query
-          // using Oracle-specific hierarchical query
-/*
-          pstmt = conn.prepareStatement(
-                  "SELECT nodedata FROM xml_nodes " +
-                  "WHERE nodetype = 'TEXT' " +
-                  "AND parentnodeid IN " +
-                  "(SELECT nodeid FROM xml_nodes " +
-                  "WHERE nodename = 'title' " +
-                  "START WITH nodeid = ? " +
-                  "CONNECT BY PRIOR nodeid = parentnodeid)");
-*/
-
-          // Bind the values to the query
-          pstmt.setLong(1, rootnodeid);
-          pstmt.setLong(2, rootnodeid);
-
-          pstmt.execute();
-          ResultSet rs = pstmt.getResultSet();
-          boolean tableHasRows = rs.next();
-          if (tableHasRows) {
-            title = rs.getString(1);
-          }
-          pstmt.close();
-        } catch (SQLException e) {
-          System.out.println("Error getting id: " + e.getMessage());
-        }
-
-        // assign the new title
-        this.setTitle(title);
-    }
-
-  /** Save a document entry in the xml_revisions table */
-  public void saveDocument(String docid) throws SQLException {
-    // First get all of the values we need
-    long rnodeid = -1;
-    String docname = null;
-    String doctype = null;
-    String doctitle = null;
-    Date date_created = null;
-    PreparedStatement pstmt = conn.prepareStatement(
-       "SELECT rootnodeid, docname, doctype, doctitle, date_created " +
-       "FROM xml_documents " +
-       "WHERE docid = ?");
-    // Bind the values to the query and execute it
-    pstmt.setString(1, docid);
-    pstmt.execute();
-
-    ResultSet rs = pstmt.getResultSet();
-    boolean tableHasRows = rs.next();
-    if (tableHasRows) {
-      rnodeid      = rs.getLong(1);
-      docname      = rs.getString(2);
-      doctype      = rs.getString(3);
-      doctitle     = rs.getString(4);
-      date_created = rs.getDate(5);
-    }
-    pstmt.close();
-
-    MetaCatUtil.debugMessage(new Long(rnodeid).toString());
-    MetaCatUtil.debugMessage(docname);
-    MetaCatUtil.debugMessage(doctitle);
-    //MetaCatUtil.debugMessage(date_created.toString());
-
-    // Next create the new record in the other table using the values selected
-    pstmt = conn.prepareStatement(
-       "INSERT INTO xml_revisions " +
-       "(revisionid, docid, rootnodeid, docname, doctype, doctitle, " +
-       "date_created, date_updated) " +
-       "VALUES (null, ?, ?, ?, ?, ?, sysdate, sysdate)");
-    // Bind the values to the query and execute it
-    pstmt.setString(1, docid);
-    pstmt.setLong(2, rnodeid);
-    pstmt.setString(3, docname);
-    pstmt.setString(4, doctype);
-    pstmt.setString(5, doctitle);
-    //pstmt.setDate(6, date_created);
-    pstmt.execute();
-    pstmt.close();
-  }
-}
-
-/**
- * '$Log$
- * 'Revision 1.16  2000/08/03 23:15:11  bojilova
- * 'Added public method to return the rootnodeid of the document
- * '
- * 'Revision 1.15  2000/06/27 04:31:07  jones
- * 'Fixed bugs associated with the new UPDATE and DELETE functions of
- * 'DBWriter.  There were problematic interactions between some static
- * 'variables used in DBEntityResolver and the way in which the
- * 'Servlet objects are re-used across multiple client invocations.
- * '
- * 'Generally cleaned up error reporting.  Now all errors and success
- * 'results are reported as XML documents from MetaCatServlet.  Need
- * 'to make the command line tools do the same.
- * '
- * 'Revision 1.14  2000/06/26 10:35:05  jones
- * 'Merged in substantial changes to DBWriter and associated classes and to
- * 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE
- * 'functions.  The command line tools and the parameters for the
- * 'servlet have changed substantially.
- * '
- * 'Revision 1.13.2.8  2000/06/26 08:38:02  jones
- * 'Added DELETE feature to DBWriter.  Now takes an action "DELETE" and a
- * 'docid and will move the record from the xml_documents table to the
- * 'xml_revisions table.
- * 'Modified option parsing to support option symbols on command line.
- * '
- * 'Revision 1.13.2.7  2000/06/26 03:04:31  jones
- * 'Completed UPDATE function.  Included new table "xml_revisions" to store a
- * 'single document record for each revision to a document.  It is identical
- * 'to "xml_documents" with the addition of a "revisionid" column to
- * 'allow more than one revision per docid.
- * '
- * 'Revision 1.13.2.6  2000/06/26 02:02:20  jones
- * 'Continued fixing problems with exception handling that deals
- * 'with INSERT and UPDATE actions and the docid passed to DBWriter
- * '
- * 'Revision 1.13.2.5  2000/06/25 23:38:16  jones
- * 'Added RCSfile keyword
- * '
- * 'Revision 1.13.2.4  2000/06/25 23:34:17  jones
- * 'Changed documentation formatting, added log entries at bottom of source files
- * ''
- */

Property changes on: src/edu/ucsb/nceas/metacat/DBSAXDocument.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Author Date Id Revision
\ No newline at end of property
Index: src/edu/ucsb/nceas/metacat/DBSAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 395)
+++ src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 396)
@@ -40,7 +40,7 @@
    private boolean 	stackCreated = false;
    private Stack 	nodeStack;
    private Connection	conn = null;
-   private DBSAXDocument currentDocument;
+   private DocumentImpl currentDocument;
    private DBSAXNode    rootNode;
    private String       action = null;
    private String       docid = null;
@@ -132,7 +132,7 @@
        rootNode.writeNodename(docname);
        rootNode.writeRootNodeID(rootNode.getNodeID());
        try {
-         currentDocument = new DBSAXDocument(conn, rootNode.getNodeID(), 
+         currentDocument = new DocumentImpl(conn, rootNode.getNodeID(), 
                                            docname, doctype, docid, action);
          } catch (AccessionNumberException ane) {
            throw (new SAXException("Error with " + action, ane));
@@ -358,58 +358,3 @@
      return processingDTD;
    }
 }
-
-/**
- * '$Log$
- * 'Revision 1.32  2000/08/03 23:17:03  bojilova
- * 'Call to DBSAXNode constructor simplified
- * '
- * 'Revision 1.31  2000/06/29 23:27:08  jones
- * 'Fixed bug in DBEntityResolver so that it now properly delegates to
- * 'the system id found inthe database.
- * 'Changed DBValidate to use DBEntityResolver, rather than the OASIS
- * 'catalog, and to return validation results in XML format.
- * '
- * 'Revision 1.30  2000/06/28 03:14:35  jones
- * 'Fixed bug where TEXT nodes couldn't be longer than 4000 characters, which
- * 'is the maximum length of a VARCHAR2 field in Oracle.  Now, if text
- * 'exceeds the field length, I break the text up into a series of TEXT
- * 'nodes each of the max field length, and the remainder in the last
- * 'TEXT node. The only problem with this is that our current search
- * 'algorithms only will find phrases within a single TEXT nodes, so if
- * 'the search term spans the node boundary, the search algorithm will not
- * 'return a hit. I expect this is extremely rare, basically inconsequential.
- * '
- * 'Revision 1.29  2000/06/27 04:31:07  jones
- * 'Fixed bugs associated with the new UPDATE and DELETE functions of
- * 'DBWriter.  There were problematic interactions between some static
- * 'variables used in DBEntityResolver and the way in which the
- * 'Servlet objects are re-used across multiple client invocations.
- * '
- * 'Generally cleaned up error reporting.  Now all errors and success
- * 'results are reported as XML documents from MetaCatServlet.  Need
- * 'to make the command line tools do the same.
- * '
- * 'Revision 1.28  2000/06/26 10:35:05  jones
- * 'Merged in substantial changes to DBWriter and associated classes and to
- * 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE
- * 'functions.  The command line tools and the parameters for the
- * 'servlet have changed substantially.
- * '
- * 'Revision 1.27.2.6  2000/06/26 02:02:20  jones
- * 'Continued fixing problems with exception handling that deals
- * 'with INSERT and UPDATE actions and the docid passed to DBWriter
- * '
- * 'Revision 1.27.2.5  2000/06/26 00:51:06  jones
- * 'If docid passed to DBWriter.write() is not unique, classes now generate
- * 'an AccessionNumberException containing the new docid generated as a
- * 'replacement.  The docid is then extracted from the exception and
- * 'returned to the calling application for user feedback or client processing.
- * '
- * 'Revision 1.27.2.4  2000/06/25 23:38:16  jones
- * 'Added RCSfile keyword
- * '
- * 'Revision 1.27.2.3  2000/06/25 23:34:17  jones
- * 'Changed documentation formatting, added log entries at bottom of source files
- * ''
- */
Index: src/edu/ucsb/nceas/metacat/DocumentImpl.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 395)
+++ src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 396)
@@ -30,9 +30,11 @@
   private String system_id = null;
   private long rootnodeid;
   private ElementNode rootNode = null;
+  private String doctitle = null;
 
   /**
-   * Constructor, creates document from database connection
+   * Constructor, creates document from database connection, used 
+   * for reading the document
    *
    * @param conn the database connection from which to read the document
    * @param docid the identifier of the document to be created
@@ -47,7 +49,7 @@
       getDocumentInfo(docid);
       
       // Download all of the document nodes using a single SQL query
-      TreeSet nodeRecordList = getNodeRecordList(docid);
+      TreeSet nodeRecordList = getNodeRecordList(rootnodeid);
   
       // Create the elements from the downloaded data in the TreeSet
       rootNode = new ElementNode(nodeRecordList, rootnodeid);
@@ -59,6 +61,44 @@
     }
   }
 
+  /** 
+   * Construct a new document instance, writing the contents to the database
+   *
+   * @param conn the JDBC Connection to which all information is written
+   * @param rootnodeid - sequence id of the root node in the document
+   * @param docname - the name of DTD, i.e. the name immediately following 
+   *        the DOCTYPE keyword ( should be the root element name ) or
+   *        the root element name if no DOCTYPE declaration provided
+   *        (Oracle's and IBM parsers are not aware if it is not the 
+   *        root element name)
+   * @param doctype - Public ID of the DTD, i.e. the name immediately 
+   *                  following the PUBLIC keyword in DOCTYPE declaration or
+   *                  the docname if no Public ID provided or
+   *                  null if no DOCTYPE declaration provided
+   *
+   */
+  public DocumentImpl(Connection conn, long rootnodeid, String docname, 
+                      String doctype, String docid, String action)
+                      throws AccessionNumberException 
+  {
+    this.conn = conn;
+    this.rootnodeid = rootnodeid;
+    this.docname = docname;
+    this.doctype = doctype;
+    this.docid = docid;
+    writeDocumentToDB(action);
+  }
+    
+  /** 
+   * Construct a new document instance, used for deleting documents
+   *
+   * @param conn the JDBC Connection to which all information is written
+   */
+  public DocumentImpl (Connection conn) 
+  {
+    this.conn = conn;
+  }
+
   /**
    * get the document name
    */
@@ -87,6 +127,13 @@
     return rootnodeid;
   }
 
+  /** 
+   * Get the document identifier (docid)
+   */
+  public String getDocID() {
+    return docid;
+  }
+
   /**
    * Create an XML document from the database for the document with ID docid
    */
@@ -165,9 +212,9 @@
   /**
    * Look up the node data from the database
    *
-   * @param docid the id of the document to look up
+   * @param rootnodeid the id of the root node of the node tree to look up
    */
-  private TreeSet getNodeRecordList(String docid) throws McdbException 
+  private TreeSet getNodeRecordList(long rootnodeid) throws McdbException 
   {
     PreparedStatement pstmt;
     TreeSet nodeRecordList = new TreeSet(new NodeComparator());
@@ -187,10 +234,10 @@
            "replace(nodedata,'&','&amp;') " +
            ",'<','&lt;') " +
            ",'>','&gt;') " +
-           "FROM xml_nodes WHERE docid = ?");
+           "FROM xml_nodes WHERE rootnodeid = ?");
 
       // Bind the values to the query
-      pstmt.setString(1, docid);
+      pstmt.setLong(1, rootnodeid);
 
       pstmt.execute();
       ResultSet rs = pstmt.getResultSet();
@@ -248,7 +295,7 @@
           Connection dbconn = util.openDBConnection();
 
           DocumentImpl xmldoc = new DocumentImpl( dbconn, docid );
-          System.out.println(xmldoc);
+          System.out.println(xmldoc.toString());
 
         } catch (McdbException me) {
           me.toXml(new PrintWriter(System.err));
@@ -259,4 +306,201 @@
         }
      }
   }
+
+
+
+
+
+  /** creates SQL code and inserts new document into DB connection */
+  private void writeDocumentToDB(String action) 
+               throws AccessionNumberException {
+    try {
+      PreparedStatement pstmt = null;
+
+      if (action.equals("INSERT")) {
+        this.docid = AccessionNumber.generate(docid, "INSERT");
+        pstmt = conn.prepareStatement(
+            "INSERT INTO xml_documents " +
+            "(docid, rootnodeid, docname, doctype, " +
+            "date_created, date_updated) " +
+            "VALUES (?, ?, ?, ?, sysdate, sysdate)");
+        // Bind the values to the query
+        pstmt.setString(1, this.docid);
+        pstmt.setLong(2, rootnodeid);
+        pstmt.setString(3, docname);
+        pstmt.setString(4, doctype);
+      } else if (action.equals("UPDATE")) {
+
+        // Determine if the docid is OK for an UPDATE
+        this.docid = AccessionNumber.generate(docid, "UPDATE");
+
+        // Save the old document entry in a backup table
+        saveDocument(docid);
+
+        // Update the new document to reflect the new node tree
+        pstmt = conn.prepareStatement(
+            "UPDATE xml_documents " +
+            "SET rootnodeid = ?, docname = ?, doctype = ?, " +
+            "date_updated = sysdate WHERE docid LIKE ?");
+        // Bind the values to the query
+        pstmt.setLong(1, rootnodeid);
+        pstmt.setString(2, docname);
+        pstmt.setString(3, doctype);
+        pstmt.setString(4, this.docid);
+      } else {
+        System.err.println("Action not supported: " + action);
+      }
+
+      // Do the insertion
+      pstmt.execute();
+      pstmt.close();
+
+    } catch (SQLException e) {
+      System.out.println(e.getMessage());
+    } catch (AccessionNumberException ane) {
+      MetaCatUtil.debugMessage("Invalid accession number.");
+      MetaCatUtil.debugMessage(ane.getMessage());
+      throw ane;
+    } catch (Exception e) {
+      System.out.println(e.getMessage());
+    }
+  }
+
+  /**
+   * Get the document title
+   */
+  public String getTitle() {
+    return doctitle;
+  }
+
+  /**
+   * Set the document title
+   *
+   * @param title the new title for the document
+   */
+  public void setTitle( String title ) {
+    this.doctitle = title;
+    try {
+      PreparedStatement pstmt;
+      pstmt = conn.prepareStatement(
+            "UPDATE xml_documents " +
+            " SET doctitle = ? " +
+            "WHERE docid = ?");
+
+      // Bind the values to the query
+      pstmt.setString(1, doctitle);
+      pstmt.setString(2, docid);
+
+      // Do the insertion
+      pstmt.execute();
+      pstmt.close();
+    } catch (SQLException e) {
+      System.out.println(e.getMessage());
+    }
+  }
+
+  /**
+   * Look up the title of the first child element named "title"
+   * and record it as the document title
+   */
+  public void setTitleFromChildElement() {
+    String title = null;
+    long assigned_id=0;
+    PreparedStatement pstmt;
+    try {
+      pstmt = conn.prepareStatement(
+              "SELECT nodedata FROM xml_nodes " +
+              "WHERE nodetype = 'TEXT' " +
+              "AND rootnodeid = ? " +
+              "AND parentnodeid IN " +
+              "  (SELECT nodeid FROM xml_nodes " +
+              "  WHERE nodename = 'title' " +
+              "  AND nodetype =  'ELEMENT' " +
+              "  AND rootnodeid = ? ) " +
+              "ORDER BY nodeid");
+
+      // The above query might be slow, and probably will be because
+      // it gets ALL of the title elements while searching for one
+      // title in a small subtree but it avoids the problem of using
+      // Oracle's Hierarchical Query syntax which is not portable --
+      // the commented out SQL that follows shows an equivalent query
+      // using Oracle-specific hierarchical query
+      /*
+      pstmt = conn.prepareStatement(
+              "SELECT nodedata FROM xml_nodes " +
+              "WHERE nodetype = 'TEXT' " +
+              "AND parentnodeid IN " +
+              "(SELECT nodeid FROM xml_nodes " +
+              "WHERE nodename = 'title' " +
+              "START WITH nodeid = ? " +
+              "CONNECT BY PRIOR nodeid = parentnodeid)");
+      */
+
+      // Bind the values to the query
+      pstmt.setLong(1, rootnodeid);
+      pstmt.setLong(2, rootnodeid);
+
+      pstmt.execute();
+      ResultSet rs = pstmt.getResultSet();
+      boolean tableHasRows = rs.next();
+      if (tableHasRows) {
+        title = rs.getString(1);
+      }
+      pstmt.close();
+    } catch (SQLException e) {
+      System.out.println("Error getting title: " + e.getMessage());
+    }
+
+    // assign the new title
+    this.setTitle(title);
+  }
+
+  /** Save a document entry in the xml_revisions table */
+  public void saveDocument(String docid) throws SQLException {
+    // First get all of the values we need
+    long rnodeid = -1;
+    String docname = null;
+    String doctype = null;
+    String doctitle = null;
+    Date date_created = null;
+    PreparedStatement pstmt = conn.prepareStatement(
+       "SELECT rootnodeid, docname, doctype, doctitle, date_created " +
+       "FROM xml_documents " +
+       "WHERE docid = ?");
+    // Bind the values to the query and execute it
+    pstmt.setString(1, docid);
+    pstmt.execute();
+
+    ResultSet rs = pstmt.getResultSet();
+    boolean tableHasRows = rs.next();
+    if (tableHasRows) {
+      rnodeid      = rs.getLong(1);
+      docname      = rs.getString(2);
+      doctype      = rs.getString(3);
+      doctitle     = rs.getString(4);
+      date_created = rs.getDate(5);
+    }
+    pstmt.close();
+
+    MetaCatUtil.debugMessage(new Long(rnodeid).toString());
+    MetaCatUtil.debugMessage(docname);
+    MetaCatUtil.debugMessage(doctitle);
+    //MetaCatUtil.debugMessage(date_created.toString());
+
+    // Next create the new record in the other table using the values selected
+    pstmt = conn.prepareStatement(
+       "INSERT INTO xml_revisions " +
+       "(revisionid, docid, rootnodeid, docname, doctype, doctitle, " +
+       "date_created, date_updated) " +
+       "VALUES (null, ?, ?, ?, ?, ?, sysdate, sysdate)");
+    // Bind the values to the query and execute it
+    pstmt.setString(1, docid);
+    pstmt.setLong(2, rnodeid);
+    pstmt.setString(3, docname);
+    pstmt.setString(4, doctype);
+    pstmt.setString(5, doctitle);
+    //pstmt.setDate(6, date_created);
+    pstmt.execute();
+    pstmt.close();
+  }
 }
Index: src/edu/ucsb/nceas/metacat/DBSAXNode.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 395)
+++ src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 396)
@@ -49,7 +49,7 @@
    * @param parentNode the parent node for this node being created
    */
   public DBSAXNode (Connection conn, String tagname, DBSAXNode parentNode, 
-                    DBSAXDocument currentDocument) {
+                    DocumentImpl currentDocument) {
 
     super(tagname);
     setParentID(parentNode.getNodeID());
@@ -303,32 +303,3 @@
     return parentNode;
   }
 }
-
-/**
- * '$Log$
- * 'Revision 1.33  2000/08/03 23:17:19  bojilova
- * 'DBSAXNode constructor simplified
- * '
- * 'Revision 1.32  2000/06/27 04:31:07  jones
- * 'Fixed bugs associated with the new UPDATE and DELETE functions of
- * 'DBWriter.  There were problematic interactions between some static
- * 'variables used in DBEntityResolver and the way in which the
- * 'Servlet objects are re-used across multiple client invocations.
- * '
- * 'Generally cleaned up error reporting.  Now all errors and success
- * 'results are reported as XML documents from MetaCatServlet.  Need
- * 'to make the command line tools do the same.
- * '
- * 'Revision 1.31  2000/06/26 10:35:05  jones
- * 'Merged in substantial changes to DBWriter and associated classes and to
- * 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE
- * 'functions.  The command line tools and the parameters for the
- * 'servlet have changed substantially.
- * '
- * 'Revision 1.30.2.2  2000/06/25 23:38:16  jones
- * 'Added RCSfile keyword
- * '
- * 'Revision 1.30.2.1  2000/06/25 23:34:17  jones
- * 'Changed documentation formatting, added log entries at bottom of source files
- * ''
- */
Index: src/edu/ucsb/nceas/metacat/DBWriter.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBWriter.java	(revision 395)
+++ src/edu/ucsb/nceas/metacat/DBWriter.java	(revision 396)
@@ -238,7 +238,7 @@
 
     conn.setAutoCommit(false);
     // Copy the record to the xml_revisions table
-    DBSAXDocument document = new DBSAXDocument(conn);
+    DocumentImpl document = new DocumentImpl(conn);
     document.saveDocument( docid );
 
     // Now delete it from the xml_documents table
@@ -249,62 +249,3 @@
     conn.commit();
   }
 }
-
-/**
- * '$Log$
- * 'Revision 1.24  2000/08/14 17:59:32  bojilova
- * 'on "DELETE" added delete from xml_index table for a given docid
- * 'before delete from xml_documents, b' of foreign key in xml_index(docid)
- * 'to xml_documents(docid)
- * '
- * 'Revision 1.23  2000/06/29 23:27:08  jones
- * 'Fixed bug in DBEntityResolver so that it now properly delegates to
- * 'the system id found inthe database.
- * 'Changed DBValidate to use DBEntityResolver, rather than the OASIS
- * 'catalog, and to return validation results in XML format.
- * '
- * 'Revision 1.22  2000/06/27 04:31:07  jones
- * 'Fixed bugs associated with the new UPDATE and DELETE functions of
- * 'DBWriter.  There were problematic interactions between some static
- * 'variables used in DBEntityResolver and the way in which the
- * 'Servlet objects are re-used across multiple client invocations.
- * '
- * 'Generally cleaned up error reporting.  Now all errors and success
- * 'results are reported as XML documents from MetaCatServlet.  Need
- * 'to make the command line tools do the same.
- * '
- * 'Revision 1.21  2000/06/26 10:35:05  jones
- * 'Merged in substantial changes to DBWriter and associated classes and to
- * 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE
- * 'functions.  The command line tools and the parameters for the
- * 'servlet have changed substantially.
- * '
- * 'Revision 1.20.2.7  2000/06/26 10:18:06  jones
- * 'Partial fix for MetaCatServlet INSERT?UPDATE bug.  Only will work on
- * 'the first call to the servlet.  Subsequent calls fail.  Seems to be
- * 'related to exception handling.  Multiple successive DELETE actions
- * 'work fine.
- * '
- * 'Revision 1.20.2.6  2000/06/26 08:38:02  jones
- * 'Added DELETE feature to DBWriter.  Now takes an action "DELETE" and a
- * 'docid and will move the record from the xml_documents table to the
- * 'xml_revisions table.
- * 'Modified option parsing to support option symbols on command line.
- * '
- * 'Revision 1.20.2.5  2000/06/26 02:02:20  jones
- * 'Continued fixing problems with exception handling that deals
- * 'with INSERT and UPDATE actions and the docid passed to DBWriter
- * '
- * 'Revision 1.20.2.4  2000/06/26 00:51:06  jones
- * 'If docid passed to DBWriter.write() is not unique, classes now generate
- * 'an AccessionNumberException containing the new docid generated as a
- * 'replacement.  The docid is then extracted from the exception and
- * 'returned to the calling application for user feedback or client processing.
- * '
- * 'Revision 1.20.2.3  2000/06/25 23:38:16  jones
- * 'Added RCSfile keyword
- * '
- * 'Revision 1.20.2.2  2000/06/25 23:34:18  jones
- * 'Changed documentation formatting, added log entries at bottom of source files
- * ''
- */
