Index: /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java
===================================================================
--- /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java	(revision 6287)
+++ /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java	(revision 6288)
@@ -15,4 +15,5 @@
 public abstract class AbstractHierarchyNode
 {
+  String prefix;        // a basic prefix used in this hierarchy
   String descriptor;    // the textual descriptor used on screen or long-hand
   String name;          // the index number, letter assignment or other item
@@ -35,4 +36,5 @@
     this.name       = null;
     this.id         = null;
+    this.prefix     = null;
     this.childNodes = new ArrayList();
     this.childDocs  = new ArrayList();
@@ -41,8 +43,9 @@
   }
     
-  public AbstractHierarchyNode(String name, String id, String descriptor)
+  public AbstractHierarchyNode(String prefix, String name, String id, String descriptor)
   { this.descriptor = descriptor;
     this.name       = name;
     this.id         = id;
+    this.prefix     = prefix;
     this.childNodes = new ArrayList();
     this.childDocs  = new ArrayList();
@@ -96,5 +99,10 @@
 
   public String getParentId()
-  { int dotAt = this.id.lastIndexOf('.');
+  { 
+    if (this.id == null) {
+      return "";
+    }
+
+    int dotAt = this.id.lastIndexOf('.');
     if (dotAt < 0) {
       return "";
@@ -188,5 +196,5 @@
     select = new GS3SQLSelect("classifiers");
     select.addField("ClassifyRef");
-    GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ClassifyID", "=", this.id);
+    GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ClassifyID", "=", this.prefix+"."+this.id);
     GS3SQLWhere where = new GS3SQLWhere(whereItem);
     select.setWhere(where);
@@ -206,11 +214,17 @@
       else {
 	insert = new GS3SQLInsert("classifiers");
-	if (this.parent != null) {
-	  insert.addValue("ParentID", this.getParentId());
+
+	String parentId = this.getParentId();
+
+	if (parentId.length() > 0) {
+	  insert.addValue("ParentID", this.prefix+"."+this.getParentId());
 	}
+	else {
+	  insert.addValue("ParentID", this.prefix);
+	}
 
 	action = insert;
       }
-      action.addValue("ClassifyID", this.id);
+      action.addValue("ClassifyID", this.prefix+"."+this.id);
       action.addValue("Name", this.name);
       action.addValue("Description", this.descriptor);
@@ -246,5 +260,5 @@
 
       // delete child documents
-      GS3SQLDelete delete = new GS3SQLDelete("classifydocuments");
+      GS3SQLDelete delete = new GS3SQLDelete("classdocuments");
       delete.setWhere(where);
 
@@ -266,7 +280,9 @@
     while (iterator.hasNext()) {
       DocumentID docId = (DocumentID) iterator.next();
-      insert = new GS3SQLInsert("classifydocuments");
+      insert = new GS3SQLInsert("classdocuments");
       insert.addValue("ClassifyRef", Integer.toString(classifyRef), GS3SQLField.INTEGER_TYPE);
       insert.addValue("DocID", docId.toString());
+
+      connection.execute(insert.toString());
     }
     return true;
Index: /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/GS2HierarchyClassifier.java
===================================================================
--- /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/GS2HierarchyClassifier.java	(revision 6287)
+++ /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/GS2HierarchyClassifier.java	(revision 6288)
@@ -49,6 +49,6 @@
     }
     
-    public GS2HierarchyNode(String name, String id, String descriptor)
-    { super(name, id, descriptor);
+    public GS2HierarchyNode(String prefix, String name, String id, String descriptor)
+    { super(prefix, name, id, descriptor);
     }
     
@@ -97,4 +97,5 @@
  
       this.rootNode = new GS2HierarchyNode();
+      String prefix = "CL"+hierarchyName;
 
       while (this.hasMoreLines()) {
@@ -120,5 +121,5 @@
 	
 	// Initialise the tree
-	GS2HierarchyNode node = new GS2HierarchyNode(name, "CL"+hierarchyName+"."+id, description);
+	GS2HierarchyNode node = new GS2HierarchyNode(prefix, name, id, description);
 
 	this.rootNode.add(node);
@@ -224,5 +225,9 @@
    */
   public boolean classifyDocument(DocumentID documentID, DocumentInterface document)
-  { // the observer records the assignment of documents to classifications
+  { if (this.hierarchy == null) {
+      return true;
+    }
+    
+    // the observer records the assignment of documents to classifications
     GS2HierarchyClassifierObserver classifyObserver = new GS2HierarchyClassifierObserver(document);
 		
@@ -241,4 +246,11 @@
       }
 
+      System.out.println("Matching " + values.get(0).toString());
+
+      if (documentID == null) {
+	System.out.println("Bad documentID");
+	continue;
+      }
+
       // ...and send them to the classifier
       this.hierarchy.getClassifications(documentID, values, classifyObserver);
