Index: src/edu/ucsb/nceas/metacat/QuerySpecification.java
===================================================================
--- src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 401)
+++ src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 402)
@@ -29,7 +29,7 @@
 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.
@@ -36,10 +36,13 @@
  */
 public class QuerySpecification extends DefaultHandler {
  
+  private boolean containsExtendedSQL=false;
+ 
   // Query data structures
   private String meta_file_id;
   private String querytitle;
   private Vector doctypeList;
+  private Vector returnFieldList;
   private QueryGroup query = null;
 
   private Stack elementStack;
@@ -59,11 +62,12 @@
   public QuerySpecification( Reader queryspec, String parserName ) 
          throws IOException {
     super();
-
+    
     // Initialize the class variables
     doctypeList = new Vector();
     elementStack = new Stack();
     queryStack   = new Stack();
+    returnFieldList = new Vector();
     this.parserName = parserName;
 
     // Initialize the parser and read the queryspec
@@ -115,6 +119,31 @@
          
      }
   }
+  
+  /**
+   * 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;
+    }
+  }
+  
+  /**
+   * 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 up the SAX parser for reading the XML serialized query
@@ -221,6 +250,9 @@
       currentPathexpr = inputString;
     } else if (currentTag.equals("returndoctype")) {
       doctypeList.add(inputString);
+    } else if (currentTag.equals("returnfield")) {
+      returnFieldList.add(inputString);
+      containsExtendedSQL = true;
     }
   }
 
@@ -231,8 +263,8 @@
   public String printSQL() {
     StringBuffer self = new StringBuffer();
 
-    // This determines the returned results
-    self.append("SELECT docid,docname,doctype,doctitle ");
+    self.append("SELECT docid,docname,doctype,doctitle,");
+    self.append("date_created, date_updated ");
     self.append("FROM xml_documents WHERE docid IN (");
 
     // This determines the documents that meet the query conditions
@@ -239,7 +271,7 @@
     self.append(query.printSQL());
 
     self.append(") ");
-
+ 
     // Add SQL to filter for doctypes requested in the query
     if (!doctypeList.isEmpty()) {
       boolean firstdoctype = true;
@@ -248,8 +280,8 @@
       while (en.hasMoreElements()) {
         String currentDoctype = (String)en.nextElement();
         if (firstdoctype) {
-          firstdoctype = false;
-          self.append(" doctype = '" + currentDoctype + "'"); 
+           firstdoctype = false;
+           self.append(" doctype = '" + currentDoctype + "'"); 
         } else {
           self.append(" OR doctype = '" + currentDoctype + "'"); 
         }
@@ -256,9 +288,51 @@
       }
       self.append(") ");
     }
-
+    
     return self.toString();
   }
+  
+  /**
+   * This method prints sql based upon the &lt;returnfield&gt; tag in the
+   * pathquery document.  This allows for customization of the 
+   * returned fields
+   * The parameters of the query are changed to upper case before the query
+   * so that givenName is queryied the same as givenname.
+   */
+  public String printExtendedSQL()
+  {  
+    StringBuffer self = new StringBuffer();
+    self.append("select A.docid, A.nodename, B.nodedata from xml_nodes A, ");
+    self.append("xml_nodes B where A.nodeid = B.parentnodeid ");
+    self.append("and B.nodeid in ");
+    self.append("(select distinct nodeid from xml_nodes where parentnodeid in ");
+    self.append("(select nodeid from xml_index where UPPER(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)).toUpperCase());
+        self.append("' ");
+      }
+      else
+      {
+        self.append("or UPPER(path) like '");
+        self.append(((String)returnFieldList.elementAt(i)).toUpperCase());
+        self.append("' ");
+      }
+    }
+    self.append("))");
+    self.append(" AND B.docid in (");
+    self.append(query.printSQL());
+    self.append(")");
+    self.append(" AND B.nodetype = 'TEXT'");
+    
+    return self.toString();
+  }
 
   /**
    * create a String description of the query that this instance represents.
@@ -483,6 +557,10 @@
 
 /**
  * '$Log$
+ * 'Revision 1.11  2000/08/14 20:53:34  jones
+ * 'Added "release" keyword to all metacat source files so that the release
+ * 'number will be evident in software distributions.
+ * '
  * 'Revision 1.10  2000/06/26 10:35:05  jones
  * 'Merged in substantial changes to DBWriter and associated classes and to
  * 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE
