Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java	(revision 37513)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java	(revision 37514)
@@ -124,8 +124,9 @@
 		// add the format info into the response
 		Element format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.FORMAT_ELEM);
+                Element this_format = null;
 		if (format_elem != null)
 		{
 			// find the one for the classifier we are in
-			Element this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
+			this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
 			if (this_format == null)
 			{
@@ -140,23 +141,13 @@
 				}
 				Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
-				// set teh format type
+				// set the format type
 				new_format.setAttribute(GSXML.TYPE_ATT, "browse");
 
 				page_response.appendChild(new_format);
-				getRequiredMetadataNames(new_format, metadata_names);
-			}
-		}
-		
-		Element extraMetaListElem = (Element) GSXML.getChildByTagName(request, GSXML.EXTRA_METADATA + GSXML.LIST_MODIFIER);
-		if(extraMetaListElem != null)
-		{
-			NodeList extraMetaList = extraMetaListElem.getElementsByTagName(GSXML.EXTRA_METADATA);
-			for(int i = 0; i < extraMetaList.getLength(); i++)
-			{
-				metadata_names.add(((Element)extraMetaList.item(i)).getAttribute(GSXML.NAME_ATT));
-			}
-		}
-
-		logger.info("extracted meta names, " + metadata_names.toString());
+			}
+		}
+                getRequiredMetadataNames(metadata_names, this_format, request);
+
+		//logger.info("extracted meta names, " + metadata_names.toString());
 		// get the browse structure for the selected node
 		Element classify_message = doc.createElement(GSXML.MESSAGE_ELEM);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java	(revision 37513)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java	(revision 37514)
@@ -126,42 +126,35 @@
 		// add the format info into the response
 		Element format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.FORMAT_ELEM);
+                Element this_format = null;
 		if (format_elem != null)
 		{
-			// find the one for the classifier we are in
-			Element this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
-			if (this_format == null)
-			{
-				this_format = (Element) GSXML.getChildByTagName(format_elem, GSXML.DEFAULT_ELEM);
-			}
-
-			if (this_format != null)
-			{
-				Element global_format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.GLOBAL_FORMAT_ELEM);
-				if (global_format_elem != null)
-				{
-					GSXSLT.mergeFormatElements(this_format, global_format_elem, false);
-				}
-
-				Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
-				extractMetadataNames(new_format, doc_meta_names, class_meta_names);
-
-				Element extraMetaListElem = (Element) GSXML.getChildByTagName(request, GSXML.EXTRA_METADATA + GSXML.LIST_MODIFIER);
-				if (extraMetaListElem != null)
-				{
-					NodeList extraMetaList = extraMetaListElem.getElementsByTagName(GSXML.EXTRA_METADATA);
-					for (int i = 0; i < extraMetaList.getLength(); i++)
-					{
-						doc_meta_names.add(((Element) extraMetaList.item(i)).getAttribute(GSXML.NAME_ATT));
-					}
-				}
+                  // find the one for the classifier we are in
+                  this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
+                  if (this_format == null)
+                  {
+                    this_format = (Element) GSXML.getChildByTagName(format_elem, GSXML.DEFAULT_ELEM);
+                  }
+
+                  if (this_format != null)
+                  {
+                    Element global_format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.GLOBAL_FORMAT_ELEM);
+                    if (global_format_elem != null)
+                    {
+                      GSXSLT.mergeFormatElements(this_format, global_format_elem, false);
+                    }
+                    
+                    Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
+                    // set the format type
+                    new_format.setAttribute(GSXML.TYPE_ATT, "browse");
+                    
+                    page_response.appendChild(new_format);
+                    
+                  }
 				
-				// set the format type
-				new_format.setAttribute(GSXML.TYPE_ATT, "browse");
-
-				page_response.appendChild(new_format);
-			}
-		}
-
-		// find out if this classifier is horizontal at top
+			
+                }
+                extractMetadataNames(doc_meta_names, class_meta_names, this_format, request);
+
+                // find out if this classifier is horizontal at top
 		Element class_list = (Element) GSXML.getChildByTagName(service_description, GSXML.CLASSIFIER_ELEM + GSXML.LIST_MODIFIER);
 		Element this_classifier = GSXML.getNamedElement(class_list, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
@@ -481,6 +474,9 @@
 	}
 
-	protected void extractMetadataNames(Element new_format, HashSet<String> doc_meta_names, HashSet<String> class_meta_names)
+  protected void extractMetadataNames(HashSet<String> doc_meta_names, HashSet<String> class_meta_names, Element new_format, Element request)
 	{
+          // for doc names, add the ones from extraMetadata
+          getRequiredMetadataNames(doc_meta_names, null, request);
+          
 		NodeList templates = new_format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "template");
 		for (int i = 0; i < templates.getLength(); i++)
@@ -493,15 +489,15 @@
 				if (match.startsWith("documentNode"))
 				{
-					getRequiredMetadataNames(template, doc_meta_names);
+                                  getRequiredMetadataNames(doc_meta_names, template, null);
 				}
 				else if (match.startsWith("classifierNode")) // not match.equals, as we want to match nodes like: classifierNode[@classifierStyle = 'VList']
 				{
-					getRequiredMetadataNames(template, class_meta_names);
+                                  getRequiredMetadataNames(class_meta_names, template, null);
 				}
 			}
 			else
 			{
-				getRequiredMetadataNames(template, doc_meta_names);
-				getRequiredMetadataNames(template, class_meta_names);
+                          getRequiredMetadataNames(doc_meta_names, template, null);
+                          getRequiredMetadataNames(class_meta_names, template, null);
 			}
 		}
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java	(revision 37513)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java	(revision 37514)
@@ -240,8 +240,7 @@
 		metadata_names.add("Title");
 		// we already got the format element earlier
-		if (format_elem != null)
-		{
-		  getRequiredMetadataNames(format_elem, metadata_names);
-		}
+                // find names from format and from extraMetadataList in the request
+                getRequiredMetadataNames(metadata_names, format_elem, request);
+		
 
 		// paging of the results is done here - we filter the list to remove unwanted entries before retrieving metadata
@@ -261,17 +260,4 @@
 		Element mr_metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_metadata_message.appendChild(mr_metadata_request);
-
-		// just get all for now - the receptionist should perhaps pass in some
-		// metadata that it wants, and QueryAction should look through the format stuff to see if there is any other?
-
-		Element extraMetaListElem = (Element) GSXML.getChildByTagName(request, GSXML.EXTRA_METADATA + GSXML.LIST_MODIFIER);
-		if(extraMetaListElem != null)
-		{
-			NodeList extraMetaList = extraMetaListElem.getElementsByTagName(GSXML.EXTRA_METADATA);
-			for(int i = 0; i < extraMetaList.getLength(); i++)
-			{
-				metadata_names.add(((Element)extraMetaList.item(i)).getAttribute(GSXML.NAME_ATT));
-			}
-		}
 
 		Element dm_param_list = createMetadataParamList(doc,metadata_names);
