Index: src/edu/ucsb/nceas/metacat/DBSAXNode.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 2357)
+++ src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 2358)
@@ -36,7 +36,7 @@
 
 import edu.ucsb.nceas.dbadapter.AbstractDatabase;
 
-/** 
+/**
  * A Class that represents an XML node and its contents and
  * can write its own representation to a database connection
  */
@@ -46,7 +46,7 @@
   private DBSAXNode	parentNode;
   private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
 
-  /** 
+  /**
    * Construct a new node instance for DOCUMENT nodes
    *
    * @param conn the JDBC Connection to which all information is written
@@ -60,7 +60,7 @@
     updateRootNodeID(getNodeID());
   }
 
-  /** 
+  /**
    * Construct a new node instance for ELEMENT nodes
    *
    * @param conn the JDBC Connection to which all information is written
@@ -68,8 +68,8 @@
    * @param parentNode the parent node for this node being created
    */
   public DBSAXNode (DBConnection conn, String qName, String lName,
-                    DBSAXNode parentNode, long rootnodeid, 
-                    String docid, String doctype) 
+                    DBSAXNode parentNode, long rootnodeid,
+                    String docid, String doctype)
                                                throws SAXException {
 
     super(lName);
@@ -83,8 +83,8 @@
     //No writing XML Index from here. New Thread used instead.
     //updateNodeIndex(docid, doctype);
   }
-  
-  /** 
+
+  /**
    * Construct a new node instance for DTD nodes
    * This Node will write docname, publicId and systemId into db. Only
    * handle systemid  existed.(external dtd)
@@ -93,9 +93,9 @@
    * @param tagname the name of the node
    * @param parentNode the parent node for this node being created
    */
-  public DBSAXNode (DBConnection conn, String docName, String publicId, 
-                    String systemId, DBSAXNode parentNode, long rootnodeid, 
-                    String docid) throws SAXException 
+  public DBSAXNode (DBConnection conn, String docName, String publicId,
+                    String systemId, DBSAXNode parentNode, long rootnodeid,
+                    String docid) throws SAXException
   {
 
     super();
@@ -124,32 +124,50 @@
       writeDTDNodeToDB(DocumentImpl.SYSTEMID, systemId, docid);
     }
   }
-    
+
   /** creates SQL code and inserts new node into DB connection */
   public long writeChildNodeToDB(String nodetype, String nodename,
-                                 String data, String docid) 
-                                 throws SAXException 
+                                 String data, String docid)
+                                 throws SAXException
   {
     long nid = -1;
-    try 
+    try
     {
- 
+
       PreparedStatement pstmt;
+
       if (nodetype == "DOCUMENT") {
         pstmt = connection.prepareStatement(
             "INSERT INTO xml_nodes " +
             "(nodetype, nodename, nodeprefix, docid) " +
             "VALUES (?, ?, ?, ?)");
-        
+
         // Increase DBConnection usage count
         connection.increaseUsageCount(1);
         MetaCatUtil.debugMessage("INSERTING DOCNAME: " + nodename, 35);
       } else {
-        pstmt = connection.prepareStatement(
-            "INSERT INTO xml_nodes " +
-            "(nodetype, nodename, nodeprefix, docid, " +
-            "rootnodeid, parentnodeid, nodedata, nodeindex) " +
-            "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+          if(data != null && !data.trim().equals("")){
+              try{
+                  double numberData = Double.parseDouble(data);
+                  pstmt = connection.prepareStatement(
+                      "INSERT INTO xml_nodes " +
+                      "(nodetype, nodename, nodeprefix, docid, " +
+                      "rootnodeid, parentnodeid, nodedata, nodeindex, nodedatanumerical) " +
+                      "VALUES (?, ?, ?, ?, ?, ?, ?, ?, "+ numberData +")");
+              } catch (NumberFormatException nfe) {
+                  pstmt = connection.prepareStatement(
+                      "INSERT INTO xml_nodes " +
+                      "(nodetype, nodename, nodeprefix, docid, " +
+                      "rootnodeid, parentnodeid, nodedata, nodeindex) " +
+                      "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+              }
+          } else {
+              pstmt = connection.prepareStatement(
+                  "INSERT INTO xml_nodes " +
+                  "(nodetype, nodename, nodeprefix, docid, " +
+                  "rootnodeid, parentnodeid, nodedata, nodeindex) " +
+                  "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+          }
         // Increase DBConnection usage count
         connection.increaseUsageCount(1);
       }
@@ -188,8 +206,8 @@
       // get the generated unique id afterward
       nid = dbAdapter.getUniqueID(connection.getConnections(), "xml_nodes");
       //should incease connection usage!!!!!!
-     
-      
+
+
       if (nodetype.equals("DOCUMENT")) {
         // Record the root node id that was generated from the database
         setRootNodeID(nid);
@@ -208,7 +226,7 @@
     } catch (SQLException e) {
       System.out.println("Error in DBSaxNode.writeChildNodeToDB");
       System.err.println("Error inserting node: (" + nodetype + ", " +
-                                                     nodename + ", " + 
+                                                     nodename + ", " +
                                                      data + ")" );
       System.err.println(e.getMessage());
       e.printStackTrace(System.err);
@@ -217,7 +235,7 @@
     return nid;
   }
 
-  /** 
+  /**
    * update rootnodeid=nodeid for 'DOCUMENT' type of nodes only
    */
   public void updateRootNodeID(long nodeid) throws SAXException {
@@ -236,15 +254,15 @@
         pstmt.execute();
         pstmt.close();
       } catch (SQLException e) {
-        System.out.println("Error in DBSaxNode.updateRootNodeID: " + 
+        System.out.println("Error in DBSaxNode.updateRootNodeID: " +
                            e.getMessage());
         throw new SAXException(e.getMessage());
       }
   }
 
-  /** 
-   * creates SQL code to put nodename for the document node 
-   * into DB connection 
+  /**
+   * creates SQL code to put nodename for the document node
+   * into DB connection
    */
   public void writeNodename(String nodename) throws SAXException {
       try {
@@ -262,7 +280,7 @@
         pstmt.execute();
         pstmt.close();
       } catch (SQLException e) {
-        System.out.println("Error in DBSaxNode.writeNodeName: " + 
+        System.out.println("Error in DBSaxNode.writeNodeName: " +
                            e.getMessage());
         throw new SAXException(e.getMessage());
       }
@@ -269,23 +287,41 @@
   }
 
  /** creates SQL code and inserts new node into DB connection */
-  public long writeDTDNodeToDB(String nodename, String data, String docid) 
-                                 throws SAXException 
+  public long writeDTDNodeToDB(String nodename, String data, String docid)
+                                 throws SAXException
   {
     long nid = -1;
-    try 
+    try
     {
- 
+
       PreparedStatement pstmt;
       MetaCatUtil.debugMessage("Insert dtd into db: "+nodename +" "+data, 45);
-      pstmt = connection.prepareStatement(
-            "INSERT INTO xml_nodes " +
-            "(nodetype, nodename, docid, " +
-            "rootnodeid, parentnodeid, nodedata, nodeindex) " +
-            "VALUES (?, ?, ?, ?, ?, ?, ?)");
+      if(data != null && !data.trim().equals("")){
+            try{
+                double numberData = Double.parseDouble(data);
+                pstmt = connection.prepareStatement(
+                    "INSERT INTO xml_nodes " +
+                    "(nodetype, nodename, docid, " +
+                    "rootnodeid, parentnodeid, nodedata, nodeindex, nodedatanumerical) " +
+                    "VALUES (?, ?, ?, ?, ?, ?, ?, "+ numberData +")");
+            } catch (NumberFormatException nfe) {
+                pstmt = connection.prepareStatement(
+                    "INSERT INTO xml_nodes " +
+                    "(nodetype, nodename,  docid, " +
+                    "rootnodeid, parentnodeid, nodedata, nodeindex) " +
+                    "VALUES (?, ?, ?, ?, ?, ?, ?)");
+            }
+        } else {
+            pstmt = connection.prepareStatement(
+                  "INSERT INTO xml_nodes " +
+                  "(nodetype, nodename, docid, " +
+                  "rootnodeid, parentnodeid, nodedata, nodeindex) " +
+                  "VALUES (?, ?, ?, ?, ?, ?, ?)");
+        }
+
        // Increase DBConnection usage count
       connection.increaseUsageCount(1);
-      
+
       // Bind the values to the query
       pstmt.setString(1, DocumentImpl.DTD);
       pstmt.setString(2, nodename);
@@ -294,7 +330,7 @@
       pstmt.setLong(5, getParentID());
       pstmt.setString(6, data);
       pstmt.setInt(7, getNodeIndex());
-    
+
       // Do the insertion
       pstmt.execute();
       pstmt.close();
@@ -302,11 +338,11 @@
       // get the generated unique id afterward
       nid = dbAdapter.getUniqueID(connection.getConnections(), "xml_nodes");
       //should incease connection usage!!!!!!
-     
+
     } catch (SQLException e) {
       System.out.println("Error in DBSaxNode.writeDTDNodeToDB");
       System.err.println("Error inserting node: (" + DocumentImpl.DTD + ", " +
-                                                     nodename + ", " + 
+                                                     nodename + ", " +
                                                      data + ")" );
       System.err.println(e.getMessage());
       e.printStackTrace(System.err);
@@ -314,8 +350,8 @@
     }
     return nid;
   }
- 
-  
+
+
   /** get next node id from DB connection */
   private long generateNodeID() throws SAXException {
       long nid=0;
@@ -335,7 +371,7 @@
         }
         stmt.close();
       } catch (SQLException e) {
-        System.out.println("Error in DBSaxNode.generateNodeID: " + 
+        System.out.println("Error in DBSaxNode.generateNodeID: " +
                             e.getMessage());
         throw new SAXException(e.getMessage());
       }
@@ -350,10 +386,10 @@
 
   /** Add a new attribute to this node, or set its value */
   public long setAttribute(String attName, String attValue, String docid)
-              throws SAXException 
+              throws SAXException
   {
     long nodeId = -1;
-    if (attName != null) 
+    if (attName != null)
     {
       // Enter the attribute in the hash table
       super.setAttribute(attName, attValue);
@@ -360,8 +396,8 @@
 
       // And enter the attribute in the database
       nodeId = writeChildNodeToDB("ATTRIBUTE", attName, attValue, docid);
-    } 
-    else 
+    }
+    else
     {
       System.err.println("Attribute name must not be null!");
       throw new SAXException("Attribute name must not be null!");
@@ -371,17 +407,17 @@
 
   /** Add a namespace to this node */
   public long setNamespace(String prefix, String uri, String docid)
-              throws SAXException 
+              throws SAXException
   {
     long nodeId = -1;
-    if (prefix != null) 
+    if (prefix != null)
     {
       // Enter the namespace in a hash table
       super.setNamespace(prefix, uri);
       // And enter the namespace in the database
       nodeId = writeChildNodeToDB("NAMESPACE", prefix, uri, docid);
-    } 
-    else 
+    }
+    else
     {
       System.err.println("Namespace prefix must not be null!");
       throw new SAXException("Namespace prefix must not be null!");
@@ -389,15 +425,15 @@
     return nodeId;
   }
 
- 
 
-  /** 
+
+  /**
    * USED FROM SEPARATE THREAD RUNNED from DBSAXHandler on endDocument()
    * Update the node index (xml_index) for this node by generating
    * test strings that represent all of the relative and absolute
    * paths through the XML tree from document root to this node
    */
-  public void updateNodeIndex(DBConnection conn, String docid, String doctype) 
+  public void updateNodeIndex(DBConnection conn, String docid, String doctype)
                throws SAXException
   {
     Hashtable pathlist = new Hashtable();
@@ -432,22 +468,22 @@
         pathlist.put(currentPath.toString(), new Long(getNodeID()));
         counter++;
         atRootDocumentNode = true;
-      } 
+      }
     }
 
     try {
       // Create an insert statement to reuse for all of the path insertions
       PreparedStatement pstmt = conn.prepareStatement(
-              "INSERT INTO xml_index (nodeid, path, docid, doctype, " + 
-               "parentnodeid) " + 
+              "INSERT INTO xml_index (nodeid, path, docid, doctype, " +
+               "parentnodeid) " +
               "VALUES (?, ?, ?, ?, ?)");
       // Increase usage count
       conn.increaseUsageCount(1);
-  
+
       pstmt.setString(3, docid);
       pstmt.setString(4, doctype);
       pstmt.setLong(5, getParentID());
-      
+
       // Step through the hashtable and insert each of the path values
       Enumeration en = pathlist.keys();
       while (en.hasMoreElements()) {
@@ -455,7 +491,7 @@
         Long nodeid = (Long)pathlist.get(path);
         pstmt.setLong(1, nodeid.longValue());
         pstmt.setString(2, path);
-        
+
         pstmt.executeUpdate();
       }
       // Close the database statement
@@ -467,7 +503,7 @@
       throw new SAXException(sqe.getMessage());
     }
   }
- 
+
   /** get the parent of this node */
   public DBSAXNode getParentNode() {
     return parentNode;
