Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java	(revision 27717)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java	(revision 27718)
@@ -197,4 +197,5 @@
 		String nameToGet = (String) params.get("name");
 		String matchToGet = (String) params.get("match");
+		String xPath = (String) params.get("xpath");
 
 		String fullNamespace;
@@ -218,6 +219,32 @@
 			XMLConverter converter = new XMLConverter();
 			Document xslDoc = converter.getDOM(xslFile, "UTF-8");
-
-			NodeList templateElems = xslDoc.getElementsByTagNameNS(fullNamespace, nodeName);
+			Element rootElem = xslDoc.getDocumentElement();
+
+			if (xPath != null && xPath.length() > 0)
+			{
+				String[] pathSegments = xPath.split("/");
+				for (int i = 1; i < pathSegments.length; i++)
+				{
+					String currentSegment = pathSegments[i];
+					int count = 1;
+					if (currentSegment.contains("["))
+					{
+						count = Integer.parseInt(currentSegment.substring(currentSegment.indexOf("[") + 1, currentSegment.indexOf("]")));
+						currentSegment = currentSegment.substring(0, currentSegment.indexOf("["));
+					}
+					Node child = rootElem.getFirstChild();
+					while (count > 0)
+					{
+						if (child.getNodeType() == Node.ELEMENT_NODE && ((Element) child).getNodeName().equals(currentSegment))
+						{
+							rootElem = (Element) child;
+							count--;
+						}
+						child = child.getNextSibling();
+					}
+				}
+			}
+
+			NodeList templateElems = rootElem.getElementsByTagNameNS(fullNamespace, nodeName);
 
 			if (nameToGet != null && nameToGet.length() != 0)
@@ -323,4 +350,5 @@
 		String nameToSave = (String) params.get("name");
 		String matchToSave = (String) params.get("match");
+		String xPath = (String) params.get("xpath");
 		String xml = (String) params.get("xml");
 
@@ -345,4 +373,31 @@
 			XMLConverter converter = new XMLConverter();
 			Document xslDoc = converter.getDOM(xslFile, "UTF-8");
+
+			Element rootElem = xslDoc.getDocumentElement();
+
+			if (xPath != null && xPath.length() > 0)
+			{
+				String[] pathSegments = xPath.split("/");
+				for (int i = 1; i < pathSegments.length; i++)
+				{
+					String currentSegment = pathSegments[i];
+					int count = 1;
+					if (currentSegment.contains("["))
+					{
+						count = Integer.parseInt(currentSegment.substring(currentSegment.indexOf("[") + 1, currentSegment.indexOf("]")));
+						currentSegment = currentSegment.substring(0, currentSegment.indexOf("["));
+					}
+					Node child = rootElem.getFirstChild();
+					while (count > 0)
+					{
+						if (child.getNodeType() == Node.ELEMENT_NODE && ((Element) child).getNodeName().equals(currentSegment))
+						{
+							rootElem = (Element) child;
+							count--;
+						}
+						child = child.getNextSibling();
+					}
+				}
+			}
 
 			NodeList templateElems = xslDoc.getElementsByTagNameNS(fullNamespace, nodeName);
@@ -472,10 +527,16 @@
 			XMLConverter converter = new XMLConverter();
 			Document xslDoc = converter.getDOM(xslFile, "UTF-8");
+			Element xslDocElem = xslDoc.getDocumentElement();
+
+			if (locationName.equals("collectionConfig"))
+			{
+				GSXSLT.modifyCollectionConfigForDebug(xslDocElem);
+			}
 
 			Element templateList = this.doc.createElement("templateList");
 			StringBuilder templateListString = new StringBuilder("[");
 
-			NodeList xslTemplateElems = xslDoc.getElementsByTagNameNS(GSXML.XSL_NAMESPACE, "template");
-			NodeList gsfTemplateElems = xslDoc.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "template");
+			NodeList xslTemplateElems = xslDocElem.getElementsByTagNameNS(GSXML.XSL_NAMESPACE, "template");
+			NodeList gsfTemplateElems = xslDocElem.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "template");
 			for (int i = 0; i < xslTemplateElems.getLength() + gsfTemplateElems.getLength(); i++)
 			{
@@ -495,4 +556,9 @@
 				{
 					templateListString.append("\"match\":\"" + currentElem.getAttribute(GSXML.MATCH_ATT) + "\",");
+				}
+
+				if (currentElem.getUserData("xpath") != null)
+				{
+					templateListString.append("\"xpath\":\"" + currentElem.getUserData("xpath") + "\",");
 				}
 				templateListString.deleteCharAt(templateListString.length() - 1);
