Index: /trunk/gsdl3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java
===================================================================
--- /trunk/gsdl3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java	(revision 13977)
+++ /trunk/gsdl3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java	(revision 13978)
@@ -205,5 +205,5 @@
 	
 	for (int k=0; k<responses.getLength(); k++) {
-	    String coll_name = GSPath.getFirstLink(((Element)responses.item(k)).getAttribute(GSXML.FROM_ATT));
+	    String coll_name = GSPath.removeLastLink(((Element)responses.item(k)).getAttribute(GSXML.FROM_ATT));
 	    NodeList nodes = ((Element)responses.item(k)).getElementsByTagName(GSXML.DOC_NODE_ELEM);
 	    if (nodes==null || nodes.getLength()==0) continue;
@@ -261,15 +261,16 @@
 	Element metadata_response = (Element)this.router.process(metadata_message);
 	logger.debug("metadata response = "+this.converter.getPrettyString(metadata_response));
-
-	NodeList coll_responses = metadata_response.getElementsByTagName(GSXML.COLLECTION_ELEM);
+	NodeList coll_responses = metadata_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
 	ArrayList valid_colls = new ArrayList();
 	ArrayList valid_coll_names = new ArrayList();
 	for (int i=0; i<coll_responses.getLength(); i++) {
-	    Element coll = (Element)coll_responses.item(i);
+	    Element response = (Element)coll_responses.item(i);
+	    Element coll = (Element)GSXML.getChildByTagName(response, GSXML.COLLECTION_ELEM);
 	    Element service_list = (Element)GSXML.getChildByTagName(coll, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
 	    if (service_list==null) continue;
 	    Element query_service = GSXML.getNamedElement(service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, TEXT_QUERY_SERVICE); // should be AbstractSearch.TEXT_QUERY_SERVICE
 	    if (query_service == null) continue;
-	    String coll_id = coll.getAttribute(GSXML.NAME_ATT);
+	    // use the name of the response in case we are talking to a remote collection, not the name of the collection.
+	    String coll_id = response.getAttribute(GSXML.FROM_ATT);
 	    String coll_name = coll_id+": "+GSXML.getDisplayText(coll, GSXML.DISPLAY_TEXT_NAME, "en", "en"); // just use english for now until we do some caching or something
 	    valid_colls.add(coll_id);
@@ -298,5 +299,5 @@
 	result.setAttribute(GSXML.FROM_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE);
 	result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
-	
+
 	String lang = request.getAttribute(GSXML.LANG_ATT);
 	// Get the parameters of the request
@@ -306,5 +307,5 @@
 	    return result;  // Return the empty result
 	}
-	
+
 	NodeList query_doc_list = request.getElementsByTagName(GSXML.DOC_NODE_ELEM);
 	if (query_doc_list.getLength()==0) {
@@ -316,5 +317,5 @@
 	Element result_node_list = this.doc.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
 	result.appendChild(result_node_list);
-	
+
 	// get all the metadata params
 	Element new_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
@@ -335,10 +336,10 @@
 	    coll_items.appendChild(this.doc.importNode(doc_node, true));
 	}
-	
+
 	// create teh individual requests
 	Element meta_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
 	Set mapping_set = coll_map.entrySet();
 	Iterator iter = mapping_set.iterator();
-	
+
 	while (iter.hasNext()) {
 	    Map.Entry e = (Map.Entry)iter.next();
@@ -351,4 +352,5 @@
 	    
 	}
+
 	Element meta_result = this.router.process(meta_request_message);
 	
@@ -358,5 +360,5 @@
 	NodeList meta_responses = meta_result.getElementsByTagName(GSXML.RESPONSE_ELEM);
 	for (int i=0; i<meta_responses.getLength(); i++) {
-	    String collname = GSPath.getFirstLink(((Element)meta_responses.item(i)).getAttribute(GSXML.FROM_ATT));
+	    String collname = GSPath.removeLastLink(((Element)meta_responses.item(i)).getAttribute(GSXML.FROM_ATT));
 	    Element first_elem = (Element)GSXML.getNodeByPath(meta_responses.item(i), "documentNodeList/documentNode");
 	    coll_map.put(collname, first_elem);
