Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptive.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptive.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptive.java	(revision 8461)
@@ -179,4 +179,100 @@
   }
   
+    protected void parse_xmlData(METSNamespace namespace, Element element) 
+    {
+	if (namespace==null) {
+	    System.err.println("namespace is null!!!!");
+	}
+	NodeList children = element.getChildNodes();
+	
+	for (int c = 0; c < children.getLength(); c++) {
+	    if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
+		continue;
+	    }
+
+	    Element child  = (Element) children.item(c);
+	    String childName = child.getNodeName();
+	    
+	    // if (childName.equals("gsdl2:Metadata")) {
+	    if (childName.equals("gsdl3:Metadata")) {
+		String metaName = child.getAttribute("name");
+		Text text = (Text) child.getFirstChild();
+		String metaValue = text.getData();
+		
+		addMetadata(namespace.getName(),metaName, metaValue);
+	    }
+	}
+    }
+
+    public void parse_mdWrap(Element element)
+    {
+	// deal with mets:mdWrap
+	
+	METSNamespace namespace = NamespaceFactory.parseXML(element);
+	
+	NodeList children = element.getChildNodes();
+	
+	for (int c = 0; c < children.getLength(); c ++) {
+	    if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
+		continue;
+	    }
+
+	    Element child  = (Element) children.item(c);
+	    String childName = child.getNodeName();
+
+	    if (childName.equals("mets:xmlData")) {
+		parse_xmlData(namespace, child);
+	    } else {
+		System.err.println("Warning: unrecognised tag " + childName 
+				   + "in mets:mdWrap");
+	    }
+	}
+    }
+
+    /**
+     *  Parse an XML Element as a METS Descriptive Metadata section
+     *
+     *  @param <code>Element</code> the XML element which represents the dmdSec itself
+     */
+   
+    //public static METSDescriptive parseXML(Element element, METSDescriptive thisDescriptive) 
+    public static METSDescriptive parseXML(Element element) 
+    {
+	// Note: no parsing of attributes required, we just move onto
+	// the metadata namespaces/sections themselves
+
+	// deal with mets:dmdSec
+	String ID = element.getAttribute("ID");
+	String label = element.getAttribute("GROUPID");
+	
+	METSDescriptive thisDescriptive = new METSDescriptive(ID, label);
+
+	//thisDescriptive = new METSDescriptive(ID, label);
+	
+	NodeList children = element.getChildNodes();
+
+	for (int c = 0; c < children.getLength(); c ++) {
+	    if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
+		continue;
+	    }
+	    
+	    Element child = (Element) children.item(c);
+	    String childName = child.getNodeName();
+	    
+	    if (childName.equals("mets:mdRef")) {
+		//for External Descriptive Metadata
+		METSNamespace namespace = NamespaceFactory.parseXML(element);
+		System.err.println("*** mets::mdRef does not appear to be implemented yet");
+	    } else if (childName.equals("mets:mdWrap")) {
+		thisDescriptive.parse_mdWrap(child);
+	    } else {
+		// TODO: raise an error!
+		System.out.println("Error: METSDescriiptive: unrecognised tag "+childName);
+	    }
+	}
+	return thisDescriptive;
+    }
+    
+
   /**
    *  Parse an XML Element as a METS Descriptive Metadata section
@@ -184,5 +280,5 @@
    *  @param <code>Element</code> the XML element which represents the dmdSec itself
    */
-  public static METSDescriptive parseXML(Element element)
+    /*  public static METSDescriptive parseXML(Element element)
   { // Note: no parsing of attributes required, we just move onto the metadata
     //       namespaces/sections themselves
@@ -211,5 +307,5 @@
     return thisDescriptive;
   }
-
+    */
 
   /**
@@ -250,4 +346,47 @@
     output.println(tag);
   }
+
+    public void copy_metadata(METSDescriptive dst) 
+    {
+	Iterator keys = this.map.keySet().iterator();
+
+	// get the keys one by one
+	while (keys.hasNext()) {
+	    Object nextKey = keys.next();
+	    if (nextKey == null) {
+		continue;
+	    }
+	    String key = nextKey.toString();
+
+	    System.err.println("*** Namespace = " + key);
+	    
+	    // get every copy of the current namespace name - namespaces may
+	    // occur more than once, so this is a List
+	    Iterator namespaces = this.map.getAll(key).iterator();
+      
+	    while (namespaces.hasNext()) {
+		METSNamespace namespace = (METSNamespace) namespaces.next();
+		
+		// for each metadata name 
+
+		Iterator mdnIter = namespace.getMetadataNames();
+		while (mdnIter.hasNext()) {
+
+		    String md_name = mdnIter.next().toString();
+		    
+		    List values = getMetadata(key, md_name);
+		    
+		    if (values != null) {	
+			Iterator valueIter = values.iterator();
+			while (valueIter.hasNext()) {
+			    String value = valueIter.next().toString();
+			    dst.addMetadata("gsdl3",md_name,value);
+			}
+		    }
+		}
+	    }
+	}
+    }
+
 
   public boolean writeSQL(DocumentInterface document, GS3SQLConnection connection)
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java	(revision 8461)
@@ -70,9 +70,10 @@
     
     // when a descriptive block is added, check that it hasn't been used before...
-    this.identifierFactory.noteIdentifier(metadata.getID());
-  }
-
-  /**
-   *  Get a descriptive item by its name
+    //this.identifierFactory.noteIdentifier(metadata.getID());
+    this.identifierFactory.noteIdentifier(metadata.getName());
+  }
+
+  /**
+   *  Get a descriptive item by its name(GROUPID in METS file)
    */
   public METSDescriptive getDescriptive(String name)
@@ -177,5 +178,5 @@
     return true;
   }
-
+    /*
   public static METSDescriptiveSet parseXML(NodeList fileSecs)
   {	
@@ -189,4 +190,62 @@
     return set;
   }
+    */
+
+    /*    public static METSDescriptiveSet parseXML(NodeList dmdSecs) 
+    {
+	METSDescriptiveSet set = new METSDescriptiveSet();
+	METSDescriptive thisDescriptive = null;
+
+	for (int g = 0; g < dmdSecs.getLength(); g ++) {
+	    Element dmdNode = (Element) dmdSecs.item(g);
+	    String ID = dmdNode.getAttribute("ID");
+	    String label = dmdNode.getAttribute("GROUPID");
+	    System.err.println("###Label="+label);
+
+	    if (label.equals("1")) {
+		thisDescriptive = set.getDescriptive("default");
+		System.err.println("####thisDescriptiveDefault=" + thisDescriptive);
+	    } else {
+		thisDescriptive = new METSDescriptive(ID, label);
+		System.err.println("####thisDescriptive=" + thisDescriptive);
+	    }
+
+	    METSDescriptive metadata = METSDescriptive.parseXML((Element) dmdSecs.item(g), thisDescriptive);
+	    
+	    set.addDescriptive(metadata);
+	    }
+	return set;
+	}*/
+    public static METSDescriptiveSet parseXML(NodeList dmdSecs) 
+    {
+	METSDescriptiveSet set = new METSDescriptiveSet();
+	
+	for (int g = 0; g < dmdSecs.getLength(); g ++) {
+	    METSDescriptive metadata = METSDescriptive.parseXML((Element) dmdSecs.item(g));
+	    
+	    set.addDescriptive(metadata);
+	}
+           
+    
+	System.err.println("******** Away to do transfer!!!!!!");
+	  
+	METSDescriptive top_level_metadata = set.getDescriptive("1");
+	METSDescriptive tl2_metadata = set.getDescriptive("1");
+	METSDescriptive opo_metadata = set.getDescriptive("1.1");
+	METSDescriptive default_metadata = set.getDescriptive("default");
+
+	if (top_level_metadata != null) {
+	    if (default_metadata != null) {
+		top_level_metadata.copy_metadata(default_metadata);
+	    }
+	    else {
+		System.err.println("Warning: Could not find default metadata");
+	    }
+	}
+	else {
+	    System.err.println("Warning: Could not find top level metadata for groupID=1");
+	}
+	return set;
+    } 
 
   public static METSDescriptiveSet readSQL(DocumentInterface document, GS3SQLConnection connection)
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java	(revision 8461)
@@ -11,4 +11,7 @@
 import java.sql.SQLException;
 import java.sql.ResultSet;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 import org.greenstone.gsdl3.gs3build.doctypes.DocumentID;
@@ -289,4 +292,62 @@
     }
   }
+
+      /*  Parse an XML Element as a METSDivision section
+      *
+      *  @param <code>Element</code> the XML element which represents
+      *  the mets:div itself 
+      */
+    
+     public static METSDivision parseXML(Element element) 
+     {
+ 	METSDivision thisDivision = null;
+ 
+ 	String divId = element.getAttribute("ID");
+ 	String divType = element.getAttribute("TYPE");
+ 	String divOrder = element.getAttribute("ORDER");
+ 	String divOrderLabel = element.getAttribute("ORDERLABEL");
+ 	String divUserLabel = element.getAttribute("LABEL");
+ 	String divMetaRef = element.getAttribute("DMDID");
+ 	
+ 	thisDivision = new METSDivision(divId, divOrder,divOrderLabel, divUserLabel, divType);
+ 		
+ 	thisDivision.addMetadataReference(divMetaRef);
+ 
+ 	NodeList children = element.getChildNodes();
+ 
+ 	for (int c = 0; c < children.getLength(); c++){
+ 	    if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
+ 		continue;
+ 	    }
+ 	    Element child = (Element) children.item(c);
+ 	    String childName = child.getNodeName();
+ 
+ 	    if (childName.equals("mets:fptr")) {
+ 		
+ 		METSDivision.fptr_parseXML(thisDivision, child);
+ 	    } else if (childName.equals("mets:div")) {
+ 		METSDivision division = METSDivision.parseXML(child);
+ 		thisDivision.addDivision(division);
+ 	    } else {
+ 		System.err.println("Error: mets:div expected mets:div or mets:fptr, but got " + childName);
+ 	    } 
+ 	}
+ 	return thisDivision;
+     }
+ 
+ 
+ 
+     /**
+      * Parse an XML element as a  METSFptr Section
+      * @param <code>Element</code> the XML element which represents the mets:fptr itself
+      */
+     private static void fptr_parseXML(METSDivision thisDivision, Element element) 
+     {
+ 	String fileRef = element.getAttribute("FILEID");
+ 	thisDivision.addFileReference(fileRef);
+     }
+ 
+     /**
+
 
   /**
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java	(revision 8461)
@@ -248,4 +248,5 @@
    *  Parse an XML Element as a METS File
    */
+    /*
   public static METSFile parseXML(Element element, METSFileGroup parentGroup)
   { METSFile file = null;
@@ -287,4 +288,78 @@
     return file;
   }
+    */
+
+
+    public static METSFile parse_file(Element element, METSFileGroup group, String parseFilePath)
+    {
+	NodeList children = element.getChildNodes();
+
+	METSFile thisFile = null;
+
+	for (int c = 0; c < children.getLength(); c++){
+	    if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
+		continue;
+	    }  
+	    Element child = (Element) children.item(c);
+	    String childName = child.getNodeName();
+
+	    if (childName.equals("mets:file")){
+		METSFile.parse_file(child, group, parseFilePath);
+	    } else if (childName.equals("mets:FLocat")) {
+		String mimeType = element.getAttribute("MIMETYPE");
+		String fileId = element.getAttribute("ID");   
+		
+		METSFilePos thisFilePos = METSFile.parse_flocateXML(child, parseFilePath);
+		thisFile = new METSFile(new METSFileID(fileId), thisFilePos, mimeType);
+		group.addFile(thisFile);
+	    } else {
+		System.err.println("Warning: unrecognised tag " +childName);
+	    }
+	}
+	return thisFile;
+    }
+    
+    public static METSFilePos parse_flocateXML(Element element, String parseFilePath)
+    {
+	METSFilePos thisFilePos = null;
+	
+	// get most of the information from the child FLocat node
+	String locationType = element.getAttribute("LOCTYPE");
+	String href = element.getAttribute("xlink:href");
+	String fileId = element.getAttribute("ID");
+	
+	try {
+	    thisFilePos = new METSFilePos(locationType, href);
+	   
+	    if (fileId.startsWith("default.")) {
+		//retrieve the string after ..import/
+		int importPosition = href.indexOf("import/")+7;
+		href.substring(importPosition);
+		if (fileId.equals("default.1")) {
+		    href = "file:" + parseFilePath+ "doctxt.xml";
+		} else {
+		    href = "file:" + parseFilePath + href.substring(importPosition);
+		}
+	    }
+            thisFilePos = new METSFilePos(locationType, href);
+	} catch (java.net.MalformedURLException ex) {
+	    // TODO: raise error
+	    System.err.println(ex);
+	}
+	return thisFilePos;
+// 	file = new METSFile(new METSFileID(id), filePos, mimeType);
+//       }
+//       else if (childElement.getNodeName().equals("mets:FContent"))
+//       {
+//       }
+//       else
+//       { // TODO: raise an error!
+//       }
+//     }
+//     return file;
+// }
+	
+    }
+
 
   /**
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java	(revision 8461)
@@ -9,4 +9,8 @@
 import java.sql.SQLException;
 import java.sql.ResultSet;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
 
 import java.io.PrintWriter;
@@ -203,4 +207,31 @@
   { return this.id;
   }
+
+     public static METSFileGroup parse_groupXML(Element element, METSFileSet set, String parseFilePath, METSFileGroup group)
+     {
+ 	//deal with mets:fileGrp
+ 	NodeList children = element.getChildNodes();
+ 	
+ 	for (int c = 0; c < children.getLength(); c++) {
+ 	    if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
+ 		continue;
+ 	    }
+ 	    Element child = (Element) children.item(c);
+ 	    String childName = child.getNodeName();
+ 
+ 	    if (childName.equals("mets:fileGrp")) {
+ 		String groupId = child.getAttribute("ID");
+ 		METSFileGroup childGroup = new METSFileGroup(groupId);
+ 
+ 		if (group != null){
+ 		    group.addGroup(childGroup);
+ 		} else {
+ 		    set.addGroup(childGroup);
+ 		}
+ 		METSFile file = METSFile.parse_file(child, childGroup, parseFilePath);
+ 	    }
+ 	}
+ 	return group;
+     }
 
   /**
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java	(revision 8461)
@@ -17,4 +17,8 @@
 import java.sql.SQLException;
 import java.sql.ResultSet;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
 
 import java.net.URL;
@@ -172,4 +176,23 @@
     return resultList;
   }
+    
+    /*
+     *
+     *
+     */
+    public static METSFileSet parseXML(NodeList fileSecs, METSFileSet fileSet, String parseFilePath) {
+	
+ 	//METSFileSet set = new METSFileSet();> 
+ 	// this is in effect a group without a sense of 'self'...
+ 	for (int c = 0; c < fileSecs.getLength(); c++) {
+ 	    if (fileSecs.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
+ 		continue;
+ 	    }
+	    
+ 	    METSFileGroup groups = METSFileGroup.parse_groupXML((Element)fileSecs.item(c), fileSet, parseFilePath, null);
+ 	}
+ 	return fileSet;
+    }
+    
 
   public void write(PrintWriter writer)
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSNamespace.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSNamespace.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSNamespace.java	(revision 8461)
@@ -4,5 +4,5 @@
 
 import java.util.List;
-
+import java.util.Iterator;
 import java.sql.SQLException;
 import java.sql.ResultSet;
@@ -100,4 +100,5 @@
   public abstract boolean removeMetadata(String label, String value);
   public abstract List    getMetadata(String label);
+  public abstract Iterator getMetadataNames();
   public abstract boolean write(PrintWriter writer);
   //  public abstract boolean writeSQL(GS3SQLConnection connection);
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructure.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructure.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructure.java	(revision 8461)
@@ -12,4 +12,7 @@
 import java.sql.ResultSet;
 
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
 import org.greenstone.gsdl3.gs3build.doctypes.DocumentInterface;
 
@@ -22,4 +25,5 @@
   String label;
   String type;
+    METSDivision divGroup;
 
   public static final String STRUCTURE_TYPE = "Structure";
@@ -30,4 +34,5 @@
     this.label    = label;
     this.type     = type;
+    this.divGroup = null;
   }
 
@@ -108,4 +113,40 @@
   }
 
+
+     /*
+      *
+      * parse an XML Element as a METSStructure Section
+      *
+      * @param <code>Element</code> the XML element which represents
+      *  the mets:structMap itself 
+      */
+    
+     public static METSStructure parseXML(Element element) 
+     {
+ 	String structId = element.getAttribute("ID");
+ 	String structType = element.getAttribute("TYPE");
+ 	String structLabel = element.getAttribute("LABEL");
+ 
+ 	METSStructure thisStruct = new METSStructure (structId, structType, structLabel);
+ 	
+ 	NodeList divSecs = element.getChildNodes();
+ 	if (divSecs != null) {
+ 	    for (int c = 0; c < divSecs.getLength(); c++) {
+ 		if (divSecs.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
+ 		    continue;
+ 		}
+ 		Element divElement = (Element) divSecs.item(c);
+ 		String divName = divElement.getNodeName();
+ 		if (divName.equals("mets:div")) {
+ 		    METSDivision division = METSDivision.parseXML(divElement);
+ 		    thisStruct.addDivision(division);
+ 		} else {
+ 		    System.err.println("Error: mets:structMap was expecting mets:div but got "+divName);
+ 		}
+ 	    }
+ 	}
+ 	return thisStruct;
+     }
+ 
   /**
    *  Write this structure in XML(METS) format to a <code>PrintWriter</code>
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructureSet.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructureSet.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructureSet.java	(revision 8461)
@@ -11,4 +11,9 @@
 import java.sql.SQLException;
 import java.sql.ResultSet;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+
 
 import org.greenstone.gsdl3.gs3build.doctypes.DocumentInterface;
@@ -100,4 +105,15 @@
     return null;
   }
+    public static METSStructureSet parseXML(NodeList structMapSecs)
+     {
+ 	METSStructureSet set = new METSStructureSet();
+ 
+ 	for (int c = 0; c < structMapSecs.getLength(); c++) {
+ 	    METSStructure structure = METSStructure.parseXML((Element) structMapSecs.item(c));
+ 	    set.addStructure(structure);
+ 	}
+ 	return set;
+     }
+        
 
   public void write(PrintWriter writer)
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/NamespaceFactory.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/NamespaceFactory.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/NamespaceFactory.java	(revision 8461)
@@ -32,5 +32,6 @@
 	 */
 	public static METSNamespace initNamespace(String name, Element element)
-	{	return null;
+    {	//return null;
+	return new SimpleNamespace(name);
 	}
 
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/OrderedNamespace.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/OrderedNamespace.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/OrderedNamespace.java	(revision 8461)
@@ -167,4 +167,10 @@
     return -1;
   }
+
+     public Iterator getMetadataNames() 
+     {
+ 	return this.metadataList.iterator();
+     }
+ 
 
   /**
@@ -212,4 +218,5 @@
   protected boolean writeItem(PrintWriter writer, NamespaceItem item)
   { // Do some default sillinesses
+      //writer.write("         ");
     writer.write(XMLTools.getOpenTag(this.name, item.getLabel()));
     
Index: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/SimpleNamespace.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/SimpleNamespace.java	(revision 8460)
+++ trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/SimpleNamespace.java	(revision 8461)
@@ -164,4 +164,9 @@
   }
 
+    public Iterator getMetadataNames() 
+    {
+ 	return this.metadataMap.keySet().iterator();
+    }
+
   /**
    *  Write out the metadata to an XML file through a <code>PrintWriter</code>.
@@ -221,10 +226,12 @@
       while (values.hasNext())
       { String value = values.next().toString();
-
-        writer.write(XMLTools.getOpenTag(this.name, label));
-	
+String metaTagName = "Metadata name=" +'"'+ label +'"';
+      //writer.write(XMLTools.getOpenTag(this.name, label));
+	writer.write("         ");
+	writer.write(XMLTools.getOpenTag(this.name, metaTagName));
 	writer.write(value);
 	
-	writer.println(XMLTools.getCloseTag(this.name, label));
+	//writer.println(XMLTools.getCloseTag(this.name, label));
+writer.println(XMLTools.getCloseTag(this.name, "Metadata"));
       }
     }
