Index: /trunk/gsdl3/bin/script/convert_coll_from_gs2.pl
===================================================================
--- /trunk/gsdl3/bin/script/convert_coll_from_gs2.pl	(revision 3871)
+++ /trunk/gsdl3/bin/script/convert_coll_from_gs2.pl	(revision 3872)
@@ -23,4 +23,6 @@
     print STDOUT "Usage: convert_coll_from_gs2.pl [options] coll-name\n";
     print STDOUT "options:\n";
+    
+    print STDOUT "   -collectdir         Directory where collection lives.\n";
     
 }
@@ -51,4 +53,12 @@
 
     }
+    $xmlcollconfigfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");
+    my $xmlcollectcfg;
+    if (-e $collconfigfilename) {
+	$collectcfg = &colcfg::read_collect_cfg ($collconfigfilename);
+
+    }
+    
+
     $buildconfigfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "building", "build.cfg");
     my $buildcfg;
@@ -75,37 +85,14 @@
 
     $writer->startTag('buildConfig');
- 
-    if (defined $collectcfg->{'collectionmeta'}) {
-	my $collmeta = $collectcfg->{'collectionmeta'};
-	$writer->startTag('metadataList');
-	#just do collname for now
-	my $collnames = $collmeta->{'collectionname'};
-	foreach $lang (keys %$collnames) {
-	    my $short_lang;
-	    if ($lang eq 'default') {
-		$short_lang = 'en';
-	    } else {
-	        ($short_lang) = $lang =~ /^\[l=(..)\]/;
-	    }
-	    $writer->startTag('metadata', 'lang'=>$short_lang, 'name'=>'collName');
-	    $writer->characters($collnames->{$lang});
-	    $writer->endTag('metadata');
-	}
-	my $collabouts = $collmeta->{'collectionextra'};
-	foreach $lang (keys %$collabouts) {
-	    my $short_lang;
-	    if ($lang eq 'default') {
-		$short_lang = 'en';
-	    } else {
-	        ($short_lang) = $lang =~ /^\[l=(..)\]/;
-	    }
-	    $writer->startTag('metadata', 'lang'=>$short_lang, 'name'=>'collDescript');
-	    $writer->characters($collabouts->{$lang});
-	    $writer->endTag('metadata');
-	}
-	$writer->endTag('metadataList');
-    }
-
-	
+
+#num docs
+    my $numdocs = $buildcfg->{'numdocs'};
+    $writer->startTag('metadataList');
+    $writer->startTag('metadata',  'name'=>'numDocs');
+    $writer->characters($numdocs);
+    $writer->endTag('metadata');
+    $writer->endTag('metadataList');
+    
+    
     #indexes
     my $indexmap = {};
@@ -156,4 +143,23 @@
 	    
             #fieldlist
+	    print STDOUT "trying fields\n";
+	    my $fieldmap = {};
+	    if (defined $buildcfg->{'indexfieldmap'}) {
+		print STDOUT "doing fields\n";
+		$fieldmap_t = $buildcfg->{'indexfieldmap'};
+		foreach $f (@$fieldmap_t) {
+		    my ($k, $v) = $f =~ /^(.*)\-\>(.*)$/;
+		    $fieldmap->{$k} = $v;
+		}
+		
+		$writer->startTag('fieldList');
+		foreach $f (keys %$fieldmap) {
+		    $field = $fieldmap->{$f};
+		    $writer->emptyTag('field', 'shortname'=>$field, 'name'=>$f);
+		}	
+		$writer->endTag('fieldList');
+	    } else {
+		print STDERR "indexfieldmap not defined";
+	    }
 	    
 	} elsif ($buildtype eq 'mg') {
@@ -198,26 +204,15 @@
 		$started_classifiers = 1;
 	    }
-	    my $title = ''; #use buttonname if defined, otherwise use metadata
+	    my $content = ''; #use metadata
 	    
 	    for ($i=0; $i<scalar(@$cl); $i++) {
 		$arg = @$cl[$i];
-		if ($arg eq "-buttonname") {
-		    $title = @$cl[$i+1];
+		if ($arg eq "-metadata") {
+		    $content = @$cl[$i+1];
 		    last;
 		}
-		if ($arg eq "-metadata") {
-		    $title = @$cl[$i+1];
-		}
-	    }
-
-	    $writer->startTag('classifier', 'name'=>$name);
-	    $writer->startTag('metadataList');
-	    #title meta
-	    $writer->startTag('metadata', 'name'=>'Title');
-	    $writer->characters($title);
-	    $writer->endTag('metadata');
-	    $writer->endTag('metadataList');
-	    $writer->endTag('classifier');
-	    
+	    }
+
+	    $writer->emptyTag('classifier', 'name'=>$name, 'content'=>$content);
 	    
 	} #foreach classifier
Index: /trunk/gsdl3/bin/script/gs2_mkcol.pl
===================================================================
--- /trunk/gsdl3/bin/script/gs2_mkcol.pl	(revision 3871)
+++ /trunk/gsdl3/bin/script/gs2_mkcol.pl	(revision 3872)
@@ -125,5 +125,7 @@
 		$line =~ s/\*\*defaultindex\*\*/$defaultindex/g;
 		$line =~ s/\*\*indexmeta\*\*/$indexmeta/g;
-
+		$line =~ s/\*\*xmlindexes\*\*/$xmlindexes/g;
+		$line =~ s/\*\*xmlplugins\*\*/$xmlpluginstring/g;
+		
 		print OUTFILE $line;
 	    }
@@ -239,9 +241,12 @@
     # get the strings to include.
     $pluginstring = "";
+    $xmlpluginstring = "";
     foreach $plugin (@plugin) {
 	if ($plugin eq RecPlug) {
 	    $pluginstring .= "plugin         $plugin -use_metadata_files\n";
+	    $xmlpluginstring .= "<plugin name='$plugin'><option name='use_metadata_files'/></plugin>\n";
 	} else {
 	    $pluginstring .= "plugin         $plugin\n";
+	    $xmlpluginstring .= "<plugin name='$plugin'/>\n";
 	}
     }
@@ -269,4 +274,5 @@
 
     # set up the default indexes - this could be a command line option at some stage
+    # the names are added in here for the xml ones, but they should be added after building once the names are known.
     if ($buildtype eq "mg") {
 	$indexes = "document:text document:Title document:Source";
@@ -274,8 +280,10 @@
 	$indexmeta = "collectionmeta .document:text    \"text\"\ncollectionmeta .document:Title  \"titles\"\ncollectionmeta .document:Source  \"filenames\"\n";
 
+	$xmlindexes = "<index name='dtx' content='text' level='Document'><displayName lang='en'>text</displayName></index>\n<index name='dtt' content='Title' level='Document'><displayName lang='en'>titles</displayName></index>\n<index name='dsr' content='Source' level='Document'><displayName lang='en'>filenames</displayName></index>";
     } elsif ($buildtype eq "mgpp") {
 	$indexes = "text,metadata";
 	$defaultindex = "text,metadata";
 	$indexmeta = "collectionmeta .text,metadata    \"text\"\n";
+	$xmlindexes = "<index name='tm' content='text,metadata' level='Document'><displayName lang='en'>text</displayName></index>";
     } else {
 	print STDOUT "Error: buildtype should be mg or mgpp, but its $buildtype\n";
