Index: main/trunk/greenstone2/runtime-src/src/recpt/formatconverter.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/formatconverter.cpp	(revision 28998)
+++ main/trunk/greenstone2/runtime-src/src/recpt/formatconverter.cpp	(revision 29042)
@@ -46,4 +46,8 @@
 here" | ./formatconverter --silent
 ***********************************************************************/
+void print_usage() {
+  cout << endl << "Usage: formatconverter [options]" << endl;
+  cout << "\tOptions: --help, [--silent] [--documentNode|--classifierNode]" << endl << endl;
+}
 
 int main(int argc, char **argv) {
@@ -54,8 +58,25 @@
   text_t resultstring;
 
-  
+  text_t nodeType = "";
   bool silent = false;
+
   if(argc > 1) {
-    silent = (strcmp(argv[1], "--silent") == 0);
+
+    if((strcmp(argv[1], "--help") == 0)) {
+      print_usage();
+      return 0;
+    }
+
+    else {
+      for(int i = 1; i < argc; i++) {
+	if (strcmp(argv[i], "--silent") == 0) { silent = true; }
+	else if(strcmp(argv[i], "--documentNode") == 0) { nodeType = "document"; } 
+	else if(strcmp(argv[i], "--classifierNode") == 0) { nodeType = "classifier"; }
+	else { 
+	  print_usage(); 
+	  return 0;
+	}
+      }
+    }
   }
 
@@ -75,5 +96,5 @@
 
   parse_formatstring (argstr, formatlistptr, metadata, getParents);  
-  resultstring = get_GS3_formatstring (formatlistptr);
+  resultstring = get_GS3_formatstring (formatlistptr, nodeType);
 
   delete formatlistptr;
Index: main/trunk/greenstone2/runtime-src/src/recpt/formattools.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/formattools.cpp	(revision 28998)
+++ main/trunk/greenstone2/runtime-src/src/recpt/formattools.cpp	(revision 29042)
@@ -59,5 +59,5 @@
 			      ostream &logout);
 
-static text_t transform_to_GS3_format (format_t *formatlistptr);
+static text_t transform_to_GS3_format (format_t *formatlistptr, const text_t& nodeType);
 
 void metadata_t::clear() {
@@ -2154,5 +2154,5 @@
 }
 
-static text_t get_gs3_if (const decision_t &decision, format_t *ifptr, format_t *elseptr)
+static text_t get_gs3_if (const decision_t &decision, format_t *ifptr, format_t *elseptr, const text_t& nodeType)
 {
   text_t ifstmt ="<gsf:switch>";
@@ -2215,5 +2215,5 @@
   text_t if_body = "";
   while(ifptr != NULL) { // body of if can contain a list of items to be transformed into GS3 format stmts
-    if_body += transform_to_GS3_format (ifptr);
+    if_body += transform_to_GS3_format (ifptr, nodeType);
     ifptr = ifptr->nextptr;
   }
@@ -2227,5 +2227,5 @@
     text_t else_body = ""; // body of else can contain a list of items to be transformed into GS3 format stmts
     while(elseptr != NULL) {
-      else_body += transform_to_GS3_format (elseptr);
+      else_body += transform_to_GS3_format (elseptr, nodeType);
       elseptr = elseptr->nextptr;
     }
@@ -2239,9 +2239,9 @@
 
 
-static text_t get_gs3_or (format_t *orptr) {
+static text_t get_gs3_or (format_t *orptr, const text_t& nodeType) {
   text_t result = "<gsf:choose-metadata>";
 
   while(orptr != NULL) {
-    text_t or_body = transform_to_GS3_format (orptr);
+    text_t or_body = transform_to_GS3_format (orptr, nodeType);
     if (!or_body.empty()) {
       result += or_body;
@@ -2255,9 +2255,9 @@
 
 // what about all the <td>? Does that get stored in formatlistptr, such as under the ->text field?
-text_t get_GS3_formatstring (format_t *formatlistptr) {
+text_t get_GS3_formatstring (format_t *formatlistptr, const text_t& nodeType) {
   text_t result;
 
   while (formatlistptr != NULL) {
-    result += transform_to_GS3_format(formatlistptr);    
+    result += transform_to_GS3_format(formatlistptr, nodeType);    
     formatlistptr = formatlistptr->nextptr;
   }
@@ -2266,6 +2266,5 @@
 }
 
-text_t transform_to_GS3_format (format_t *formatlistptr) {
-
+text_t transform_to_GS3_format (format_t *formatlistptr, const text_t& nodeType) {
   if (formatlistptr == NULL) return "";
   
@@ -2280,5 +2279,9 @@
     return formatlistptr->text; // [text]? or any string that is not a command or reserved
   case comLink:
-    return "<gsf:link type='document'>"; // type?
+    if(nodeType == "classifier") {
+      return "<gsf:link type='classifier'>";
+    } else { // if nodeType is document or not set
+      return "<gsf:link type='document'>";
+    }
   case comEndLink:
     return "</gsf:link>";
@@ -2286,5 +2289,9 @@
     return "<gsf:lib name=\"href\"/>"; // ??? in gslib xsl, output comment marking not sure what this maps to
   case comIcon:
-    return "<gsf:icon type='document'/>";
+    if(nodeType == "classifier") {
+      return "<gsf:icon type='classifier'/>";
+    } else { // if nodeType is document or not set
+      return "<gsf:icon type='document'/>";
+    }
   case comNum:
     return "<gsf:lib name=\"num\"/>"; // ??? in gslib xsl, output comment marking not sure what this maps to
@@ -2335,8 +2342,27 @@
     break;
   case comIf:
-    return get_gs3_if (formatlistptr->decision, formatlistptr->ifptr, formatlistptr->elseptr);
+    if(formatlistptr->decision.meta.metaname == "numleafdocs") {
+      if(nodeType == "classifier") {
+	text_t if_body = "";
+	while(formatlistptr->ifptr != NULL) { // body of if can contain a list of items to be transformed into GS3 format stmts
+	  if_body += transform_to_GS3_format (formatlistptr->ifptr, nodeType);
+	  formatlistptr->ifptr = formatlistptr->ifptr->nextptr;
+	}
+	return if_body;
+      } else if(nodeType == "document") {
+	text_t else_body = ""; // body of else can contain a list of items to be transformed into GS3 format stmts
+	while(formatlistptr->elseptr != NULL) {
+	  else_body += transform_to_GS3_format (formatlistptr->elseptr, nodeType);
+	  formatlistptr->elseptr = formatlistptr->elseptr->nextptr;
+	}
+	return else_body;
+      }
+    }
+    
+    // if nodeType not specified as classifier or document, or if the If test is not for numleafdocs' existence
+    return get_gs3_if (formatlistptr->decision, formatlistptr->ifptr, formatlistptr->elseptr, nodeType);
   case comOr:
-    return get_gs3_or (formatlistptr->orptr);
-    //return "<gsf:choose-metadata>"+get_gs3_or (formatlistptr->orptr)+"</gsf:choose-metadata>";
+    return get_gs3_or (formatlistptr->orptr, nodeType);
+    //return "<gsf:choose-metadata>"+get_gs3_or (formatlistptr->orptr, nodeType)+"</gsf:choose-metadata>";
   case comDocTermsFreqTotal:
     return "<gsf:lib name=\"DocTermsFreqTotal\"/>";
Index: main/trunk/greenstone2/runtime-src/src/recpt/formattools.h
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/formattools.h	(revision 28998)
+++ main/trunk/greenstone2/runtime-src/src/recpt/formattools.h	(revision 29042)
@@ -148,5 +148,5 @@
 			     ostream& logout);
 
-text_t get_GS3_formatstring (format_t *formatlistptr);
+text_t get_GS3_formatstring (format_t *formatlistptr, const text_t& nodetype="");
 
 #endif
