Index: /gsdl/trunk/perllib/plugouts/FedoraMETSPlugout.pm
===================================================================
--- /gsdl/trunk/perllib/plugouts/FedoraMETSPlugout.pm	(revision 14927)
+++ /gsdl/trunk/perllib/plugouts/FedoraMETSPlugout.pm	(revision 14927)
@@ -0,0 +1,597 @@
+###########################################################################
+#
+# FedoraMETSPlugout.pm -- the plugout module for METS archives
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2006 New Zealand Digital Library Project
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+package FedoraMETSPlugout;
+
+use strict;
+no strict 'refs';
+
+#eval {require bytes};
+#use util;
+use METSPlugout;
+#use docprint; # for escape_text
+
+sub BEGIN {
+    @FedoraMETSPlugout::ISA = ('METSPlugout');
+}
+
+my $arguments = [ 
+      { 'name' => "fedora_namespace", 
+	'desc' => "{FedoraPlugout.fedora_namespace}",
+	'type' => "string",
+        'deft' =>  "greenstone",
+	'reqd' => "no",    
+	'hiddengli' => "no"}
+		  ];
+
+
+
+my $options = { 'name'     => "FedoraMETSPlugout",
+		'desc'     => "{FedoraMETSPlugout.desc}",
+		'abstract' => "no",
+		'inherits' => "yes", 
+	        'args'     => $arguments
+                };
+
+
+sub new 
+{
+    my ($class) = shift (@_);
+    my ($plugoutlist, $inputargs,$hashArgOptLists) = @_;
+    push(@$plugoutlist, $class);
+    
+    
+    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
+    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
+    
+    my $self = (defined $hashArgOptLists)? new METSPlugout($plugoutlist,$inputargs,$hashArgOptLists): new METSPlugout($plugoutlist,$inputargs); 
+    
+    
+    return bless $self, $class;
+}
+
+
+sub output_mets_xml_header
+{
+    my $self = shift(@_);
+    my ($handle, $OID, $doc_title) = @_;
+
+    my $fnamespace = $self->{'fedora_namespace'};
+    my $oid_namespace = (defined $fnamespace) ? $fnamespace : "test";
+
+    my $collection = $ENV{'GSDLCOLLECTION'};
+
+    my $extra_attr = "OBJID=\"$oid_namespace:$collection-$OID\" TYPE=\"FedoraObject\" LABEL=\"$doc_title\"";
+
+    $self->output_mets_xml_header_extra_attribute($handle,$extra_attr);
+
+    print $handle '<mets:metsHdr RECORDSTATUS="A"/>'. "\n"; # A = active
+
+}
+
+#
+#  Print out "family" of doctxt.xml files
+#
+
+sub saveas_doctxt_section
+{
+    my $self = shift (@_);
+    my ($doc_obj,$working_dir,$section) = @_;
+
+    my $section_ptr=$doc_obj->_lookup_section($section);
+    return unless defined $section_ptr;
+
+    my $section_fnum ="1". $section;
+    $section_fnum =~ s/\./_/g;
+
+    my $doc_txt_file = &util::filename_cat ($working_dir,"doctxt$section_fnum.xml");	
+	
+    $self->open_xslt_pipe($doc_txt_file,$self->{'xslt_txt'});
+
+    my $outhandler; 
+
+    if (defined $self->{'xslt_writer'}){
+	$outhandler = $self->{'xslt_writer'};
+    }
+    else{
+	$outhandler = $self->get_output_handler($doc_txt_file);
+    } 
+
+    $self->output_xml_header($outhandler);
+    $self->output_txt_section($outhandler,$doc_obj, $section);
+    $self->output_xml_footer($outhandler);
+    
+
+    if (defined $self->{'xslt_writer'}){     
+	$self->close_xslt_pipe(); 
+    }
+    else{
+	close($outhandler);
+    } 
+
+
+    # Output all the subsections as separate files
+    foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
+	
+	$self->saveas_doctxt_section($doc_obj, $working_dir, "$section.$subsection");
+    }
+
+
+}
+
+
+sub saveas_doctxt
+{
+    my $self = shift (@_);
+    my ($doc_obj,$working_dir) = @_;
+
+    my $section = $doc_obj->get_top_section();
+
+    $self->saveas_doctxt_section($doc_obj,$working_dir,$section);
+
+    $self->saveas_toc($doc_obj,$working_dir);
+}
+
+sub buffer_toc
+{
+    my $self = shift (@_);
+    my ($doc_obj,$working_dir,$section,$depth) = @_;
+    
+    my $section_ptr=$doc_obj->_lookup_section($section);
+    return "" unless defined $section_ptr;
+
+    my $all_text = "";
+
+    my $section_num ="1". $section;
+    my $indent = " " x ($depth*2);
+
+    $all_text .= "$indent<Section id=\"$section_num\">\n";
+
+    # Output all the subsections as separate files
+    foreach my $subsection (@{$section_ptr->{'subsection_order'}})
+    {
+	$all_text 
+	    .= $self->buffer_toc($doc_obj, $working_dir, 
+				 "$section.$subsection",$depth+1);
+    }
+
+    $all_text .= "$indent</Section>\n";
+
+    return $all_text;
+}
+
+
+sub saveas_toc
+{
+    my $self = shift (@_);
+    my ($doc_obj,$working_dir) = @_;
+
+    my $section = $doc_obj->get_top_section();
+
+    my $doc_txt_file = &util::filename_cat ($working_dir,"doctoc.xml");	
+	
+    $self->open_xslt_pipe($doc_txt_file,$self->{'xslt_txt'});
+
+    my $outhandler; 
+
+    if (defined $self->{'xslt_writer'}){
+	$outhandler = $self->{'xslt_writer'};
+    }
+    else{
+	$outhandler = $self->get_output_handler($doc_txt_file);
+    } 
+
+    print $outhandler $self->buffer_toc($doc_obj, $working_dir, $section, 0);
+
+    if (defined $self->{'xslt_writer'}){     
+	$self->close_xslt_pipe(); 
+    }
+    else{
+	close($outhandler);
+   } 
+
+}
+
+
+#
+#  Print out docmets.xml file
+#
+sub output_mets_section 
+{
+    my $self = shift(@_);
+    my ($handle, $doc_obj, $section, $working_dir) = @_;
+
+    # print out the dmdSection
+    print $handle $self->buffer_mets_dmdSection_section_xml($doc_obj,$section);
+
+    print $handle "<mets:fileSec>\n";
+    print $handle "  <mets:fileGrp ID=\"DATASTREAMS\">\n";
+
+    # Generate Filestream for Table of Contents (TOC)
+    print $handle $self->buffer_mets_fileSection_toc($doc_obj,$section,$working_dir);
+
+    # print out the fileSection by sections
+    print $handle $self->buffer_mets_fileSection_section_xml($doc_obj,$section,$working_dir);
+
+    # print out the whole fileSection
+    print $handle $self->buffer_mets_fileWhole_section_xml($doc_obj,$section,$working_dir); 
+
+    print $handle "  </mets:fileGrp>\n";
+    print $handle "</mets:fileSec>\n";
+  
+    # print out the StructMapSection by sections
+
+    my $struct_type = "fedora:dsBindingMap";
+
+    # If document is going to make use of deminators (BMech and BDef) then
+    # need to code up more output XML here (structMap)and in  
+    # METS:behaviorSec (Fedora extension?) sections
+  
+}
+
+sub buffer_mets_amdSec_header
+{
+    my $self = shift(@_);
+    my ($section,$id) = @_;
+
+    # convert section number
+    my $section_num ="1". $section;
+
+    my $all_text = "";
+
+    my $label_attr = "";
+
+    $all_text .= "<mets:amdSec ID=\"$id$section\" >\n";
+    $all_text .= "  <mets:techMD ID=\"$id$section.0\">\n"; # .0 fedora version number?
+    
+    $label_attr = "LABEL=\"Metadata\"";
+
+    $all_text .= "  <mets:mdWrap $label_attr MDTYPE=\"OTHER\" OTHERMDTYPE=\"gsdl3\" ID=\"".$id."gsdl$section_num\">\n";
+    $all_text .= "    <mets:xmlData>\n";
+
+    return $all_text;
+
+}
+
+sub buffer_mets_amdSec_footer
+{
+    my $self = shift(@_);
+
+    my $all_text = "";
+    
+    $all_text .= "    </mets:xmlData>\n";
+    $all_text .= "  </mets:mdWrap>\n";
+    
+    $all_text .= "  </mets:techMD>\n";
+    $all_text .= "</mets:amdSec>\n";
+
+    return $all_text;
+
+}
+
+sub oai_dc_metadata_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section) = @_;
+
+    my $all_text = "";
+
+    my $dc_namespace = "";
+    $dc_namespace .= "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"";
+    $dc_namespace .= " xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" ";
+    
+    $all_text .= "  <oai_dc:dc $dc_namespace>\n";
+    
+    $all_text .= $self->get_dc_metadata($doc_obj, $section,"oai_dc");
+    $all_text .= "  </oai_dc:dc>\n";
+
+    return $all_text;
+}
+
+
+
+
+
+# Work out the what the metadata set prefixes (dc,dls etc.) are for 
+# this document
+
+sub metadata_set_prefixes
+{
+    my $self = shift(@_);
+    my ($doc_obj, $section) = @_;
+    
+    $section="" unless defined $section;
+    
+    my $section_ptr = $doc_obj->_lookup_section($section);
+    return {} unless defined $section_ptr;
+
+    my $unique_prefix = {};
+
+    foreach my $data (@{$section_ptr->{'metadata'}})
+    {
+	my ($prefix) = ($data->[0]=~ m/^(.*?)\./);
+	
+	if (defined $prefix)
+	{
+	    next if ($prefix eq "dc"); # skip dublin core as handled separately elsewhere
+
+	    $unique_prefix->{$prefix} = 1;
+	}
+	else
+	{
+	    $unique_prefix->{"ex"} = 1;
+	}
+
+    }
+
+    return $unique_prefix;
+}
+
+
+sub mds_metadata_xml 
+{
+    my $self = shift(@_);
+    my ($doc_obj, $section, $mds_prefix, $namespace) = @_;
+    
+    # build up string of metadata with $mds_prefix
+    $section="" unless defined $section;
+    
+    my $section_ptr = $doc_obj->_lookup_section($section);
+    return "" unless defined $section_ptr;
+
+    my $all_text="";
+    $all_text .= "  <$mds_prefix:$mds_prefix $namespace>\n";
+
+
+    foreach my $data (@{$section_ptr->{'metadata'}})
+    {
+	if ($data->[0]=~ m/^(?:(.*?)\.)?(.*)$/) 
+	{
+	    my $curr_mds_prefix = $1;
+	    my $mds_full_element = $2;
+
+	    $curr_mds_prefix = "ex" unless defined $curr_mds_prefix;
+
+	    if ($curr_mds_prefix eq $mds_prefix)
+	    {
+		# split up full element in the form Title^en into element=Title, attr="en"
+		my ($mds_element,$subelem) = ($mds_full_element =~ m/^(.*?)(?:\^(.*))?$/);
+		my $mds_attr = (defined $subelem) ? "qualifier=\"$subelem\"" : "";
+		
+		my $escaped_value = &docprint::escape_text($data->[1]);
+		
+		$all_text .= "   <$mds_prefix:metadata name=\"$mds_element\" $mds_attr>$escaped_value</$mds_prefix:metadata>\n";
+	    }
+	}
+    }
+
+    $all_text .= "  </$mds_prefix:$mds_prefix>\n";
+
+
+    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
+
+    return $all_text;
+}
+
+
+
+sub buffer_mets_dmdSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section) = @_;
+   
+    $section="" unless defined $section;
+    
+    my $section_ptr=$doc_obj->_lookup_section($section);
+    return "" unless defined $section_ptr;
+
+    my $all_text = "";
+
+    $all_text .= $self->buffer_mets_amdSec_header($section,"DC");
+    $all_text .= $self->oai_dc_metadata_xml($doc_obj,$section);
+    $all_text .= $self->buffer_mets_amdSec_footer($section);
+
+    # for each metadata set
+    my $md_sets = $self->metadata_set_prefixes($doc_obj,$section);
+
+    foreach my $md_set (keys %$md_sets)
+    {
+	# Greenstone's agnostic approach to metadata sets conflicts with
+	# Fedoras more clinically prescribed one.  Fake a namespace for
+	# each $md_set to keep both sides happy
+
+	my $fake_namespace 
+	    = "xmlns:$md_set=\"http://www.greenstone.org/namespace/fake/$md_set\"";
+	my $id_caps = $md_set;
+	$id_caps =~ tr/[a-z]/[A-Z]/;
+
+	$all_text .= $self->buffer_mets_amdSec_header($section,$id_caps);
+	$all_text .= $self->mds_metadata_xml($doc_obj,$section,$md_set,$fake_namespace);
+	$all_text .= $self->buffer_mets_amdSec_footer($section);
+    }
+
+
+    foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
+       $all_text .= $self->buffer_mets_dmdSection_section_xml($doc_obj,"$section.$subsection");
+    }
+    
+    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
+
+    return $all_text;
+}
+
+
+
+
+sub doctxt_to_xlink
+{
+    my $self = shift @_;
+    my ($fname,$working_dir) = @_;
+
+    my $xlink_href;
+
+    my $fedora_prefix = $ENV{'FEDORA_PREFIX'};
+    if (!defined $fedora_prefix) {
+	$xlink_href  = "file:$fname";
+    }
+    else
+    {
+	my $gsdlhome = $ENV{'GSDLHOME'};
+	my $gsdl_href = "$working_dir/$fname";
+	
+	$gsdl_href =~ s/^$gsdlhome(\/)?//;
+	$gsdl_href = "/gsdl/$gsdl_href";
+	
+	my $fserver = $ENV{'FEDORA_HOSTNAME'};
+	my $fport = $ENV{'FEDORA_SERVER_PORT'};
+	
+	my $fdomain = "http://$fserver:$fport";
+	$xlink_href  = "$fdomain$gsdl_href";
+    }
+	
+
+    return $xlink_href;
+
+}
+
+
+sub buffer_mets_fileSection_toc
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir) = @_;
+
+    my $opt_attr = "OWNERID=\"M\"";
+
+    my $all_text = '  <mets:fileGrp ID="TOC">'. "\n";
+    $all_text .= "    <mets:file MIMETYPE=\"text/xml\" ID=\"FILETOC\" $opt_attr >\n";    
+    my $xlink = $self->doctxt_to_xlink("doctoc.xml",$working_dir);
+
+    $all_text .= '      <mets:FLocat LOCTYPE="URL" xlink:href="'.$xlink.'"';
+
+    $all_text .= ' xlink:title="Table of Contents"/>' . "\n";
+    $all_text .= "    </mets:file>\n";
+    $all_text .= "  </mets:fileGrp>\n";
+
+    return $all_text;
+}
+
+
+sub buffer_mets_fileSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir) = @_;
+
+    my $is_txt_split = 1;
+    my $opt_owner_id = "OWNERID=\"M\"";
+
+    my $all_text 
+	= $self->SUPER::buffer_mets_fileSection_section_xml($doc_obj,$section,$working_dir,$is_txt_split, $opt_owner_id,"SECTION");
+
+
+    return $all_text;
+}
+
+sub buffer_mets_fileWhole_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir) = @_;
+
+    my $section_ptr = $doc_obj-> _lookup_section($section);
+    return "" unless defined $section_ptr;
+    
+    my $all_text="";
+
+    my $fileID=0;
+
+    # Output the fileSection for the whole section
+    #  => get the sourcefile and associative file
+
+    my $id_root = "";
+    my $opt_owner_id = "OWNERID=\"M\"";
+
+
+    foreach my $data (@{$section_ptr->{'metadata'}}){
+       my $escaped_value = &docprint::escape_text($data->[1]);
+
+       if ($data->[0] eq "gsdlassocfile"){
+	   
+	   $escaped_value =~ m/^(.*?):(.*):(.*)$/;
+	   my $assoc_file = $1;
+	   my $mime_type  = $2;
+	   my $assoc_dir  = $3;
+	   
+	   $id_root = $assoc_file;
+	   $id_root =~ s/\//_/g;
+	   $all_text .= "  <mets:fileGrp ID=\"$id_root\">\n";
+	   
+	   my $assfilePath = ($assoc_dir eq "") ? $assoc_file : "$assoc_dir/$assoc_file";
+	   ++$fileID;
+	   
+	   my $mime_attr   = "MIMETYPE=\"$mime_type\"";
+	   my $xlink_title = "xlink:title=\"$assoc_file\"";
+
+	   my $id_attr;
+	   my $xlink_href;
+
+	   $id_attr = "ID=\"$id_root.0\"";
+
+	   my $fedora_prefix = $ENV{'FEDORA_PREFIX'};
+	   if (!defined $fedora_prefix) {
+	       $xlink_href  = "xlink:href=\"$assfilePath\"";
+	   }
+	   else
+	   {
+	       my $gsdlhome = $ENV{'GSDLHOME'};
+	       my $gsdl_href = "$working_dir/$assfilePath";
+	       
+	       $gsdl_href =~ s/^$gsdlhome(\/)?//;
+	       $gsdl_href = "/gsdl/$gsdl_href";
+	       
+	       my $fserver = $ENV{'FEDORA_HOSTNAME'};
+	       my $fport = $ENV{'FEDORA_SERVER_PORT'};
+	       
+	       my $fdomain = "http://$fserver:$fport";
+	       $xlink_href  = "xlink:href=\"$fdomain$gsdl_href\"";
+	   }
+	   
+	   my $top_section = $doc_obj->get_top_section();
+	   my $id = $doc_obj->get_metadata_element($top_section,"Identifier");
+
+	   $all_text .= "    <mets:file $mime_attr $id_attr $opt_owner_id >\n";
+	   $all_text .= "      <mets:FLocat LOCTYPE=\"URL\" $xlink_href $xlink_title />\n";
+	   
+	   $all_text .= "    </mets:file>\n";
+	   
+	   $all_text .= "  </mets:fileGrp>\n";	   
+       }
+   }
+    
+    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
+    
+    return $all_text;
+}
+
+
+1;
Index: /gsdl/trunk/perllib/plugouts/GreenstoneMETSPlugout.pm
===================================================================
--- /gsdl/trunk/perllib/plugouts/GreenstoneMETSPlugout.pm	(revision 14927)
+++ /gsdl/trunk/perllib/plugouts/GreenstoneMETSPlugout.pm	(revision 14927)
@@ -0,0 +1,264 @@
+###########################################################################
+#
+# GreenstoneMETSPlugout.pm -- the plugout module for METS archives
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2006 New Zealand Digital Library Project
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+package FedoraMETSPlugout;
+
+use strict;
+no strict 'refs';
+
+#eval {require bytes};
+#use util;
+use METSPlugout;
+#use docprint; # for escape_text
+
+sub BEGIN {
+    @GreenstoneMETSPlugout::ISA = ('METSPlugout');
+}
+
+my $arguments = [
+      ];
+
+my $options = { 'name'     => "GreenstoneMETSPlugout",
+		'desc'     => "{GreenstoneMETSPlugout.desc}",
+		'abstract' => "no",
+		'inherits' => "yes", 
+	        'args'     => $arguments
+                };
+
+sub new {
+    my ($class) = shift (@_);
+    my ($plugoutlist, $inputargs,$hashArgOptLists) = @_;
+    push(@$plugoutlist, $class);
+      
+    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
+    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
+
+    my $self = (defined $hashArgOptLists)? new METSPlugout($plugoutlist,$inputargs,$hashArgOptLists): new METSPlugout($plugoutlist,$inputargs); 
+
+   
+   return bless $self, $class;
+}
+
+
+sub output_mets_xml_header
+{
+    my $self = shift(@_);
+    my ($handle, $OID, $doc_title) = @_;
+
+    my $extra_attr = "OBJID=\"$OID:2\"";
+
+    $self->output_mets_xml_header_extra_attribute($handle,$extra_attr);
+
+}
+
+#
+#  Print out docmets.xml file
+#
+sub output_mets_section 
+{
+    my $self = shift(@_);
+    my ($handle, $doc_obj, $section, $working_dir) = @_;
+
+    # print out the dmdSection
+    print $handle $self->buffer_mets_dmdSection_section_xml($doc_obj,$section);
+
+    print $handle "<mets:fileSec>\n";
+
+    # print out the fileSection by sections
+    print $handle $self->buffer_mets_fileSection_section_xml($doc_obj,$section,$working_dir);
+
+    # print out the whole fileSection
+    print $handle $self->buffer_mets_fileWhole_section_xml($doc_obj,$section,$working_dir); 
+
+    print $handle "</mets:fileSec>\n";
+  
+    # print out the StructMapSection by sections
+
+    my $struct_type = "Section";
+
+
+    # consider making the following its own subroutine
+
+    print $handle "<mets:structMap ID=\"Section\" TYPE=\"$struct_type\" LABEL=\"Section\">\n";
+    my $order_num=0;
+    print $handle $self->buffer_mets_StructMapSection_section_xml($doc_obj,$section, \$order_num);
+    print $handle "</mets:structMap>\n";
+    
+    print $handle '<mets:structMap ID="All" TYPE="Whole Document" LABEL="All">'."\n";
+    print $handle $self->buffer_mets_StructMapWhole_section_xml($doc_obj,$section);
+    print $handle "</mets:structMap>\n";
+
+  
+}
+
+sub buffer_mets_dmdSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section) = @_;
+   
+    $section="" unless defined $section;
+    
+    my $section_ptr=$doc_obj->_lookup_section($section);
+    return "" unless defined $section_ptr;
+
+    # convert section number
+    my $section_num ="1". $section;
+    my $dmd_num = $section_num;
+
+    my $all_text = "";
+
+    my $label_attr = "";
+    # TODO::
+    #print STDERR "***** Check that GROUPID in dmdSec is valid!!!\n";
+    #print STDERR "***** Check to see if <techMD> required\n";
+    # if it isn't allowed, go back and set $mdTag = dmdSec/amdSec
+
+    $all_text .= "<mets:dmdSec ID=\"DM$dmd_num\" GROUPID=\"$section_num\">\n";
+
+    $all_text .= "  <mets:mdWrap $label_attr MDTYPE=\"OTHER\" OTHERMDTYPE=\"gsdl3\" ID=\"gsdl$section_num\">\n";
+    $all_text .= "    <mets:xmlData>\n";
+
+    foreach my $data (@{$section_ptr->{'metadata'}}){
+	my $escaped_value = &docprint::escape_text($data->[1]);
+	$all_text .= '      <gsdl3:Metadata name="'. $data->[0].'">'. $escaped_value. "</gsdl3:Metadata>\n";
+	if ($data->[0] eq "dc.Title") {
+	    $all_text .= '      <gsdl3:Metadata name="Title">'. $escaped_value."</gsdl3:Metadata>\n";
+	}
+    }
+   
+    $all_text .= "    </mets:xmlData>\n";
+    $all_text .= "  </mets:mdWrap>\n";
+    
+    $all_text .= "</mets:dmdSec>\n";    
+
+
+    foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
+	$all_text .= $self->buffer_mets_dmdSection_section_xml($doc_obj,"$section.$subsection");
+    }
+    
+    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
+
+    return $all_text;
+}
+
+
+
+sub doctxt_to_xlink
+{
+    my $self = shift @_;
+    my ($fname,$working_dir) = @_;
+
+    my $xlink_href  = "file:$fname";
+
+    return $xlink_href;
+
+}
+
+
+
+sub buffer_mets_fileSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir,$is_recursive) = @_;
+
+    my $is_txt_split = undef;
+
+    my $all_text 
+	= $self->SUPER::buffer_mets_fileSection_section_xml($doc_obj,$section,$working_dir,$is_txt_split);
+
+    return $all_text;
+}
+
+sub buffer_mets_fileWhole_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir) = @_;
+
+    my $section_ptr = $doc_obj-> _lookup_section($section);
+    return "" unless defined $section_ptr;
+    
+    my $all_text="";
+
+    my $fileID=0;
+
+    # Output the fileSection for the whole section
+    #  => get the sourcefile and associative file
+
+    my $id_root = "default";
+    my $opt_owner_id = "";    
+
+    $all_text .= "  <mets:fileGrp ID=\"$id_root\">\n";
+
+
+    foreach my $data (@{$section_ptr->{'metadata'}}){
+       my $escaped_value = &docprint::escape_text($data->[1]);
+
+       if ($data->[0] eq "gsdlsourcefilename") { 
+          my ($dirPath) = $escaped_value =~ m/^(.*)[\/\\][^\/\\]*$/;
+
+          ++$fileID;	  
+          $all_text .= "    <mets:file MIMETYPE=\"text/xml\" ID=\"$id_root.$fileID\" $opt_owner_id >\n";
+        
+	  $all_text .= '      <mets:FLocat LOCTYPE="URL" xlink:href="file:'.$data->[1].'" />'."\n";
+	  
+          $all_text .= "    </mets:file>\n";
+       }
+       
+       if ($data->[0] eq "gsdlassocfile"){
+	   
+	   $escaped_value =~ m/^(.*?):(.*):(.*)$/;
+	   my $assoc_file = $1;
+	   my $mime_type  = $2;
+	   my $assoc_dir  = $3;
+	   
+	   my $assfilePath = ($assoc_dir eq "") ? $assoc_file : "$assoc_dir/$assoc_file";
+	   ++$fileID;
+	   
+	   my $mime_attr   = "MIMETYPE=\"$mime_type\"";
+	   my $xlink_title = "xlink:title=\"$assoc_file\"";
+
+	   my $id_attr;
+	   my $xlink_href;
+
+	   $id_attr = "ID=\"$id_root.$fileID\"";
+	   $xlink_href  = "xlink:href=\"$assfilePath\"";
+
+	   $all_text .= "    <mets:file $mime_attr $id_attr $opt_owner_id >\n";
+	   $all_text .= "      <mets:FLocat LOCTYPE=\"URL\" $xlink_href $xlink_title />\n";
+	   
+	   $all_text .= "    </mets:file>\n";
+	   	   
+       }
+   }
+    
+    $all_text .= "  </mets:fileGrp>\n";
+    
+    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
+    
+    return $all_text;
+}
+
+
+1;
Index: /gsdl/trunk/perllib/plugouts/METSPlugout.pm
===================================================================
--- /gsdl/trunk/perllib/plugouts/METSPlugout.pm	(revision 14926)
+++ /gsdl/trunk/perllib/plugouts/METSPlugout.pm	(revision 14927)
@@ -27,5 +27,8 @@
 
 use strict;
+no strict 'subs';
 no strict 'refs';
+
+use gsprintf 'gsprintf';
 
 eval {require bytes};
@@ -39,10 +42,4 @@
 
 my $arguments = [
-      { 'name' => "saveas_version", 
-	'desc' => "{METSPlugout.version}",
-	'type' => "string",
-        'deft' => 'greenstone',
-	'reqd' => "yes",    
-	'hiddengli' => "no"},
       { 'name' => "xslt_txt", 
 	'desc' => "{METSPlugout.xslt_txt}",
@@ -59,5 +56,5 @@
 my $options = { 'name'     => "METSPlugout",
 		'desc'     => "{METSPlugout.desc}",
-		'abstract' => "no",
+		'abstract' => "yes",
 		'inherits' => "yes", 
 	        'args'     => $arguments
@@ -75,26 +72,16 @@
     my $self = (defined $hashArgOptLists)? new BasPlugout($plugoutlist,$inputargs,$hashArgOptLists): new BasPlugout($plugoutlist,$inputargs); 
 
- 
-   
+    
    return bless $self, $class;
 }
 
-sub saveas {
+
+sub saveas_doctxt
+{
     my $self = shift (@_);
-    my ($doc_obj,$doc_dir) = @_;
-    my $version = $self->{'saveas_version'};
-
-    $self->process_assoc_files ($doc_obj, $doc_dir, '');
-
-    my $output_dir = $self->get_output_dir();
-    &util::mk_all_dir ($output_dir) unless -e $output_dir;
- 
-    my $working_dir = &util::filename_cat ($output_dir, $doc_dir);              
-   
-    &util::mk_all_dir ($working_dir) unless -e $working_dir;
-
-    #########################
-    # save the text file
-    #########################
+    my ($doc_obj,$working_dir) = @_;
+
+    my $is_recursive = 1;
+
     my $doc_txt_file = &util::filename_cat ($working_dir,"doctxt.xml");	
 	
@@ -111,5 +98,6 @@
 
     $self->output_xml_header($outhandler);
-    $self->output_txt_section($outhandler,$doc_obj, $doc_obj->get_top_section());
+    my $section = $doc_obj->get_top_section();
+    $self->output_txt_section($outhandler,$doc_obj, $section, $is_recursive);
     $self->output_xml_footer($outhandler);
     
@@ -121,8 +109,12 @@
 	close($outhandler);
     }
-    
-    #########################
-    # save the mets file
-    #########################
+
+}
+
+sub saveas_docmets
+{
+    my $self = shift (@_);
+    my ($doc_obj,$working_dir) = @_;
+
     my $doc_mets_file = &util::filename_cat ($working_dir, "docmets.xml");
     
@@ -134,4 +126,6 @@
     $self->open_xslt_pipe($doc_mets_file,$self->{'xslt_mets'});
 
+    my $outhandler; 
+
     if (defined $self->{'xslt_writer'}){
        $outhandler = $self->{'xslt_writer'};
@@ -143,5 +137,5 @@
       
     $self->output_mets_xml_header($outhandler, $doc_obj->get_OID(), $doc_title);
-    $self->output_mets_section($outhandler, $doc_obj, $doc_obj->get_top_section(),$version,$working_dir);
+    $self->output_mets_section($outhandler, $doc_obj, $doc_obj->get_top_section(),$working_dir);
     $self->output_mets_xml_footer($outhandler);
 	
@@ -152,30 +146,51 @@
 	close($outhandler);
     }
-     
+    
+
+}
+
+sub saveas 
+{
+    my $self = shift (@_);
+    my ($doc_obj,$doc_dir) = @_;
+
+    $self->process_assoc_files ($doc_obj, $doc_dir, '');
+
+    my $output_dir = $self->get_output_dir();
+    &util::mk_all_dir ($output_dir) unless -e $output_dir;
+ 
+    my $working_dir = &util::filename_cat ($output_dir, $doc_dir);              
+   
+    &util::mk_all_dir ($working_dir) unless -e $working_dir;
+
+    ###
+    # Save the text as a filefile
+    ###
+    $self->saveas_doctxt($doc_obj,$working_dir);
+
+    ###
+    # Save the structure and metadata as a METS file
+    ###
+    $self->saveas_docmets($doc_obj,$working_dir);
+
     $self->{'short_doc_file'} =  &util::filename_cat ($doc_dir, "docmets.xml");
   
-    $self->store_output_info_reference($doc_obj);
-      
-}
-
-
-sub output_mets_xml_header(){
+    $self->store_output_info_reference($doc_obj);  
+
+}
+
+
+sub output_mets_xml_header
+{
     my $self = shift(@_);
     my ($handle, $OID, $doc_title) = @_;
 
-    my $version = $self->{'saveas_version'};
-
-    my $extra_attr = "";
-    if ($version eq "fedora") {	
-	my $fnamespace = $ENV{'FEDORA_PID_NAMESPACE'};
-	my $oid_namespace = (defined $fnamespace) ? $fnamespace : "test";
-
-	$extra_attr = "OBJID=\"$oid_namespace:$OID\" TYPE=\"FedoraObject\" LABEL=\"$doc_title\"";
-    }
-    else {
-	# Greenstone METS profile
-	$extra_attr = "OBJID=\"$OID:2\"";
-    }
-
+    gsprintf(STDERR, "METSPlugout::output_mets_xml_header {common.must_be_implemented}\n") && die "\n";
+}
+
+sub output_mets_xml_header_extra_attribute
+{
+    my $self = shift(@_);
+    my ($handle, $extra_attr) = @_;
 
     print $handle '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
@@ -188,13 +203,11 @@
     print $handle '           http://www.greenstone.org/namespace/gsdlmetadata/1.0/' . "\n";
     print $handle '           http://www.greenstone.org/namespace/gsdlmetadata/1.0/gsdl_metadata.xsd"' . "\n";
+
     print $handle "  $extra_attr>\n";
 
-    if ($version eq "fedora") {
-	print $handle '<mets:metsHdr RECORDSTATUS="A"/>'. "\n"; # A = active
-    }
-
-}
-
-sub output_mets_xml_footer() {
+}
+
+sub output_mets_xml_footer 
+{
     my $self = shift(@_);
     my ($handle) = @_;
@@ -205,12 +218,12 @@
 sub output_txt_section {
     my $self = shift (@_);
-    my ($handle, $doc_obj, $section) = @_;
-
-    print $handle $self->buffer_txt_section_xml($doc_obj, $section);
+    my ($handle, $doc_obj, $section, $is_recursive) = @_;
+
+    print $handle $self->buffer_txt_section_xml($doc_obj, $section, $is_recursive);
 }
 
 sub buffer_txt_section_xml {
     my $self = shift(@_);
-    my ($doc_obj, $section) = @_;
+    my ($doc_obj, $section, $is_recursive) = @_;
  
     my $section_ptr = $doc_obj->_lookup_section ($section);
@@ -221,8 +234,11 @@
     $all_text .= &docprint::escape_text("$section_ptr->{'text'}");
    
-    #output all the subsections
-    foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
-       $all_text .= $self->buffer_txt_section_xml($doc_obj, "$section.$subsection");
-     }
+    if (defined $is_recursive && $is_recursive)
+    {
+	# Output all the subsections
+	foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
+	    $all_text .= $self->buffer_txt_section_xml($doc_obj, "$section.$subsection");
+	}
+    }
 
      $all_text .= "</Section>\n";
@@ -233,151 +249,41 @@
 }
 
-#  print out docmets.xml file
-sub output_mets_section {
-    my $self = shift(@_);
-    my ($handle, $doc_obj, $section, $version, $working_dir) = @_;
-
-    # print out the dmdSection
-    print $handle $self->buffer_mets_dmdSection_section_xml($doc_obj,$section, $version);
-
-    print $handle "<mets:fileSec>\n";
-    if ($version eq "fedora") {
-	print $handle "  <mets:fileGrp ID=\"DATASTREAMS\">\n";
-    }
-
-    # print out the fileSection by sections
-    print $handle $self->buffer_mets_fileSection_section_xml($doc_obj,$section,$version);
-
-    # print out the whole fileSection
-    print $handle $self->buffer_mets_fileWhole_section_xml($doc_obj,$section,$version,$working_dir); 
-
-    if ($version eq "fedora") {
-	print $handle "  </mets:fileGrp>\n";
-    }
-    print $handle "</mets:fileSec>\n";
-  
-    # print out the StructMapSection by sections
-
-    my $struct_type;
-    if ($version eq "fedora") {
-	$struct_type = "fedora:dsBindingMap";
-    }
-    else {
-	$struct_type = "Section";
-    }
-
-    if ($version ne "fedora") {
-	print $handle "<mets:structMap ID=\"Section\" TYPE=\"$struct_type\" LABEL=\"Section\">\n";
-	my $order_num=0;
-	print $handle $self->buffer_mets_StructMapSection_section_xml($doc_obj,$section, \$order_num);
-	print $handle "</mets:structMap>\n";
-
-	print $handle '<mets:structMap ID="All" TYPE="Whole Document" LABEL="All">'."\n";
-	print $handle $self->buffer_mets_StructMapWhole_section_xml($doc_obj,$section);
-	print $handle "</mets:structMap>\n";
-    }
-  
-}
-
-sub buffer_mets_dmdSection_section_xml(){
-    my $self = shift(@_);
-    my ($doc_obj,$section,$version) = @_;
-   
+#
+#  Print out docmets.xml file
+#
+sub output_mets_section 
+{
+    my $self = shift(@_);
+    my ($handle, $doc_obj, $section, $working_dir) = @_;
+
+    gsprintf(STDERR, "METSPlugout::output_mets_section {common.must_be_implemented}\n") && die "\n";
+
+}
+
+
+sub buffer_mets_dmdSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section) = @_;
+
+    gsprintf(STDERR, "METSPlugout::buffer_mets_dmdSection_section_xml {common.must_be_implemented}\n") && die "\n";
+}
+
+sub buffer_mets_StructMapSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section, $order_numref, $fileid_base) = @_;
+
     $section="" unless defined $section;
+    
     
     my $section_ptr=$doc_obj->_lookup_section($section);
     return "" unless defined $section_ptr;
 
-    # convert section number
-    my $section_num ="1". $section;
-    my $dmd_num = $section_num;
-
-    # #**output the dmdSection details  
-    # if ($section_num eq "1") {
-    #	$dmd_num = "0";
-    # }
-
-
-    my $all_text = "";
-
-    my $label_attr = "";
-    if ($version eq "fedora") {
-	$all_text .= "<mets:amdSec ID=\"DC\" >\n";
-	$all_text .= "  <mets:techMD ID=\"DC.0\">\n"; # .0 fedora version number?
-
-	$label_attr = "LABEL=\"Dublin Core Metadata\"";
-    }
-    else {
-	# TODO::
-	#print STDERR "***** Check that GROUPID in dmdSec is valid!!!\n";
-	#print STDERR "***** Check to see if <techMD> required\n";
-	# if it isn't allowed, go back and set $mdTag = dmdSec/amdSec
-
-	$all_text .= "<mets:dmdSec ID=\"DM$dmd_num\" GROUPID=\"$section_num\">\n";
-    }
-
-    $all_text .= "  <mets:mdWrap $label_attr MDTYPE=\"OTHER\" OTHERMDTYPE=\"gsdl3\" ID=\"gsdl$section_num\">\n";
-    $all_text .= "    <mets:xmlData>\n";
-
-    if ($version eq "fedora") {
-	my $dc_namespace = "";
-	$dc_namespace .= "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"";
-	$dc_namespace .= " xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\">\n";
-
-	$all_text .= "  <oai_dc:dc $dc_namespace>\n";
-
-	$all_text .= $self->get_dc_metadata($doc_obj, $section,"oai_dc");
-	$all_text .= "  </oai_dc:dc>\n";
-    }
-    else {
-	foreach my $data (@{$section_ptr->{'metadata'}}){
-	    my $escaped_value = &docprint::escape_text($data->[1]);
-	    $all_text .= '      <gsdl3:Metadata name="'. $data->[0].'">'. $escaped_value. "</gsdl3:Metadata>\n";
-	    if ($data->[0] eq "dc.Title") {
-		$all_text .= '      <gsdl3:Metadata name="Title">'. $escaped_value."</gsdl3:Metadata>\n";
-	    }
-	}
-    }
-   
-    $all_text .= "    </mets:xmlData>\n";
-    $all_text .= "  </mets:mdWrap>\n";
-    
-    if ($version eq "fedora") {
-	$all_text .= "  </mets:techMD>\n";
-	$all_text .= "</mets:amdSec>\n";
-    }
-    else {
-	$all_text .= "</mets:dmdSec>\n";    
-    }
-
-
-    foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
-       $all_text .= $self->buffer_mets_dmdSection_section_xml($doc_obj,"$section.$subsection",$version);
-    }
-    
-    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
-
-    return $all_text;
-}
-
-sub buffer_mets_StructMapSection_section_xml(){
-    my $self = shift(@_);
-    my ($doc_obj,$section, $order_numref) = @_;
-
-    $section="" unless defined $section;
-    
-    
-    my $section_ptr=$doc_obj->_lookup_section($section);
-    return "" unless defined $section_ptr;
-
+    $fileid_base = "FILEGROUP_PRELUDE" unless defined $fileid_base;
 
     # output fileSection by Sections
     my $section_num ="1". $section;
     my $dmd_num = $section_num;
-
-    ##**output the dmdSection details  
-    #if ($section_num eq "1") {
-    #	$dmd_num = "0";
-    #}
 
     #**output the StructMap details
@@ -389,9 +295,9 @@
     $all_text .= "      LABEL=\"$section_num\" DMDID=\"$dmdid_attr\">\n";
    
-    $all_text .= '    <mets:fptr FILEID="FILEGROUP_PRELUDE'.$section_num.'" />'. "\n";
+    $all_text .= '    <mets:fptr FILEID="'.$fileid_base.$section_num.'" />'. "\n";
 
 
     foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
-       $all_text .= $self->buffer_mets_StructMapSection_section_xml($doc_obj,"$section.$subsection", $order_numref);
+       $all_text .= $self->buffer_mets_StructMapSection_section_xml($doc_obj,"$section.$subsection", $order_numref, $fileid_base);
     }
     
@@ -404,5 +310,6 @@
 
 
-sub buffer_mets_StructMapWhole_section_xml(){
+sub buffer_mets_StructMapWhole_section_xml
+{
     my $self = shift(@_);
     my ($doc_obj,$section) = @_;
@@ -440,36 +347,62 @@
 }
 
-sub buffer_mets_fileSection_section_xml() {
-    my $self = shift(@_);
-    my ($doc_obj,$section,$version) = @_;
+
+
+sub doctxt_to_xlink
+{
+    my $self = shift @_;
+    my ($fname,$working_dir) = @_;
+
+    gsprintf(STDERR, "METSPlugout::doxtxt_to_xlink {common.must_be_implemented}\n") && die "\n";
+}
+
+sub buffer_mets_fileSection_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir, $is_txt_split,$opt_attr,$fileid_base) = @_;
 
     #$section="" unless defined $section;
     
-
     my $section_ptr=$doc_obj->_lookup_section($section);
     return "" unless defined $section_ptr;
  
+    $fileid_base = "FILEGROUP_PRELUDE" unless defined $fileid_base;
 
     # output fileSection by sections
     my $section_num ="1". $section;
-      
-    my $filePath = 'doctxt.xml';
-
-    my $opt_owner_id = "";
-    if ($version eq "fedora") {
-	$opt_owner_id = "OWNERID=\"M\"";
-    }
-
+ 
+    $opt_attr = "" unless defined $opt_attr;
+     
     # output the fileSection details
-    my $all_text = '  <mets:fileGrp ID="FILEGROUP_PRELUDE' . $section_num . '">'. "\n";
-    $all_text .= "    <mets:file MIMETYPE=\"text/xml\" ID=\"FILE$section_num\" $opt_owner_id >\n";
-    $all_text .= '      <mets:FLocat LOCTYPE="URL" xlink:href="file:'.$filePath.'#xpointer(/Section[';
-    
-    my $xpath = "1".$section;
-    $xpath =~ s/\./]\/Section[/g;
-   
-    $all_text .=  $xpath;
-
-    $all_text .= ']/text())" xlink:title="Hierarchical Document Structure"/>' . "\n";
+    my $all_text = '  <mets:fileGrp ID="'.$fileid_base.$section_num . '">'. "\n";
+    $all_text .= "    <mets:file MIMETYPE=\"text/xml\" ID=\"FILE$section_num\" $opt_attr >\n";
+
+    my $xlink;
+    if (defined $is_txt_split && $is_txt_split)
+    {
+	my $section_fnum ="1". $section;
+	$section_fnum =~ s/\./_/g;
+
+    	$xlink = $self->doctxt_to_xlink("doctxt$section_fnum.xml",$working_dir);
+    }
+    else
+    {
+	$xlink = $self->doctxt_to_xlink("doctxt.xml",$working_dir);
+
+	$xlink .= '#xpointer(/Section[';
+    
+	my $xpath = "1".$section;
+	$xpath =~ s/\./\]\/Section\[/g;
+	
+	$xlink .=  $xpath;
+	
+	$xlink .= ']/text())';
+    }
+
+
+
+    $all_text .= '      <mets:FLocat LOCTYPE="URL" xlink:href="'.$xlink.'"';
+
+    $all_text .= ' xlink:title="Hierarchical Document Structure"/>' . "\n";
     $all_text .= "    </mets:file>\n";
     $all_text .= "  </mets:fileGrp>\n";
@@ -477,5 +410,5 @@
 
     foreach my $subsection (@{$section_ptr->{'subsection_order'}}){
-	$all_text .= $self->buffer_mets_fileSection_section_xml($doc_obj,"$section.$subsection",$version);
+	$all_text .= $self->buffer_mets_fileSection_section_xml($doc_obj,"$section.$subsection",$working_dir, $is_txt_split, $opt_attr, $fileid_base);
     }
     
@@ -485,119 +418,12 @@
 }
 
-sub buffer_mets_fileWhole_section_xml(){
-    my $self = shift(@_);
-    my ($doc_obj,$section,$version,$working_dir) = @_;
-
-    my $section_ptr = $doc_obj-> _lookup_section($section);
-    return "" unless defined $section_ptr;
-    
-    my $all_text="";
-
-    my $fileID=0;
-
-    # Output the fileSection for the whole section
-    #  => get the sourcefile and associative file
-
-    my $id_root = "";
-    my $opt_owner_id = "";    
-
-    if ($version eq "fedora") {
-	$opt_owner_id = "OWNERID=\"M\"";
-    }
-    else {
-	$id_root = "default";
-    }
-
-    if ($version ne "fedora") {
-	$all_text .= "  <mets:fileGrp ID=\"$id_root\">\n";
-    }
-
-    foreach my $data (@{$section_ptr->{'metadata'}}){
-       my $escaped_value = &docprint::escape_text($data->[1]);
-
-       if (($data->[0] eq "gsdlsourcefilename") && ($version ne "fedora")) { 
-          my ($dirPath) = $escaped_value =~ m/^(.*)[\/\\][^\/\\]*$/;
-
-          ++$fileID;	  
-          $all_text .= "    <mets:file MIMETYPE=\"text/xml\" ID=\"$id_root.$fileID\" $opt_owner_id >\n";
-        
-	  $all_text .= '      <mets:FLocat LOCTYPE="URL" xlink:href="file:'.$data->[1].'" />'."\n";
-	  
-          $all_text .= "    </mets:file>\n";
-       }
-       
-       if ($data->[0] eq "gsdlassocfile"){
-	   
-	   $escaped_value =~ m/^(.*?):(.*):(.*)$/;
-	   my $assoc_file = $1;
-	   my $mime_type  = $2;
-	   my $assoc_dir  = $3;
-	   
-	   if ($version eq "fedora") {
-	       $id_root = $assoc_file;
-	       $id_root =~ s/\//_/g;
-	       $all_text .= "  <mets:fileGrp ID=\"$id_root\">\n";
-	   }
-	   
-	   my $assfilePath = ($assoc_dir eq "") ? $assoc_file : "$assoc_dir/$assoc_file";
-	   ++$fileID;
-	   
-	   my $mime_attr   = "MIMETYPE=\"$mime_type\"";
-	   my $xlink_title = "xlink:title=\"$assoc_file\"";
-
-	   my $id_attr;
-	   my $xlink_href;
-
-	   if ($version eq "fedora") {
-	       $id_attr = "ID=\"$id_root.0\"";
-
-	       my $fedora_prefix = $ENV{'FEDORA_PREFIX'};
-	       if (!defined $fedora_prefix) {
-		   $xlink_href  = "xlink:href=\"$assfilePath\"";
-	       }
-	       else
-	       {
-		   my $gsdlhome = $ENV{'GSDLHOME'};
-		   my $gsdl_href = "$working_dir/$assfilePath";
-
-		   $gsdl_href =~ s/^$gsdlhome(\/)?//;
-		   $gsdl_href = "/gsdl/$gsdl_href";
-
-		   my $fserver = $ENV{'FEDORA_HOSTNAME'};
-		   my $fport = $ENV{'FEDORA_SERVER_PORT'};
-
-		   my $fdomain = "http://$fserver:$fport";
-		   $xlink_href  = "xlink:href=\"$fdomain$gsdl_href\"";
-	       }
-
-	       my $top_section = $doc_obj->get_top_section();
-	       my $id = $doc_obj->get_metadata_element($top_section,"Identifier");
-	   }
-	   else {
-	       $id_attr = "ID=\"$id_root.$fileID\"";
-	       $xlink_href  = "xlink:href=\"$assfilePath\"";
-	   }
-
-	   $all_text .= "    <mets:file $mime_attr $id_attr $opt_owner_id >\n";
-	   $all_text .= "      <mets:FLocat LOCTYPE=\"URL\" $xlink_href $xlink_title />\n";
-	   
-	   $all_text .= "    </mets:file>\n";
-	   
-	   if ($version eq "fedora") {
-	       $all_text .= "  </mets:fileGrp>\n";
-	   }
-	   
-       }
-   }
-    
-    if ($version ne "fedora") {
-	$all_text .= "  </mets:fileGrp>\n";
-    }         
-    
-    $all_text =~ s/[\x00-\x09\x0B\x0C\x0E-\x1F]//g;
-    
-    return $all_text;
-}
-
+sub buffer_mets_fileWhole_section_xml
+{
+    my $self = shift(@_);
+    my ($doc_obj,$section,$working_dir) = @_;
+
+    gsprintf(STDERR, "METSPlugout::buffer_mets_fileWhole_section_xml {common.must_be_implemented}\n") && die "\n";
+
+}
 
 1;
