Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java	(revision 30588)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java	(revision 30589)
@@ -92,109 +92,8 @@
 	}
 
-	protected void getRequiredMetadataNames(Element format, HashSet<String> meta_names)
-	{
-		extractMetadataNames(format, meta_names);
-		addLinkMetadataNames(format, meta_names);
-	}
-
-	// should change to metadataList?? and use attributes for select rather than
-	// prepending parent_ etc
-	protected void extractMetadataNames(Element format, HashSet<String> meta_names)
-	{
-		NodeList metadata_nodes = format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "metadata"); // gsf:metadata
-		for (int i = 0; i < metadata_nodes.getLength(); i++)
-		{
-			Element elem = (Element) metadata_nodes.item(i);
-			String full_name = elem.getAttribute("name");
-			String select = elem.getAttribute("select");
-			
-			String []names = full_name.split(",");
-			for(int j=0; j<names.length; j++) {
-			
-			  String name = names[j];
-			  if (!select.equals(""))
-			    {
-			      name = select + GSConstants.META_RELATION_SEP + name;
-			    }
-			  meta_names.add(name);
-			}
-		}
-
-		NodeList foreach_metadata_nodes = format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "foreach-metadata"); // gsf:foreach-metadata
-		for (int i = 0; i < foreach_metadata_nodes.getLength(); i++)
-		{
-			Element elem = (Element) foreach_metadata_nodes.item(i);
-			String name = elem.getAttribute("name");
-			String select = elem.getAttribute("select");
-
-			if (!select.equals(""))
-			{
-				name = select + GSConstants.META_RELATION_SEP + name;
-			}
-			meta_names.add(name);
-		}
-	}
-
-	protected void addLinkMetadataNames(Element format, HashSet<String> meta_names)
-	{
-		// The XSL tranform for
-		//   gsf:link type="source" 
-		// makes use of 'assocfilepath' so need to make sure it's asked for
-
-		boolean getEquivLinkMeta = false;
-
-		NodeList link_nodes = format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "link");
-		for (int i = 0; i < link_nodes.getLength(); i++)
-		{
-			Element elem = (Element) link_nodes.item(i);
-			String type = elem.getAttribute("type");
-			if (type.equals("source"))
-			{
-				meta_names.add("assocfilepath");
-				meta_names.add("srclinkFile");
-			}
-			else if (type.equals("web"))
-			{
-				meta_names.add("weblink");
-				meta_names.add("webicon");
-				meta_names.add("/weblink");
-			}
-			else if (type.equals("equivdoc"))
-			{
-				getEquivLinkMeta = true;
-			}
-		}
-
-		// get all the metadata necessary for when the user has used "gsf:equivlink"
-		// so that we can build up the equivlink from the metadata components it needs
-		link_nodes = format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "equivlinkgs3");
-		if (getEquivLinkMeta || link_nodes.getLength() > 0)
-		{
-			String[] equivlink_metanames = { "equivDocIcon", "equivDocLink", "/equivDocLink" };
-
-			for (int i = 0; i < equivlink_metanames.length; i++)
-			{
-				StringBuffer metadata = new StringBuffer();
-				metadata.append("all"); // this means the attr multiple = true;
-				metadata.append(GSConstants.META_RELATION_SEP);
-
-				metadata.append(GSConstants.META_SEPARATOR_SEP);
-				metadata.append(','); // attr separator = ","
-				metadata.append(GSConstants.META_SEPARATOR_SEP);
-				metadata.append(GSConstants.META_RELATION_SEP);
-
-				// the name of the metadata we're retrieving
-				metadata.append(equivlink_metanames[i]);
-				meta_names.add(metadata.toString());
-			}
-		}
-
-		if (format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "image").getLength() > 0)
-		{
-			meta_names.add("Thumb");
-			meta_names.add("Screen");
-			meta_names.add("SourceFile");
-		}
-	}
+  protected void getRequiredMetadataNames(Element format, HashSet<String> meta_names) {
+    GSXSLT.findExtraMetadataNames(format, meta_names);
+  }
+
 
 	protected Element createMetadataParamList(Document doc, HashSet<String> metadata_names)
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 30588)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 30589)
@@ -219,76 +219,13 @@
 			}
 
-			NodeList metadataElems = currentDoc.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "metadata"); //gsf:metadata
-			NodeList foreachMetadataElems = currentDoc.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "foreach-metadata"); //gsf:foreach-metadata
-			NodeList imageElems = currentDoc.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "image"); //gsf:image
+			HashSet<String> extra_meta_names = new HashSet<String>();
+			GSXSLT.findExtraMetadataNames(currentDoc.getDocumentElement(), extra_meta_names);
+			ArrayList<String> names = new ArrayList<String>(extra_meta_names);			
+
+			metaNames.put(currentFile.getAbsolutePath(), names);
+
 			NodeList includeElems = currentDoc.getElementsByTagNameNS(GSXML.XSL_NAMESPACE, "include");
 			NodeList importElems = currentDoc.getElementsByTagNameNS(GSXML.XSL_NAMESPACE, "import");
 
-			ArrayList<String> names = new ArrayList<String>();
-			for (int i = 0; i < metadataElems.getLength(); i++)
-			{
-				Element current = (Element) metadataElems.item(i);
-				String name = current.getAttribute(GSXML.NAME_ATT);
-				if (name != null && name.length() > 0 && !names.contains(name))
-				{
-					names.add(name);
-				}
-			}
-
-			for (int i = 0; i < foreachMetadataElems.getLength(); i++)
-			{
-				Element current = (Element) foreachMetadataElems.item(i);
-				String name = current.getAttribute(GSXML.NAME_ATT);
-				if (name != null && name.length() > 0 && !names.contains(name))
-				{
-					names.add(name);
-				}
-			}
-
-			for (int i = 0; i < imageElems.getLength(); i++)
-			{
-				Element current = (Element) imageElems.item(i);
-				String type = current.getAttribute(GSXML.TYPE_ATT);
-				if (type == null || type.length() == 0)
-				{
-					continue;
-				}
-
-				if (type.equals("source"))
-				{
-					String[] standardSourceMeta = new String[] { "SourceFile", "ImageHeight", "ImageWidth", "ImageType", "srcicon" };
-					for (String meta : standardSourceMeta)
-					{
-						if (!names.contains(meta))
-						{
-							names.add(meta);
-						}
-					}
-				}
-				else if (type.equals("screen"))
-				{
-					String[] standardScreenMeta = new String[] { "Screen", "ScreenHeight", "ScreenWidth", "ScreenType", "screenicon" };
-					for (String meta : standardScreenMeta)
-					{
-						if (!names.contains(meta))
-						{
-							names.add(meta);
-						}
-					}
-				}
-				else if (type.equals("thumb"))
-				{
-					String[] standardThumbMeta = new String[] { "Thumb", "ThumbHeight", "ThumbWidth", "ThumbType", "thumbicon" };
-					for (String meta : standardThumbMeta)
-					{
-						if (!names.contains(meta))
-						{
-							names.add(meta);
-						}
-					}
-				}
-			}
-
-			metaNames.put(currentFile.getAbsolutePath(), names);
 
 			ArrayList<String> includeAndImportList = new ArrayList<String>();
@@ -1168,5 +1105,5 @@
 			try
 			{
-				Document inlineTemplateDoc = this.converter.getDOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"" + GSXML.XSL_NAMESPACE + "\" xmlns:java=\"" + GSXML.JAVA_NAMESPACE + "\" xmlns:util=\"" + GSXML.UTIL_NAMESPACE + "\" xmlns:gsf=\"" + GSXML.GSF_NAMESPACE + "\">" + inlineTemplate + "</xsl:stylesheet>", "UTF-8");
+				Document inlineTemplateDoc = this.converter.getDOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" "+GSXML.ALL_NAMESPACES_ATTS +  "\">" + inlineTemplate + "</xsl:stylesheet>", "UTF-8");
 
 				if (_debug)
