Index: bin/squeryxml
===================================================================
--- bin/squeryxml	(revision 2066)
+++ bin/squeryxml	(nonexistent)
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-#    Copyright: 2000 Regents of the University of California and the
-#               National Center for Ecological Analysis and Synthesis
-#  For Details: http://www.nceas.ucsb.edu/
-#    File Info: '$Id$'
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-PARSER=/usr/local/devtools/xerces-1_1_3/xerces.jar
-PDIR=/home/computer/$USER/development/xmltodb
-JDBC=${ORACLE_HOME}/jdbc/lib/classes111.zip
-
-export CPATH=$PDIR/build/metacat.jar:$PARSER:$JDBC
-
-java -cp ${CPATH} edu.ucsb.nceas.metacat.DBQuery $1

Property changes on: bin/squeryxml
___________________________________________________________________
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: bin/readxml
===================================================================
--- bin/readxml	(revision 2066)
+++ bin/readxml	(nonexistent)
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-#    Copyright: 2000 Regents of the University of California and the
-#               National Center for Ecological Analysis and Synthesis
-#  For Details: http://www.nceas.ucsb.edu/
-#    File Info: '$Id$'
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-PARSER=/usr/local/devtools/xerces-1_1_3/xerces.jar
-PDIR=/home/computer/$USER/development/xmltodb
-JDBC=${ORACLE_HOME}/jdbc/lib/classes111.zip
-
-export CPATH=$PDIR/build/metacat.jar:$PARSER:$JDBC
-
-java -cp ${CPATH} edu.ucsb.nceas.metacat.DocumentImpl $@

Property changes on: bin/readxml
___________________________________________________________________
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: bin/loadxml
===================================================================
--- bin/loadxml	(revision 2066)
+++ bin/loadxml	(nonexistent)
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-#    Copyright: 2000 Regents of the University of California and the
-#               National Center for Ecological Analysis and Synthesis
-#  For Details: http://www.nceas.ucsb.edu/
-#    File Info: '$Id$'
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-PARSER=/usr/local/devtools/xerces-1_1_3/xerces.jar
-PDIR=/home/computer/$USER/development/xmltodb
-JDBC=${ORACLE_HOME}/jdbc/lib/classes111.zip
-
-export CPATH=$PDIR/build/metacat.jar:$PARSER:$JDBC
-
-java -cp ${CPATH} edu.ucsb.nceas.metacat.DocumentImpl $@

Property changes on: bin/loadxml
___________________________________________________________________
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: bin/xml2sql
===================================================================
--- bin/xml2sql	(revision 2066)
+++ bin/xml2sql	(nonexistent)
@@ -1,39 +0,0 @@
-#!/bin/sh
-#
-#    Copyright: 2000 Regents of the University of California and the
-#               National Center for Ecological Analysis and Synthesis
-#  For Details: http://www.nceas.ucsb.edu/
-#    File Info: '$Id$'
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-PARSER=/usr/local/devtools/xerces-1_1_3/xerces.jar
-PDIR=/home/computer/$USER/development/xmltodb
-JDBC=${ORACLE_HOME}/jdbc/lib/classes111.zip
-
-export CPATH=$PDIR/build/metacat.jar:$PARSER:$JDBC
-
-echo " "
-echo "WITH INDEX"
-echo "----------"
-echo " "
-java -cp ${CPATH} edu.ucsb.nceas.metacat.QuerySpecification $1
-echo " "
-
-echo "NO INDEX"
-echo "----------"
-echo " "
-java -cp ${CPATH} edu.ucsb.nceas.metacat.QuerySpecification -noindex $1
-echo " "

Property changes on: bin/xml2sql
___________________________________________________________________
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: bin/valxml
===================================================================
--- bin/valxml	(revision 2066)
+++ bin/valxml	(nonexistent)
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-#    Copyright: 2000 Regents of the University of California and the
-#               National Center for Ecological Analysis and Synthesis
-#  For Details: http://www.nceas.ucsb.edu/
-#    File Info: '$Id$'
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-PARSER=/usr/local/devtools/xerces-1_1_3/xerces.jar
-PDIR=/home/computer/$USER/development/xmltodb
-JDBC=${ORACLE_HOME}/jdbc/lib/classes111.zip
-
-export CPATH=$PDIR/build/metacat.jar:$PARSER:$JDBC
-
-java -cp ${CPATH} edu.ucsb.nceas.metacat.DBValidate $1

Property changes on: bin/valxml
___________________________________________________________________
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: bin/queryxml
===================================================================
--- bin/queryxml	(revision 2066)
+++ bin/queryxml	(nonexistent)
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-#    Copyright: 2000 Regents of the University of California and the
-#               National Center for Ecological Analysis and Synthesis
-#  For Details: http://www.nceas.ucsb.edu/
-#    File Info: '$Id$'
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-PARSER=/usr/local/devtools/xerces-1_1_3/xerces.jar
-PDIR=/home/computer/$USER/development/xmltodb
-JDBC=${ORACLE_HOME}/jdbc/lib/classes111.zip
-
-export CPATH=$PDIR/build/metacat.jar:$PARSER:$JDBC
-
-java -cp ${CPATH} edu.ucsb.nceas.metacat.DBSimpleQuery $1 $2

Property changes on: bin/queryxml
___________________________________________________________________
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/QuerySpecification.java
===================================================================
--- src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 2066)
+++ src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 2067)
@@ -30,964 +30,981 @@
 
 package edu.ucsb.nceas.metacat;
 
-import edu.ucsb.nceas.dbadapter.*;
-
-import java.io.*;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Stack;
 import java.util.Vector;
-import java.util.Enumeration;
 
+import edu.ucsb.nceas.dbadapter.AbstractDatabase;
+
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
 import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.helpers.DefaultHandler;
 
 /**
- * A Class that represents a structured query, and can be 
- * constructed from an XML serialization conforming to @see pathquery.dtd. 
- * The printSQL() method can be used to print a SQL serialization of the query.
+ * A Class that represents a structured query, and can be constructed from an
+ * XML serialization conforming to
+ * 
+ * @see pathquery.dtd. The printSQL() method can be used to print a SQL
+ *      serialization of the query.
  */
-public class QuerySpecification extends DefaultHandler {
- 
-  /** flag determining whether extended query terms are present */
-  private boolean containsExtendedSQL=false;
-  /** Identifier for this query document */
-  private String meta_file_id;
-  /** Title of this query */
-  private String queryTitle;
-  /** List of document types to be returned using package back tracing */
-  private Vector returnDocList;
-  /** List of document types to be searched */
-  private Vector filterDocList;
-  /** List of fields to be returned in result set */
-  private Vector returnFieldList;
-  /** List of users owning documents to be searched */
-  private Vector ownerList;
-  /** List of sites/scopes used to constrain search */
-  private Vector siteList;
-  /** The root query group that contains the recursive query constraints */
-  private QueryGroup query = null;
- 
-  // Query data structures used temporarily during XML parsing
-  private Stack elementStack;
-  private Stack queryStack;
-  private String currentValue;
-  private String currentPathexpr;
-  private String parserName = null;
-  private String accNumberSeparator = null;
-  private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
-  
+public class QuerySpecification extends DefaultHandler
+{
 
-  private boolean percentageSearch = false;
-  
-  private String userName = null;
-  private static final String PUBLIC = "public";
-  private String [] group = null;
+    /** flag determining whether extended query terms are present */
+    private boolean containsExtendedSQL = false;
 
-  public static final String ATTRIBUTESYMBOL = "@";
-  private boolean hasAttributeReturnField = false;
-  private Hashtable attributeReturnList = new Hashtable();
-  private int countAttributeReturnField = 0;
-  /**
-   * construct an instance of the QuerySpecification class 
-   *
-   * @param queryspec the XML representation of the query (should conform
-   *                  to pathquery.dtd) as a Reader
-   * @param parserName the fully qualified name of a Java Class implementing
-   *                  the org.xml.sax.XMLReader interface
-   */
-  public QuerySpecification( Reader queryspec, String parserName,
-         String accNumberSeparator ) throws IOException {
-    super();
-    
-    // Initialize the class variables
-    returnDocList = new Vector();
-    filterDocList = new Vector();
-    elementStack = new Stack();
-    queryStack   = new Stack();
-    returnFieldList = new Vector();
-    ownerList = new Vector();
-    siteList = new Vector();
-    this.parserName = parserName;
-    this.accNumberSeparator = accNumberSeparator;
+    /** Identifier for this query document */
+    private String meta_file_id;
 
-    // Initialize the parser and read the queryspec
-    XMLReader parser = initializeParser();
-    if (parser == null) {
-      System.err.println("SAX parser not instantiated properly.");
+    /** Title of this query */
+    private String queryTitle;
+
+    /** List of document types to be returned using package back tracing */
+    private Vector returnDocList;
+
+    /** List of document types to be searched */
+    private Vector filterDocList;
+
+    /** List of fields to be returned in result set */
+    private Vector returnFieldList;
+
+    /** List of users owning documents to be searched */
+    private Vector ownerList;
+
+    /** List of sites/scopes used to constrain search */
+    private Vector siteList;
+
+    /** The root query group that contains the recursive query constraints */
+    private QueryGroup query = null;
+
+    // Query data structures used temporarily during XML parsing
+    private Stack elementStack;
+
+    private Stack queryStack;
+
+    private String currentValue;
+
+    private String currentPathexpr;
+
+    private String parserName = null;
+
+    private String accNumberSeparator = null;
+
+    private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
+
+    private boolean percentageSearch = false;
+
+    private String userName = null;
+
+    private static final String PUBLIC = "public";
+
+    private String[] group = null;
+
+    public static final String ATTRIBUTESYMBOL = "@";
+
+    private boolean hasAttributeReturnField = false;
+
+    private Hashtable attributeReturnList = new Hashtable();
+
+    private int countAttributeReturnField = 0;
+
+    /**
+     * construct an instance of the QuerySpecification class
+     * 
+     * @param queryspec
+     *            the XML representation of the query (should conform to
+     *            pathquery.dtd) as a Reader
+     * @param parserName
+     *            the fully qualified name of a Java Class implementing the
+     *            org.xml.sax.XMLReader interface
+     */
+    public QuerySpecification(Reader queryspec, String parserName,
+            String accNumberSeparator) throws IOException
+    {
+        super();
+
+        // Initialize the class variables
+        returnDocList = new Vector();
+        filterDocList = new Vector();
+        elementStack = new Stack();
+        queryStack = new Stack();
+        returnFieldList = new Vector();
+        ownerList = new Vector();
+        siteList = new Vector();
+        this.parserName = parserName;
+        this.accNumberSeparator = accNumberSeparator;
+
+        // Initialize the parser and read the queryspec
+        XMLReader parser = initializeParser();
+        if (parser == null) {
+            System.err.println("SAX parser not instantiated properly.");
+        }
+        try {
+            parser.parse(new InputSource(queryspec));
+        } catch (SAXException e) {
+            System.err.println("error parsing data in "
+                    + "QuerySpecification.QuerySpecification");
+            System.err.println(e.getMessage());
+        }
     }
-    try {
-      parser.parse(new InputSource(queryspec));
-    } catch (SAXException e) {
-      System.err.println("error parsing data in " + 
-                         "QuerySpecification.QuerySpecification");
-      System.err.println(e.getMessage());
+
+    /**
+     * construct an instance of the QuerySpecification class
+     * 
+     * @param queryspec
+     *            the XML representation of the query (should conform to
+     *            pathquery.dtd) as a String
+     * @param parserName
+     *            the fully qualified name of a Java Class implementing the
+     *            org.xml.sax.Parser interface
+     */
+    public QuerySpecification(String queryspec, String parserName,
+            String accNumberSeparator) throws IOException
+    {
+        this(new StringReader(queryspec), parserName, accNumberSeparator);
     }
-  }
 
-  /**
-   * construct an instance of the QuerySpecification class 
-   *
-   * @param queryspec the XML representation of the query (should conform
-   *                  to pathquery.dtd) as a String
-   * @param parserName the fully qualified name of a Java Class implementing
-   *                  the org.xml.sax.Parser interface
-   */
-  public QuerySpecification( String queryspec, String parserName,
-         String accNumberSeparator) throws IOException {
-    this(new StringReader(queryspec), parserName, accNumberSeparator);
-  }
-  
-  /**
-   * construct an instance of the QuerySpecification class which don't need 
-   * to parser a xml document
-   * @param accNumberSeparator  the separator between doc version
-   */
-  public QuerySpecification(String accNumberSeparator ) throws IOException 
-  {
-    // Initialize the class variables
-    returnDocList = new Vector();
-    filterDocList = new Vector();
-    elementStack = new Stack();
-    queryStack   = new Stack();
-    returnFieldList = new Vector();
-    ownerList = new Vector();
-    siteList = new Vector();
-    this.accNumberSeparator = accNumberSeparator;
-   }
-  
-  
-  /**
-   * Method to set user name
-   *
-   * @param myName  the user name
-   */
-  public void setUserName(String myName)
-  { 
-    //to lower case
-    if (myName != null)
+    /**
+     * construct an instance of the QuerySpecification class which don't need
+     * to parser a xml document
+     * 
+     * @param accNumberSeparator
+     *            the separator between doc version
+     */
+    public QuerySpecification(String accNumberSeparator) throws IOException
     {
-      this.userName = myName.toLowerCase();
+        // Initialize the class variables
+        returnDocList = new Vector();
+        filterDocList = new Vector();
+        elementStack = new Stack();
+        queryStack = new Stack();
+        returnFieldList = new Vector();
+        ownerList = new Vector();
+        siteList = new Vector();
+        this.accNumberSeparator = accNumberSeparator;
     }
-    else
+
+    /**
+     * Method to set user name
+     * 
+     * @param myName
+     *            the user name
+     */
+    public void setUserName(String myName)
     {
-      this.userName = myName;
+        //to lower case
+        if (myName != null) {
+            this.userName = myName.toLowerCase();
+        } else {
+            this.userName = myName;
+        }
     }
-  }
-  
-  /**
-   * Method to set user group
-   *
-   * @param myGroup  the user group
-   */
-  public void setGroup(String [] myGroup)
-  {
-    this.group = myGroup;
-  }
-  /**
-   * Method to indicate this query is a percentage search
-   */
-  public boolean isPercentageSearch()
-  {
-    return percentageSearch;
-  }
-  /*
-   * Method to get owner query. If it is owner it has all permission
-   */
-  private String createOwerQuery()
-  {
-    String ownerQuery = null;
-    ownerQuery = "SELECT docid FROM xml_documents WHERE ";
-    if (userName != null && !userName.equals(""))
+
+    /**
+     * Method to set user group
+     * 
+     * @param myGroup
+     *            the user group
+     */
+    public void setGroup(String[] myGroup)
     {
-      ownerQuery = ownerQuery + "lower(user_owner) ='"+ userName +"'";
+        this.group = myGroup;
     }
-    
-    MetaCatUtil.debugMessage("OwnerQuery: "+ownerQuery, 30);
-    return ownerQuery;
-  }
-  
-  /*
-   * Method to create query for xml_access, this part is to get docid list which
-   * have a allow rule for a given user
-   */
-  private String createAllowRuleQuery()
-  {
-    String allowQuery = null;
-    String allowString = constructAllowString();
-    allowQuery ="SELECT docid from xml_access WHERE( "+allowString;
-    allowQuery = allowQuery +") AND subtreeid IS NULL";
-    MetaCatUtil.debugMessage("allow query is: "+ allowQuery, 30);
-    return allowQuery;
-    
-  
-  }
-  
-  /* Method to construct a allow rule string */
-  private String constructAllowString()
-  {
-    String allowQuery ="";
-     // add allow rule for user name
-     if (userName != null && !userName.equals(""))
+
+    /**
+     * Method to indicate this query is a percentage search
+     */
+    public boolean isPercentageSearch()
     {
-      allowQuery = allowQuery +"(lower(principal_name) = '" + userName 
-                              +"' AND perm_type = 'allow'"
-                              +" AND (permission='4' OR permission='7'))";
+        return percentageSearch;
     }
-    // add allow rule for public
-    allowQuery = allowQuery +"OR (lower(principal_name) = '" + PUBLIC 
-                              +"' AND perm_type = 'allow'"
-                              +" AND (permission='4' OR permission='7'))";
-    
-    // add allow rule for group
-    if (group != null)
+
+    /*
+     * Method to get owner query. If it is owner it has all permission
+     */
+    private String createOwerQuery()
     {
-      for (int i = 0; i< group.length; i++)
-      {
-        String groupUint = group[i];
-        if (groupUint != null && !groupUint.equals(""))
-        {
-          groupUint = groupUint.toLowerCase();
-          allowQuery = allowQuery +" OR (lower(principal_name) = '" + groupUint 
-                              +"' AND perm_type = 'allow'"
-                              +" AND (permission='4' OR permission='7'))";
-        }//if
-      }//for
-    }//if
-    MetaCatUtil.debugMessage("allow string is: "+ allowQuery, 40);
-    return allowQuery;
-  }
+        String ownerQuery = null;
+        ownerQuery = "SELECT docid FROM xml_documents WHERE ";
+        if (userName != null && !userName.equals("")) {
+            ownerQuery = ownerQuery + "lower(user_owner) ='" + userName + "'";
+        }
 
-   /*
-   * Method to create query for xml_access, this part is to get docid list which
-   * have a deny rule and perm_order is allowFirst for a given user. This means
-   * the user will be denied to read
-   */
-  private String createDenyRuleQuery()
-  {
-    String denyQuery = null;
-    String denyString = constructDenyString();
-    denyQuery ="SELECT docid from xml_access WHERE( " + denyString;
-    denyQuery = denyQuery + ") AND subtreeid IS NULL ";
-    MetaCatUtil.debugMessage("denyquery is: "+ denyQuery, 30);
-    return denyQuery;
-  
-  }
-  /* Construct deny string */
-  private String constructDenyString()
-  {
-    String denyQuery ="";
-    // add deny rule for user name
-    if (userName != null && !userName.equals(""))
+        MetaCatUtil.debugMessage("OwnerQuery: " + ownerQuery, 30);
+        return ownerQuery;
+    }
+
+    /*
+     * Method to create query for xml_access, this part is to get docid list
+     * which have a allow rule for a given user
+     */
+    private String createAllowRuleQuery()
     {
-      denyQuery = denyQuery +"(lower(principal_name) = '" + userName 
-                              +"' AND perm_type = 'deny' "
-                              +"AND perm_order ='allowFirst'"
-                              +" AND (permission='4' OR permission='7'))";
+        String allowQuery = null;
+        String allowString = constructAllowString();
+        allowQuery = "SELECT docid from xml_access WHERE( " + allowString;
+        allowQuery = allowQuery + ") AND subtreeid IS NULL";
+        MetaCatUtil.debugMessage("allow query is: " + allowQuery, 30);
+        return allowQuery;
+
     }
-    // add deny rule for public
-    denyQuery = denyQuery +"OR (lower(principal_name) = '" + PUBLIC 
-                               +"' AND perm_type = 'deny' "
-                               +"AND perm_order ='allowFirst'"
-                               +" AND (permission='4' OR permission='7'))";
-    
-    // add allow rule for group
-    if (group != null)
+
+    /* Method to construct a allow rule string */
+    private String constructAllowString()
     {
-      for (int i = 0; i< group.length; i++)
-      {
-        String groupUint = group[i];
-        if (groupUint != null && !groupUint.equals(""))
-        {
-          groupUint = groupUint.toLowerCase();
-          denyQuery = denyQuery +" OR (lower(principal_name) = '" + groupUint 
-                                +"' AND perm_type = 'deny' "
-                                +"AND perm_order ='allowFirst'"
-                                +" AND (permission='4' OR permission='7'))";
+        String allowQuery = "";
+        // add allow rule for user name
+        if (userName != null && !userName.equals("")) {
+            allowQuery = allowQuery + "(lower(principal_name) = '" + userName
+                    + "' AND perm_type = 'allow'"
+                    + " AND (permission='4' OR permission='7'))";
+        }
+        // add allow rule for public
+        allowQuery = allowQuery + "OR (lower(principal_name) = '" + PUBLIC
+                + "' AND perm_type = 'allow'"
+                + " AND (permission='4' OR permission='7'))";
+
+        // add allow rule for group
+        if (group != null) {
+            for (int i = 0; i < group.length; i++) {
+                String groupUint = group[i];
+                if (groupUint != null && !groupUint.equals("")) {
+                    groupUint = groupUint.toLowerCase();
+                    allowQuery = allowQuery + " OR (lower(principal_name) = '"
+                            + groupUint + "' AND perm_type = 'allow'"
+                            + " AND (permission='4' OR permission='7'))";
+                }//if
+            }//for
         }//if
-      }//for
-    }//if
-    return denyQuery;
-  }
-  
-  /**
-   * Method to append a access control query to SQL. So in DBQuery class, we can
-   * get docid from both user specified query and access control query. We don't
-   * need to checking permission after we get the doclist. It will be good to 
-   * performance
-   *
-   */
-  public String getAccessQuery()
-  {
-    String accessQuery = null;
-    String onwer = createOwerQuery();
-    String allow = createAllowRuleQuery();
-    String deny = createDenyRuleQuery();
-    accessQuery = " AND (docid IN("+ onwer + ")";
-    accessQuery = accessQuery + " OR (docid IN (" + allow + ")" 
-                 + " AND docid NOT IN ("+ deny + ")))";
-    MetaCatUtil.debugMessage("accessquery is: "+ accessQuery, 30);
-    return accessQuery;
-  }
-  
-  /** Main routine for testing */
-  static public void main(String[] args) {
+        MetaCatUtil.debugMessage("allow string is: " + allowQuery, 40);
+        return allowQuery;
+    }
 
-     if (args.length < 1) {
-       System.err.println("Wrong number of arguments!!!");
-       System.err.println("USAGE: java QuerySpecification <xmlfile>");
-       return;
-     } else {
-       int i = 0;
-       boolean useXMLIndex = true;
-       if ( args[i].equals( "-noindex" ) ) {
-         useXMLIndex = false;
-         i++;
-       }
-       String xmlfile  = args[i];
+    /*
+     * Method to create query for xml_access, this part is to get docid list
+     * which have a deny rule and perm_order is allowFirst for a given user.
+     * This means the user will be denied to read
+     */
+    private String createDenyRuleQuery()
+    {
+        String denyQuery = null;
+        String denyString = constructDenyString();
+        denyQuery = "SELECT docid from xml_access WHERE( " + denyString;
+        denyQuery = denyQuery + ") AND subtreeid IS NULL ";
+        MetaCatUtil.debugMessage("denyquery is: " + denyQuery, 30);
+        return denyQuery;
 
-       try {
-         MetaCatUtil util = new MetaCatUtil();
-         FileReader xml = new FileReader(new File(xmlfile));
-         QuerySpecification qspec = 
-                 new QuerySpecification(xml, util.getOption("saxparser"),
-                                        util.getOption("accNumberSeparator"));
-         System.out.println(qspec.printSQL(useXMLIndex));
+    }
 
-       } catch (IOException e) {
-         System.err.println(e.getMessage());
-       }
-         
-     }
-  }
-  
-  /**
-   * Returns true if the parsed query contains and extended xml query 
-   * (i.e. there is at least one &lt;returnfield&gt; in the pathquery document)
-   */
-  public boolean containsExtendedSQL()
-  {
-    if(containsExtendedSQL)
+    /* Construct deny string */
+    private String constructDenyString()
     {
-      return true;
+        String denyQuery = "";
+        // add deny rule for user name
+        if (userName != null && !userName.equals("")) {
+            denyQuery = denyQuery + "(lower(principal_name) = '" + userName
+                    + "' AND perm_type = 'deny' "
+                    + "AND perm_order ='allowFirst'"
+                    + " AND (permission='4' OR permission='7'))";
+        }
+        // add deny rule for public
+        denyQuery = denyQuery + "OR (lower(principal_name) = '" + PUBLIC
+                + "' AND perm_type = 'deny' " + "AND perm_order ='allowFirst'"
+                + " AND (permission='4' OR permission='7'))";
+
+        // add allow rule for group
+        if (group != null) {
+            for (int i = 0; i < group.length; i++) {
+                String groupUint = group[i];
+                if (groupUint != null && !groupUint.equals("")) {
+                    groupUint = groupUint.toLowerCase();
+                    denyQuery = denyQuery + " OR (lower(principal_name) = '"
+                            + groupUint + "' AND perm_type = 'deny' "
+                            + "AND perm_order ='allowFirst'"
+                            + " AND (permission='4' OR permission='7'))";
+                }//if
+            }//for
+        }//if
+        return denyQuery;
     }
-    else
+
+    /**
+     * Method to append a access control query to SQL. So in DBQuery class, we
+     * can get docid from both user specified query and access control query.
+     * We don't need to checking permission after we get the doclist. It will
+     * be good to performance
+     *  
+     */
+    public String getAccessQuery()
     {
-      return false;
+        String accessQuery = null;
+        String onwer = createOwerQuery();
+        String allow = createAllowRuleQuery();
+        String deny = createDenyRuleQuery();
+        accessQuery = " AND (docid IN(" + onwer + ")";
+        accessQuery = accessQuery + " OR (docid IN (" + allow + ")"
+                + " AND docid NOT IN (" + deny + ")))";
+        MetaCatUtil.debugMessage("accessquery is: " + accessQuery, 30);
+        return accessQuery;
     }
-  }
-  
-  /**
-   * A method to get if the query has an attribute return field
-   */
-  public boolean containAttributeReturnField()
-  {
-    return hasAttributeReturnField;
-  }
-  
-  /**
-   * Accessor method to return the identifier of this Query
-   */
-  public String getIdentifier()
-  {
-    return meta_file_id;
-  }
 
-  /**
-   * method to set the identifier of this query
-   */
-  public void setIdentifier(String id) {
-    this.meta_file_id = id;
-  }
+    /** Main routine for testing */
+    static public void main(String[] args)
+    {
 
-  /**
-   * Accessor method to return the title of this Query
-   */
-  public String getQueryTitle()
-  {
-    return queryTitle;
-  }
+        if (args.length < 1) {
+            System.err.println("Wrong number of arguments!!!");
+            System.err.println("USAGE: java QuerySpecification <xmlfile>");
+            return;
+        } else {
+            int i = 0;
+            boolean useXMLIndex = true;
+            if (args[i].equals("-noindex")) {
+                useXMLIndex = false;
+                i++;
+            }
+            String xmlfile = args[i];
 
-  /**
-   * method to set the title of this query
-   */
-  public void setQueryTitle(String title)
-  {
-    this.queryTitle = title;
-  }
+            try {
+                MetaCatUtil util = new MetaCatUtil();
+                FileReader xml = new FileReader(new File(xmlfile));
+                QuerySpecification qspec = new QuerySpecification(xml, util
+                        .getOption("saxparser"), util
+                        .getOption("accNumberSeparator"));
+                System.out.println(qspec.printSQL(useXMLIndex));
 
-  /**
-   * Accessor method to return a vector of the return document types as
-   * defined in the &lt;returndoctype&gt; tag in the pathquery dtd.
-   */
-  public Vector getReturnDocList()
-  {
-    return this.returnDocList;
-  }
+            } catch (IOException e) {
+                System.err.println(e.getMessage());
+            }
 
-  /**
-   * method to set the list of return docs of this query
-   */
-  public void setReturnDocList(Vector returnDocList)
-  {
-    this.returnDocList = returnDocList;
-  }
+        }
+    }
 
-  /**
-   * Accessor method to return a vector of the filter doc types as
-   * defined in the &lt;filterdoctype&gt; tag in the pathquery dtd.
-   */
-  public Vector getFilterDocList()
-  {
-    return this.filterDocList;
-  }
+    /**
+     * Returns true if the parsed query contains and extended xml query (i.e.
+     * there is at least one &lt;returnfield&gt; in the pathquery document)
+     */
+    public boolean containsExtendedSQL()
+    {
+        if (containsExtendedSQL) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 
-  /**
-   * method to set the list of filter docs of this query
-   */
-  public void setFilterDocList(Vector filterDocList)
-  {
-    this.filterDocList = filterDocList;
-  }
+    /**
+     * A method to get if the query has an attribute return field
+     */
+    public boolean containAttributeReturnField()
+    {
+        return hasAttributeReturnField;
+    }
 
-  /**
-   * Accessor method to return a vector of the extended return fields as
-   * defined in the &lt;returnfield&gt; tag in the pathquery dtd.
-   */
-  public Vector getReturnFieldList()
-  {
-    return this.returnFieldList; 
-  }
+    /**
+     * Accessor method to return the identifier of this Query
+     */
+    public String getIdentifier()
+    {
+        return meta_file_id;
+    }
 
-  /**
-   * method to set the list of fields to be returned by this query
-   */
-  public void setReturnFieldList(Vector returnFieldList)
-  {
-    this.returnFieldList = returnFieldList;
-  }
+    /**
+     * method to set the identifier of this query
+     */
+    public void setIdentifier(String id)
+    {
+        this.meta_file_id = id;
+    }
 
-  /**
-   * Accessor method to return a vector of the owner fields as
-   * defined in the &lt;owner&gt; tag in the pathquery dtd.
-   */
-  public Vector getOwnerList()
-  {
-    return this.ownerList;
-  }
+    /**
+     * Accessor method to return the title of this Query
+     */
+    public String getQueryTitle()
+    {
+        return queryTitle;
+    }
 
-  /**
-   * method to set the list of owners used to constrain this query
-   */
-  public void setOwnerList(Vector ownerList)
-  {
-    this.ownerList = ownerList;
-  }
+    /**
+     * method to set the title of this query
+     */
+    public void setQueryTitle(String title)
+    {
+        this.queryTitle = title;
+    }
 
-  /**
-   * Accessor method to return a vector of the site fields as
-   * defined in the &lt;site&gt; tag in the pathquery dtd.
-   */
-  public Vector getSiteList()
-  {
-    return this.siteList;
-  }
+    /**
+     * Accessor method to return a vector of the return document types as
+     * defined in the &lt;returndoctype&gt; tag in the pathquery dtd.
+     */
+    public Vector getReturnDocList()
+    {
+        return this.returnDocList;
+    }
 
-  /**
-   * method to set the list of sites used to constrain this query
-   */
-  public void setSiteList(Vector siteList)
-  {
-    this.siteList = siteList;
-  }
+    /**
+     * method to set the list of return docs of this query
+     */
+    public void setReturnDocList(Vector returnDocList)
+    {
+        this.returnDocList = returnDocList;
+    }
 
-  /**
-   * get the QueryGroup used to express query constraints
-   */
-  public QueryGroup getQueryGroup()
-  {
-    return query;
-  }
-  
-  /**
-   * set the querygroup
-   */
-  public void setQueryGroup(QueryGroup group)
-  {
-    query = group;
-  }
-  
-  /**
-   * set if this query sepcification has extendQuery(has return doc type or not)
-   */
-  public void setContainsExtenedSQL(boolean hasExtenedQuery)
-  {
-     containsExtendedSQL = hasExtenedQuery;
-  }  
-   
-  /**
-   * Set up the SAX parser for reading the XML serialized query
-   */
-  private XMLReader initializeParser() {
-    XMLReader parser = null;
+    /**
+     * Accessor method to return a vector of the filter doc types as defined in
+     * the &lt;filterdoctype&gt; tag in the pathquery dtd.
+     */
+    public Vector getFilterDocList()
+    {
+        return this.filterDocList;
+    }
 
-    // Set up the SAX document handlers for parsing
-    try {
+    /**
+     * method to set the list of filter docs of this query
+     */
+    public void setFilterDocList(Vector filterDocList)
+    {
+        this.filterDocList = filterDocList;
+    }
 
-      // Get an instance of the parser
-      parser = XMLReaderFactory.createXMLReader(parserName);
+    /**
+     * Accessor method to return a vector of the extended return fields as
+     * defined in the &lt;returnfield&gt; tag in the pathquery dtd.
+     */
+    public Vector getReturnFieldList()
+    {
+        return this.returnFieldList;
+    }
 
-      // Set the ContentHandler to this instance
-      parser.setContentHandler(this);
+    /**
+     * method to set the list of fields to be returned by this query
+     */
+    public void setReturnFieldList(Vector returnFieldList)
+    {
+        this.returnFieldList = returnFieldList;
+    }
 
-      // Set the error Handler to this instance
-      parser.setErrorHandler(this);
+    /**
+     * Accessor method to return a vector of the owner fields as defined in the
+     * &lt;owner&gt; tag in the pathquery dtd.
+     */
+    public Vector getOwnerList()
+    {
+        return this.ownerList;
+    }
 
-    } catch (Exception e) {
-       System.err.println("Error in QuerySpcecification.initializeParser " + 
-                           e.toString());
+    /**
+     * method to set the list of owners used to constrain this query
+     */
+    public void setOwnerList(Vector ownerList)
+    {
+        this.ownerList = ownerList;
     }
 
-    return parser;
-  }
+    /**
+     * Accessor method to return a vector of the site fields as defined in the
+     * &lt;site&gt; tag in the pathquery dtd.
+     */
+    public Vector getSiteList()
+    {
+        return this.siteList;
+    }
 
-  /**
-   * callback method used by the SAX Parser when the start tag of an 
-   * element is detected. Used in this context to parse and store
-   * the query information in class variables.
-   */
-  public void startElement (String uri, String localName, 
-                            String qName, Attributes atts) 
-         throws SAXException {
-    BasicNode currentNode = new BasicNode(localName);
-    // add attributes to BasicNode here
-    if (atts != null) {
-      int len = atts.getLength();
-      for (int i = 0; i < len; i++) {
-        currentNode.setAttribute(atts.getLocalName(i), atts.getValue(i));
-      }
+    /**
+     * method to set the list of sites used to constrain this query
+     */
+    public void setSiteList(Vector siteList)
+    {
+        this.siteList = siteList;
     }
 
-    elementStack.push(currentNode); 
-    if (currentNode.getTagName().equals("querygroup")) {
-      QueryGroup currentGroup = new QueryGroup(
-                                currentNode.getAttribute("operator"));
-      if (query == null) {
-        query = currentGroup;
-      } else {
-        QueryGroup parentGroup = (QueryGroup)queryStack.peek();
-        parentGroup.addChild(currentGroup);
-      }
-      queryStack.push(currentGroup);
+    /**
+     * get the QueryGroup used to express query constraints
+     */
+    public QueryGroup getQueryGroup()
+    {
+        return query;
     }
-  }
 
-  /**
-   * callback method used by the SAX Parser when the end tag of an 
-   * element is detected. Used in this context to parse and store
-   * the query information in class variables.
-   */
-  public void endElement (String uri, String localName,
-                          String qName) throws SAXException {
-    BasicNode leaving = (BasicNode)elementStack.pop(); 
-    if (leaving.getTagName().equals("queryterm")) {
-      boolean isCaseSensitive = (new Boolean(
-              leaving.getAttribute("casesensitive"))).booleanValue();
-      QueryTerm currentTerm = null;
-      if (currentPathexpr == null) {
-        currentTerm = new QueryTerm(isCaseSensitive,
-                      leaving.getAttribute("searchmode"),currentValue);
-      } else {
-        currentTerm = new QueryTerm(isCaseSensitive,
-                      leaving.getAttribute("searchmode"),currentValue,
-                      currentPathexpr);
-      }
-      QueryGroup currentGroup = (QueryGroup)queryStack.peek();
-      currentGroup.addChild(currentTerm);
-      currentValue = null;
-      currentPathexpr = null;
-    } else if (leaving.getTagName().equals("querygroup")) {
-      QueryGroup leavingGroup = (QueryGroup)queryStack.pop();
+    /**
+     * set the querygroup
+     */
+    public void setQueryGroup(QueryGroup group)
+    {
+        query = group;
     }
-  }
 
-  /**
-   * callback method used by the SAX Parser when the text sequences of an 
-   * xml stream are detected. Used in this context to parse and store
-   * the query information in class variables.
-   */
-  public void characters(char ch[], int start, int length) {
+    /**
+     * set if this query sepcification has extendQuery(has return doc type or
+     * not)
+     */
+    public void setContainsExtenedSQL(boolean hasExtenedQuery)
+    {
+        containsExtendedSQL = hasExtenedQuery;
+    }
 
-    String inputString = new String(ch, start, length);
-    BasicNode currentNode = (BasicNode)elementStack.peek(); 
-    String currentTag = currentNode.getTagName();
-    if (currentTag.equals("meta_file_id")) {
-      meta_file_id = inputString;
-    } else if (currentTag.equals("querytitle")) {
-      queryTitle = inputString;
-    } else if (currentTag.equals("value")) {
-      currentValue = inputString;
-    } else if (currentTag.equals("pathexpr")) {
-      currentPathexpr = inputString;
-    } else if (currentTag.equals("returndoctype")) {
-      returnDocList.add(inputString);
-    } else if (currentTag.equals("filterdoctype")) {
-      filterDocList.add(inputString);
-    } else if (currentTag.equals("returnfield")) {
-       handleReturnField(inputString);
-    } else if (currentTag.equals("filterdoctype")) {
-      filterDocList.add(inputString);
-    } else if (currentTag.equals("owner")) {
-      ownerList.add(inputString);
-    } else if (currentTag.equals("site")) {
-      siteList.add(inputString);
+    /**
+     * Set up the SAX parser for reading the XML serialized query
+     */
+    private XMLReader initializeParser()
+    {
+        XMLReader parser = null;
+
+        // Set up the SAX document handlers for parsing
+        try {
+
+            // Get an instance of the parser
+            parser = XMLReaderFactory.createXMLReader(parserName);
+
+            // Set the ContentHandler to this instance
+            parser.setContentHandler(this);
+
+            // Set the error Handler to this instance
+            parser.setErrorHandler(this);
+
+        } catch (Exception e) {
+            System.err.println("Error in QuerySpcecification.initializeParser "
+                    + e.toString());
+        }
+
+        return parser;
     }
-  }
-  
-  /**
-   * Method to transfer string to return field
-   */
-  public void handleReturnField(String inputString)
-  {
-     // make sure if return fields has an attribute or not
-      if (inputString.indexOf(ATTRIBUTESYMBOL) ==-1)
-      {
-        // no attribute value will be returned
-        returnFieldList.add(inputString);
-        containsExtendedSQL = true;
-      }
-      else
-      {
-        // has a attribute return field
-        // divied the return filed into two parts, one is path and the
-        // other is attribue name
-        String returnPath = newPathExpressionWithOutAttribute(inputString);
-        String attributeName = getAttributeName(inputString);
-        Vector pathInfo = new Vector();
-        // the vector has the information about return path and attributename
-        pathInfo.addElement(returnPath);
-        pathInfo.addElement(attributeName);
-        // put the vector into a hash table. The reseaon why don't put
-        // return path or attributename as a key is because they are not unique
-        attributeReturnList.put
-                            (new Integer(countAttributeReturnField), pathInfo);
-        countAttributeReturnField++;
-        hasAttributeReturnField = true;
-        containsExtendedSQL = true;
-        
-      }
-  }
-  /**
-   * create a SQL serialization of the query that this instance represents
-   */
-  public String printSQL(boolean useXMLIndex) {
-    
-   
-    StringBuffer self = new StringBuffer();
 
-    self.append("SELECT docid,docname,doctype,");
-    self.append("date_created, date_updated, rev ");
-    self.append("FROM xml_documents WHERE docid IN (");
+    /**
+     * callback method used by the SAX Parser when the start tag of an element
+     * is detected. Used in this context to parse and store the query
+     * information in class variables.
+     */
+    public void startElement(String uri, String localName, String qName,
+            Attributes atts) throws SAXException
+    {
+        BasicNode currentNode = new BasicNode(localName);
+        // add attributes to BasicNode here
+        if (atts != null) {
+            int len = atts.getLength();
+            for (int i = 0; i < len; i++) {
+                currentNode
+                        .setAttribute(atts.getLocalName(i), atts.getValue(i));
+            }
+        }
 
-    // This determines the documents that meet the query conditions
-    self.append(query.printSQL(useXMLIndex));
+        elementStack.push(currentNode);
+        if (currentNode.getTagName().equals("querygroup")) {
+            QueryGroup currentGroup = new QueryGroup(currentNode
+                    .getAttribute("operator"));
+            if (query == null) {
+                query = currentGroup;
+            } else {
+                QueryGroup parentGroup = (QueryGroup) queryStack.peek();
+                parentGroup.addChild(currentGroup);
+            }
+            queryStack.push(currentGroup);
+        }
+    }
 
-    self.append(") ");
- 
-    // Add SQL to filter for doctypes requested in the query
-    // This is an implicit OR for the list of doctypes. Only doctypes in this
-    // list will be searched if the tag is present
-    if (!filterDocList.isEmpty()) {
-      boolean firstdoctype = true;
-      self.append(" AND ("); 
-      Enumeration en = filterDocList.elements();
-      while (en.hasMoreElements()) {
-        String currentDoctype = (String)en.nextElement();
-        if (firstdoctype) {
-           firstdoctype = false;
-           self.append(" doctype = '" + currentDoctype + "'"); 
-        } else {
-          self.append(" OR doctype = '" + currentDoctype + "'"); 
+    /**
+     * callback method used by the SAX Parser when the end tag of an element is
+     * detected. Used in this context to parse and store the query information
+     * in class variables.
+     */
+    public void endElement(String uri, String localName, String qName)
+            throws SAXException
+    {
+        BasicNode leaving = (BasicNode) elementStack.pop();
+        if (leaving.getTagName().equals("queryterm")) {
+            boolean isCaseSensitive = (new Boolean(leaving
+                    .getAttribute("casesensitive"))).booleanValue();
+            QueryTerm currentTerm = null;
+            if (currentPathexpr == null) {
+                currentTerm = new QueryTerm(isCaseSensitive, leaving
+                        .getAttribute("searchmode"), currentValue);
+            } else {
+                currentTerm = new QueryTerm(isCaseSensitive, leaving
+                        .getAttribute("searchmode"), currentValue,
+                        currentPathexpr);
+            }
+            QueryGroup currentGroup = (QueryGroup) queryStack.peek();
+            currentGroup.addChild(currentTerm);
+            currentValue = null;
+            currentPathexpr = null;
+        } else if (leaving.getTagName().equals("querygroup")) {
+            QueryGroup leavingGroup = (QueryGroup) queryStack.pop();
         }
-      }
-      self.append(") ");
     }
 
-    // Add SQL to filter for owners requested in the query
-    // This is an implicit OR for the list of owners
-    if (!ownerList.isEmpty()) {
-      boolean first = true;
-      self.append(" AND ("); 
-      Enumeration en = ownerList.elements();
-      while (en.hasMoreElements()) {
-        String current = (String)en.nextElement();
-        if (current != null)
-        {
-          current = current.toLowerCase();
+    /**
+     * callback method used by the SAX Parser when the text sequences of an xml
+     * stream are detected. Used in this context to parse and store the query
+     * information in class variables.
+     */
+    public void characters(char ch[], int start, int length)
+    {
+
+        String inputString = new String(ch, start, length);
+        BasicNode currentNode = (BasicNode) elementStack.peek();
+        String currentTag = currentNode.getTagName();
+        if (currentTag.equals("meta_file_id")) {
+            meta_file_id = inputString;
+        } else if (currentTag.equals("querytitle")) {
+            queryTitle = inputString;
+        } else if (currentTag.equals("value")) {
+            currentValue = inputString;
+        } else if (currentTag.equals("pathexpr")) {
+            currentPathexpr = inputString;
+        } else if (currentTag.equals("returndoctype")) {
+            returnDocList.add(inputString);
+        } else if (currentTag.equals("filterdoctype")) {
+            filterDocList.add(inputString);
+        } else if (currentTag.equals("returnfield")) {
+            handleReturnField(inputString);
+        } else if (currentTag.equals("filterdoctype")) {
+            filterDocList.add(inputString);
+        } else if (currentTag.equals("owner")) {
+            ownerList.add(inputString);
+        } else if (currentTag.equals("site")) {
+            siteList.add(inputString);
         }
-        if (first) {
-           first = false;
-           self.append(" lower(user_owner) = '" + current + "'"); 
+    }
+
+    /**
+     * Method to transfer string to return field
+     */
+    public void handleReturnField(String inputString)
+    {
+        // make sure if return fields has an attribute or not
+        if (inputString.indexOf(ATTRIBUTESYMBOL) == -1) {
+            // no attribute value will be returned
+            returnFieldList.add(inputString);
+            containsExtendedSQL = true;
         } else {
-          self.append(" OR lower(user_owner) = '" + current + "'"); 
+            // has a attribute return field
+            // divied the return filed into two parts, one is path and the
+            // other is attribue name
+            String returnPath = newPathExpressionWithOutAttribute(inputString);
+            String attributeName = getAttributeName(inputString);
+            Vector pathInfo = new Vector();
+            // the vector has the information about return path and
+            // attributename
+            pathInfo.addElement(returnPath);
+            pathInfo.addElement(attributeName);
+            // put the vector into a hash table. The reseaon why don't put
+            // return path or attributename as a key is because they are not
+            // unique
+            attributeReturnList.put(new Integer(countAttributeReturnField),
+                    pathInfo);
+            countAttributeReturnField++;
+            hasAttributeReturnField = true;
+            containsExtendedSQL = true;
+
         }
-      }
-      self.append(") ");
     }
 
-    // Add SQL to filter for sites requested in the query
-    // This is an implicit OR for the list of sites
-    if (!siteList.isEmpty()) {
-      boolean first = true;
-      self.append(" AND ("); 
-      Enumeration en = siteList.elements();
-      while (en.hasMoreElements()) {
-        String current = (String)en.nextElement();
-        if (first) {
-           first = false;
-           self.append(" SUBSTR(docid, 1, INSTR(docid, '" +
-               accNumberSeparator + "')-1) = '" + current + "'"); 
-        } else {
-          self.append(" OR SUBSTR(docid, 1, INSTR(docid, '" +
-               accNumberSeparator + "')-1) = '" + current + "'"); 
+    /**
+     * create a SQL serialization of the query that this instance represents
+     */
+    public String printSQL(boolean useXMLIndex)
+    {
+
+        StringBuffer self = new StringBuffer();
+
+        self.append("SELECT docid,docname,doctype,");
+        self.append("date_created, date_updated, rev ");
+        self.append("FROM xml_documents WHERE docid IN (");
+
+        // This determines the documents that meet the query conditions
+        self.append(query.printSQL(useXMLIndex));
+
+        self.append(") ");
+
+        // Add SQL to filter for doctypes requested in the query
+        // This is an implicit OR for the list of doctypes. Only doctypes in
+        // this
+        // list will be searched if the tag is present
+        if (!filterDocList.isEmpty()) {
+            boolean firstdoctype = true;
+            self.append(" AND (");
+            Enumeration en = filterDocList.elements();
+            while (en.hasMoreElements()) {
+                String currentDoctype = (String) en.nextElement();
+                if (firstdoctype) {
+                    firstdoctype = false;
+                    self.append(" doctype = '" + currentDoctype + "'");
+                } else {
+                    self.append(" OR doctype = '" + currentDoctype + "'");
+                }
+            }
+            self.append(") ");
         }
-      }
-      self.append(") ");
+
+        // Add SQL to filter for owners requested in the query
+        // This is an implicit OR for the list of owners
+        if (!ownerList.isEmpty()) {
+            boolean first = true;
+            self.append(" AND (");
+            Enumeration en = ownerList.elements();
+            while (en.hasMoreElements()) {
+                String current = (String) en.nextElement();
+                if (current != null) {
+                    current = current.toLowerCase();
+                }
+                if (first) {
+                    first = false;
+                    self.append(" lower(user_owner) = '" + current + "'");
+                } else {
+                    self.append(" OR lower(user_owner) = '" + current + "'");
+                }
+            }
+            self.append(") ");
+        }
+
+        // Add SQL to filter for sites requested in the query
+        // This is an implicit OR for the list of sites
+        if (!siteList.isEmpty()) {
+            boolean first = true;
+            self.append(" AND (");
+            Enumeration en = siteList.elements();
+            while (en.hasMoreElements()) {
+                String current = (String) en.nextElement();
+                if (first) {
+                    first = false;
+                    self.append(" SUBSTR(docid, 1, INSTR(docid, '"
+                            + accNumberSeparator + "')-1) = '" + current + "'");
+                } else {
+                    self.append(" OR SUBSTR(docid, 1, INSTR(docid, '"
+                            + accNumberSeparator + "')-1) = '" + current + "'");
+                }
+            }
+            self.append(") ");
+        }
+
+        // if there is only one percentage search item, this query is a
+        // percentage
+        // search query
+        MetaCatUtil.debugMessage("percentage number: "
+                + query.getPercentageSymbolCount(), 35);
+        if (query.getPercentageSymbolCount() == 1) {
+            MetaCatUtil.debugMessage("it is a percentage search", 30);
+            percentageSearch = true;
+        }
+
+        return self.toString();
     }
-    
-    // if there is only one percentage search item, this query is a percentage
-    // search query
-    MetaCatUtil.debugMessage("percentage number: " + 
-                                         query.getPercentageSymbolCount(), 35); 
-    if (query.getPercentageSymbolCount() ==1 )
+
+    /**
+     * This sql command will selecet startnodeid and endnodeid that user can
+     * NOT access
+     */
+    public String printAccessControlSQLForReturnField(String doclist)
     {
-      MetaCatUtil.debugMessage("it is a percentage search", 30);
-      percentageSearch =true;
+        StringBuffer sql = new StringBuffer();
+        String allowString = constructAllowString();
+        String denyString = constructDenyString();
+        sql.append("SELECT distinct startnodeid, endnodeid from xml_access ");
+        sql.append("WHERE docid in (");
+        sql.append(doclist);
+        sql.append(") AND startnodeid IS NOT NULL AND ");
+        sql.append("(");
+        sql.append("(");
+        sql.append("startnodeid NOT IN (SELECT startnodeid from xml_access, xml_documents ");
+        sql.append(" WHERE xml_access.docid = xml_documents.docid");
+        sql.append(" AND lower(xml_documents.user_owner) ='");
+        sql.append(userName);
+        sql.append("' AND xml_access.startnodeid IS NOT NULL)");
+        sql.append(")");
+        sql.append(" AND ");
+        sql.append("(");
+        sql.append("(startnodeid NOT IN (SELECT startnodeid from xml_access where( ");
+        sql.append(allowString);
+        sql.append(") AND (startnodeid IS NOT NULL))");
+        sql.append(")");
+        sql.append(" OR (startnodeid IN (SELECT startnodeid from xml_access where( ");
+        sql.append(denyString);
+        sql.append(") AND (startnodeid IS NOT NULL))");
+        sql.append(")");
+        sql.append(")");
+        sql.append(")");
+        MetaCatUtil.debugMessage("accessControlSQLForReturnField: "
+                + sql.toString(), 30);
+        return sql.toString();
     }
-    
-    return self.toString();
-  }
-  
-  /** This sql command will selecet startnodeid and endnodeid that user can NOT
-    * access
-    */
-  public String printAccessControlSQLForReturnField(String doclist)
-  {
-    StringBuffer sql = new StringBuffer();
-    String allowString = constructAllowString();
-    String denyString = constructDenyString();
-    sql.append("SELECT distinct startnodeid, endnodeid from xml_access ");
-    sql.append("WHERE docid in (");
-    sql.append(doclist);
-    sql.append(") AND startnodeid IS NOT NULL AND ");
-    sql.append("(");
-    sql.append("(");
-    sql.append("startnodeid NOT IN (SELECT startnodeid from xml_access, xml_documents ");
-    sql.append(" WHERE xml_access.docid = xml_documents.docid");
-    sql.append(" AND lower(xml_documents.user_owner) ='");
-    sql.append(userName);
-    sql.append("' AND xml_access.startnodeid IS NOT NULL)"); 
-    sql.append(")");
-    sql.append(" AND ");
-    sql.append("(");
-    sql.append("(startnodeid NOT IN (SELECT startnodeid from xml_access where( ");
-    sql.append(allowString);
-    sql.append(") AND (startnodeid IS NOT NULL))");
-    sql.append(")");
-    sql.append(" OR (startnodeid IN (SELECT startnodeid from xml_access where( ");
-    sql.append(denyString);
-    sql.append(") AND (startnodeid IS NOT NULL))");
-    sql.append(")");
-    sql.append(")");
-    sql.append(")");
-    MetaCatUtil.debugMessage("accessControlSQLForReturnField: " +
-                             sql.toString(), 30);
-    return sql.toString();
-  }
-  
-  /**
-   * This method prints sql based upon the &lt;returnfield&gt; tag in the
-   * pathquery document.  This allows for customization of the 
-   * returned fields
-   * @param doclist the list of document ids to search by
-   * @param unaccessableNodePair  the node pair(start id and end id) which this
-   *                               user could not access it
-   */
-  public String printExtendedSQL(String doclist, Hashtable unaccessableNodePair)
-  {  
-    StringBuffer self = new StringBuffer();
-    self.append("select xml_nodes.docid, xml_index.path, xml_nodes.nodedata, ");
-    self.append("xml_nodes.parentnodeid ");
-    self.append("from xml_index, xml_nodes where xml_index.nodeid=");
-    self.append("xml_nodes.parentnodeid and (xml_index.path like '");
-    boolean firstfield = true;
-    //put the returnfields into the query
-    //the for loop allows for multiple fields
-    for(int i=0; i<returnFieldList.size(); i++)
+
+    /**
+     * This method prints sql based upon the &lt;returnfield&gt; tag in the
+     * pathquery document. This allows for customization of the returned fields
+     * 
+     * @param doclist
+     *            the list of document ids to search by
+     * @param unaccessableNodePair
+     *            the node pair(start id and end id) which this user could not
+     *            access it
+     */
+    public String printExtendedSQL(String doclist,
+            Hashtable unaccessableNodePair)
     {
-      if(firstfield)
-      {
-        firstfield = false;
-        self.append((String)returnFieldList.elementAt(i));
-        self.append("' ");
-      }
-      else
-      {
-        self.append("or xml_index.path like '");
-        self.append((String)returnFieldList.elementAt(i));
-        self.append("' ");
-      }
+        StringBuffer self = new StringBuffer();
+        self
+                .append("select xml_nodes.docid, xml_index.path, xml_nodes.nodedata, ");
+        self.append("xml_nodes.parentnodeid ");
+        self.append("from xml_index, xml_nodes where xml_index.nodeid=");
+        self.append("xml_nodes.parentnodeid and (xml_index.path like '");
+        boolean firstfield = true;
+        //put the returnfields into the query
+        //the for loop allows for multiple fields
+        for (int i = 0; i < returnFieldList.size(); i++) {
+            if (firstfield) {
+                firstfield = false;
+                self.append((String) returnFieldList.elementAt(i));
+                self.append("' ");
+            } else {
+                self.append("or xml_index.path like '");
+                self.append((String) returnFieldList.elementAt(i));
+                self.append("' ");
+            }
+        }
+        self.append(") AND xml_nodes.docid in (");
+        //self.append(query.printSQL());
+        self.append(doclist);
+        self.append(")");
+        self.append(" AND xml_nodes.nodetype = 'TEXT'");
+
+        // add control part for extended query
+        Enumeration en = unaccessableNodePair.keys();
+
+        while (en.hasMoreElements()) {
+            // Get control pairs in object
+            Long startNodeIdObject = (Long) en.nextElement();
+            Long endNodeIdObject = (Long) unaccessableNodePair
+                    .get(startNodeIdObject);
+            // change it to long
+            long startNodeId = startNodeIdObject.longValue();
+            long endNodeId = endNodeIdObject.longValue();
+            // add into query
+            self.append(" AND( xml_nodes.nodeid < ");
+            self.append(startNodeId);
+            self.append(" OR xml_nodes.nodeid > ");
+            self.append(endNodeId);
+            self.append(")");
+        }
+
+        return self.toString();
     }
-    self.append(") AND xml_nodes.docid in (");
-    //self.append(query.printSQL());
-    self.append(doclist);
-    self.append(")");
-    self.append(" AND xml_nodes.nodetype = 'TEXT'");
-    
-    // add control part for extended query
-    Enumeration en = unaccessableNodePair.keys();
-    
-    while (en.hasMoreElements())
+
+    /**
+     * This method prints sql based upon the returnfield tag in the pathquery
+     * document has an attribute. This allows for customization of the returned
+     * fields
+     * 
+     * @param doclist
+     *            the list of document ids to search by
+     */
+    public String printAttributeQuery(String doclist)
     {
-      // Get control pairs in object
-      Long startNodeIdObject = (Long)en.nextElement();
-      Long endNodeIdObject = (Long)unaccessableNodePair.get(startNodeIdObject);
-      // change it to long
-      long startNodeId = startNodeIdObject.longValue();
-      long endNodeId   = endNodeIdObject.longValue();
-      // add into query
-      self.append(" AND( xml_nodes.nodeid < ");
-      self.append(startNodeId);
-      self.append(" OR xml_nodes.nodeid > ");
-      self.append(endNodeId);
-      self.append(")");
+        StringBuffer self = new StringBuffer();
+        self.append("select xml_nodes.docid, xml_index.path, ");
+        self.append("xml_nodes.nodedata, xml_nodes.nodename ");
+        self.append("from xml_index, xml_nodes where xml_index.nodeid=");
+        self.append("xml_nodes.parentnodeid and (");
+        boolean firstfield = true;
+        //put the returnfields attributes into the query
+        //the for loop allows for multiple fields and attributes
+        Enumeration returnAttributes = attributeReturnList.elements();
+        while (returnAttributes.hasMoreElements()) {
+            Vector currentVector = (Vector) returnAttributes.nextElement();
+            String returnPath = (String) currentVector.elementAt(0);
+            String attributeName = (String) currentVector.elementAt(1);
+            if (firstfield) {
+                firstfield = false;
+                self.append("( xml_index.path like '");
+                self.append(returnPath);
+                self.append("' AND xml_nodes.nodename like '");
+                self.append(attributeName);
+                self.append("') ");
+            } else {
+                self.append(" or ( xml_index.path like '");
+                self.append(returnPath);
+                self.append("' AND xml_nodes.nodename like '");
+                self.append(attributeName);
+                self.append("') ");
+            }
+        }
+        self.append(") AND xml_nodes.docid in (");
+        //self.append(query.printSQL());
+        self.append(doclist);
+        self.append(")");
+        self.append(" AND xml_nodes.nodetype = 'ATTRIBUTE'");
+        MetaCatUtil.debugMessage("Attribute query: " + self.toString(), 30);
+
+        return self.toString();
     }
 
-   
-    return self.toString();
-  }
-  
-  /**
-   * This method prints sql based upon the returnfield tag in the
-   * pathquery document has an attribute.  This allows for customization of the 
-   * returned fields
-   * @param doclist the list of document ids to search by
-   */
-  public String printAttributeQuery(String doclist)
-  {
-    StringBuffer self = new StringBuffer();
-    self.append("select xml_nodes.docid, xml_index.path, ");
-    self.append("xml_nodes.nodedata, xml_nodes.nodename ");
-    self.append("from xml_index, xml_nodes where xml_index.nodeid=");
-    self.append("xml_nodes.parentnodeid and (");
-    boolean firstfield = true;
-    //put the returnfields attributes into the query
-    //the for loop allows for multiple fields and attributes
-    Enumeration returnAttributes = attributeReturnList.elements();
-    while (returnAttributes.hasMoreElements())
+    public static String printRelationSQL(String docid)
     {
-      Vector currentVector = (Vector)returnAttributes.nextElement();
-      String returnPath = (String)currentVector.elementAt(0);
-      String attributeName = (String)currentVector.elementAt(1);
-      if(firstfield)
-      {
-        firstfield = false;
-        self.append("( xml_index.path like '");
-        self.append(returnPath);
-        self.append("' AND xml_nodes.nodename like '");
-        self.append(attributeName);
-        self.append("') ");
-      }
-      else
-      {
-        self.append(" or ( xml_index.path like '");
-        self.append(returnPath);
-        self.append("' AND xml_nodes.nodename like '");
-        self.append(attributeName);
-        self.append("') "); 
-      }
+        StringBuffer self = new StringBuffer();
+        self.append("select subject, relationship, object, subdoctype, ");
+        self.append("objdoctype from xml_relation ");
+        self.append("where docid like '").append(docid).append("'");
+        return self.toString();
     }
-    self.append(") AND xml_nodes.docid in (");
-    //self.append(query.printSQL());
-    self.append(doclist);
-    self.append(")");
-    self.append(" AND xml_nodes.nodetype = 'ATTRIBUTE'");
-    MetaCatUtil.debugMessage("Attribute query: "+self.toString(), 30);
-   
-    return self.toString();
-  }
-  
-  public static String printRelationSQL(String docid)
-  {
-    StringBuffer self = new StringBuffer();
-    self.append("select subject, relationship, object, subdoctype, ");
-    self.append("objdoctype from xml_relation ");
-    self.append("where docid like '").append(docid).append("'");
-    return self.toString();
-  }
 
-  public static String printGetDocByDoctypeSQL(String docid)
-  {
-    StringBuffer self = new StringBuffer();
+    public static String printGetDocByDoctypeSQL(String docid)
+    {
+        StringBuffer self = new StringBuffer();
 
-    self.append("SELECT docid,docname,doctype,");
-    self.append("date_created, date_updated ");
-    self.append("FROM xml_documents WHERE docid IN (");
-    self.append(docid).append(")");
-    return self.toString();
-  }
-  
-  /**
-   * create a String description of the query that this instance represents.
-   * This should become a way to get the XML serialization of the query.
-   */
-  public String toString() {
-    return "meta_file_id=" + meta_file_id + "\n" + query;
-//DOCTITLE attr cleared from the db
-//    return "meta_file_id=" + meta_file_id + "\n" + 
-//           "querytitle=" + querytitle + "\n" + query;
-  }
-  
-  /* A method to get rid of attribute part in path expression*/
-  public static String newPathExpressionWithOutAttribute(String pathExpression)
-  {
-      if (pathExpression == null)
-      {
-        return null;
-      }
-      int index = pathExpression.lastIndexOf(ATTRIBUTESYMBOL);
-      String newExpression = null;
-      if (index != 1)
-      {
-        newExpression=pathExpression.substring(0, index-1);
-      } 
-      MetaCatUtil.debugMessage("The path expression without attributes: " + 
-                               newExpression, 30);
-      return newExpression;
-  }
-    
-  /* A method to get attribute name from path */
-  public static String getAttributeName(String path)
-  {
-      if (path == null)
-      {
-        return null;
-      }
-      int index = path.lastIndexOf(ATTRIBUTESYMBOL);
-      int size = path.length();
-      String attributeName = null;
-       if (index != 1)
-      {
-        attributeName = path.substring(index+1, size);
-      } 
-      MetaCatUtil.debugMessage("The attirbute name from path: " + 
-                               attributeName, 30);
-      return attributeName;
-  }
+        self.append("SELECT docid,docname,doctype,");
+        self.append("date_created, date_updated ");
+        self.append("FROM xml_documents WHERE docid IN (");
+        self.append(docid).append(")");
+        return self.toString();
+    }
 
- 
+    /**
+     * create a String description of the query that this instance represents.
+     * This should become a way to get the XML serialization of the query.
+     */
+    public String toString()
+    {
+        return "meta_file_id=" + meta_file_id + "\n" + query;
+        //DOCTITLE attr cleared from the db
+        //return "meta_file_id=" + meta_file_id + "\n" +
+        //"querytitle=" + querytitle + "\n" + query;
+    }
+
+    /* A method to get rid of attribute part in path expression */
+    public static String newPathExpressionWithOutAttribute(String pathExpression)
+    {
+        if (pathExpression == null) { return null; }
+        int index = pathExpression.lastIndexOf(ATTRIBUTESYMBOL);
+        String newExpression = null;
+        if (index != 1) {
+            newExpression = pathExpression.substring(0, index - 1);
+        }
+        MetaCatUtil.debugMessage("The path expression without attributes: "
+                + newExpression, 30);
+        return newExpression;
+    }
+
+    /* A method to get attribute name from path */
+    public static String getAttributeName(String path)
+    {
+        if (path == null) { return null; }
+        int index = path.lastIndexOf(ATTRIBUTESYMBOL);
+        int size = path.length();
+        String attributeName = null;
+        if (index != 1) {
+            attributeName = path.substring(index + 1, size);
+        }
+        MetaCatUtil.debugMessage("The attirbute name from path: "
+                + attributeName, 30);
+        return attributeName;
+    }
+
 }
Index: src/edu/ucsb/nceas/metacat/MetaCatServlet.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 2066)
+++ src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 2067)
@@ -431,10 +431,6 @@
         PrintWriter out = response.getWriter();
         handleGetDTDSchemaAction(out, params, response);
         out.close();
-      } else if (action.equals("getdataguide")) {
-        PrintWriter out = response.getWriter();
-        handleGetDataGuideAction(out, params, response);
-        out.close();
       } else if (action.equals("getlastdocid")) {
         PrintWriter out = response.getWriter();
         handleGetMaxDocidAction(out, params, response);
@@ -2221,39 +2217,6 @@
   }
 
   /**
-   * Handle the "getdataguide" action.
-   * Read Data Guide for a given doctype from db connection in XML format
-   */
-  private void handleGetDataGuideAction(PrintWriter out, Hashtable params,
-                                        HttpServletResponse response) {
-
-
-    String doctype = null;
-    String[] doctypeArr = (String[])params.get("doctype");
-
-    // get only the first doctype specified in the list of doctypes
-    // it could be done for all doctypes in that list
-    if (doctypeArr != null) {
-        doctype = ((String[])params.get("doctype"))[0];
-    }
-
-    try {
-
-
-        DBUtil dbutil = new DBUtil();
-        String dataguide = dbutil.readDataGuide(doctype);
-        out.println(dataguide);
-
-    } catch (Exception e) {
-      out.println("<?xml version=\"1.0\"?>");
-      out.println("<error>");
-      out.println(e.getMessage());
-      out.println("</error>");
-    }
-
-  }
-
-  /**
    * Handle the "getlastdocid" action.
    * Get the latest docid with rev number from db connection in XML format
    */
Index: src/edu/ucsb/nceas/metacat/DBUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBUtil.java	(revision 2066)
+++ src/edu/ucsb/nceas/metacat/DBUtil.java	(revision 2067)
@@ -67,7 +67,7 @@
      {
         System.err.println("Wrong number of arguments!!!");
         System.err.println(
-        "USAGE: java DBUtil <-dt | -ds [doctype] | -dg [doctype] | -dl user>");
+        "USAGE: java DBUtil <-dt | -ds [doctype] | -dl user>");
         return;
      } else {
         try {
@@ -81,11 +81,6 @@
           if ( args[0].equals("-dt") ) {
             String doctypes = dbutil.readDoctypes();
             System.out.println(doctypes);
-          } else if ( args[0].equals("-dg") ) {
-            String doctype = null;
-            if ( args.length == 2 ) { doctype = args[1]; }
-            String dataguide = dbutil.readDataGuide(doctype);
-            System.out.println(dataguide);
           } else if ( args[0].equals("-ds") ) {
             String doctype = null;
             if ( args.length == 2 ) { doctype = args[1]; }
@@ -245,70 +240,6 @@
   }
 
   /**
-   * read Data Guide for a given doctype from db connection in XML format
-   * select all distinct absolute paths from xml_index table
-   */
-  public String readDataGuide( String doctype )
-        throws SQLException  {
-
-    Vector dataguide = new Vector();
-    String path;
-    PreparedStatement pstmt = null;
-    DBConnection dbConn = null;
-    int serialNumber = -1;
-    
-    try {
-        dbConn=DBConnectionPool.
-                  getDBConnection("DBUtil.readDataGuide");
-        serialNumber=dbConn.getCheckOutSerialNumber();
-        
-        if ( doctype != null ) {
-            pstmt = dbConn.prepareStatement("SELECT distinct path, nodeid " + 
-                                          "FROM xml_index " +
-                                          "WHERE path LIKE '/%' " + 
-                                          "AND doctype LIKE ? " +
-                                          "ORDER BY nodeid");
-            pstmt.setString(1, doctype);
-        } else {
-            pstmt = 
-            dbConn.prepareStatement("SELECT distinct path, doctype, nodeid " + 
-                                          "FROM xml_index " +
-                                          "WHERE path LIKE '/%' " + 
-                                          "ORDER BY doctype, nodeid");
-        }
-
-        pstmt.execute();
-        ResultSet rs = pstmt.getResultSet();
-        boolean tableHasRows = rs.next();
-        while (tableHasRows) {
-            path = rs.getString(1);
-            if ( dataguide.indexOf(path) == -1 ) {
-                dataguide.addElement(path);
-            }    
-            tableHasRows = rs.next();
-        }
-      
-        pstmt.close();
-
-    } catch (SQLException e) {
-      throw new SQLException("DBUtil.readDataGuide(). " + e.getMessage());
-    }
-    finally
-    {
-      try
-      {
-        pstmt.close();
-      }//try
-      finally
-      {
-        DBConnectionPool.returnDBConnection(dbConn, serialNumber);
-      }//finally
-    }//finally
-
-    return formatToXML(dataguide);
-  }
-
-  /**
    * format the DataGuide ResultSet to XML
    */
   private String formatToXML(Vector resultset) {
