Changeset 14183

Show
Ignore:
Timestamp:
15.06.2007 22:28:11 (12 years ago)
Author:
xiao
Message:

instead of simply retrieving the first child of format element in the search element, modify to find the format element which has at least one gsf:template child element

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractSearch.java

    r14002 r14183  
    124124    if (format==null) { 
    125125        String path = GSPath.appendLink(GSXML.SEARCH_ELEM, GSXML.FORMAT_ELEM); 
    126         format = (Element) GSXML.getNodeByPath(extra_info, path); 
    127     } 
    128     //Element format = (Element) GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM); 
     126 
     127      //note by xiao: instead of retrieving the first 'format' element inside the 'search' 
     128      // element, we are trying to find the real format element which has at least one 
     129      // 'gsf:template' child element. (extra_info is collectionConfig.xml) 
     130      //format = (Element) GSXML.getNodeByPath(extra_info, path); 
     131      Element search_elem = (Element) GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM); 
     132      NodeList format_elems = null; 
     133      if (search_elem != null) { 
     134        format_elems = search_elem.getElementsByTagName(GSXML.FORMAT_ELEM); 
     135      } 
     136      for(int i=0; i<format_elems.getLength(); i++) { 
     137          format = (Element)format_elems.item(i); 
     138          if (format.getElementsByTagName("gsf:template").getLength() != 0) { 
     139            break; 
     140          } 
     141      } 
     142    }//end of if(format==null) 
     143    // 
    129144    if (format != null) { 
    130145        this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(format, true));