[GeoNetwork-users] Adding the ISO topic categories search option to Geonetwork 2.2.0

Hi list,

I've been trying to add the option for topic category search in my geonetwork 2.2
installation. In version 2.1 I had done it by searching the topic categories as plan text,
but this doesn't seem to work in geon. 2.2.

What I've done sofar is:
I've added the search option in the searchform_advanced.xsl file, in order to be able
to select the topic category:
    <tr>
      <th class="padded">
        <xsl:value-of select="/root/gui/strings/theme"/>
      </th>
      <td class="padded">
        <select class="content" id="topicCat" name="topicCat">
          <xsl:for-each select="/root/gui/strings/topicCategoryCode">
            <option>
              <xsl:attribute name="value">
               <xsl:value-of select="@value"/>
              </xsl:attribute>
              <xsl:value-of select="."/>
            </option>
          </xsl:for-each>
        </select>
      </td>
    </tr>

I have also put in the localization files the corresponding values:
    <topicCategoryCode value="">-- Any --</topicCategoryCode>
   <topicCategoryCode value="Farming">Farming</topicCategoryCode>
   <topicCategoryCode value="Biota">Biota</topicCategoryCode>
....

I add the corresponding entry in lucene.xsl file:
  <!-- topicCat -->
  <xsl:call-template name="textField">
   <xsl:with-param name="expr" select="/request/topicCat"/>
   <xsl:with-param name="field" select="'topicCat'"/>
  </xsl:call-template>

I then fetch the topic category parameter in the gn_search.js and send it
via the searchform (and it is sent correctly):

function runAdvancedSearch()
{
...
pars += fetchParam('topicCat');
...

Sofar so good. In the geonetwork 2.1 the next (and final) step would be to
open the 19139.xsl file and remove the codeListValue search in the topicCategory
that is from
gmd:topicCategory/gmd:MD_TopicCategoryCode/@codeListValue
to
gmd:topicCategory/gmd:MD_TopicCategoryCode
in order to search for the topic category as plain text, because there wasn't any
codeList for the topicCategories back then.
In Geonetwork 2.2 I cannot find the 19139.xsl file. Also, it seems that the
codeLists are ther, but I don't know how to use them for the topic category searches.

Any ideas?

Thank you very much,
Dimitrios Simos

Hi Dimitrios,

Here you have some tips to integrate the topic category search in
Geonetwork.

What I've done sofar is:
I've added the search option in the searchform_advanced.xsl file, in order
to be able
to select the topic category:
   <tr>
     <th class="padded">
       <xsl:value-of select="/root/gui/strings/theme"/>
     </th>
     <td class="padded">
       <select class="content" id="topicCat" name="topicCat">
         <xsl:for-each select="/root/gui/strings/topicCategoryCode">
           <option>
             <xsl:attribute name="value">
              <xsl:value-of select="@value"/>
             </xsl:attribute>
             <xsl:value-of select="."/>
           </option>
         </xsl:for-each>
       </select>
     </td>
   </tr>

You should use codelist file instead of define once again the codelist in
your loc file.

First you could add this entry to the <gui> tag, in your config.xml file
under your WEB-INF repository :
<xml name="iso19139" base="xml/schemas/iso19139/loc" file="codelists.xml" />

And then , you should define your search option in the
searchform_advanced.xsl file.

<select class="content" name="topicCat" id="topicCat">
    <option value="">
        <xsl:if test="/root/gui/searchDefaults/topicCat=''">
            <xsl:attribute name="selected"/>
        </xsl:if>
        <xsl:value-of select="/root/gui/strings/any"/>
    </option>
    <xsl:for-each
select="/root/gui/iso19139/codelist[@name='gmd:MD_TopicCategoryCode']/entry">
        <xsl:sort select="label" order="ascending"/>
        <option value="{code}">
            <xsl:if test="label = /root/gui/searchDefaults/topicCat">
                <xsl:attribute name="selected"/>
            </xsl:if>
            <xsl:value-of select="label"/>
        </option>
    </xsl:for-each>
</select>

I have also put in the localization files the corresponding values:
   <topicCategoryCode value="">-- Any --</topicCategoryCode>
  <topicCategoryCode value="Farming">Farming</topicCategoryCode>
  <topicCategoryCode value="Biota">Biota</topicCategoryCode>
....

Obviously, this part could be remove now.

I add the corresponding entry in lucene.xsl file:
<!-- topicCat -->
<xsl:call-template name="textField">
  <xsl:with-param name="expr" select="/request/topicCat"/>
  <xsl:with-param name="field" select="'topicCat'"/>
</xsl:call-template>

Here is my entry in the lucene file :

<!-- topic category searching - - - - - - - - - - - -->
        <xsl:if test="/request/topicCat">
            <BooleanClause required="true" prohibited="false">
                <BooleanQuery>
                    <xsl:for-each select="/request/topicCat">
                        <xsl:if test="string(/request/topicCat) != ''">
                            <BooleanClause required="false"
prohibited="false">
                                <TermQuery fld="topicCat" txt="{.}"/>
                            </BooleanClause>
                        </xsl:if>
                    </xsl:for-each>
                </BooleanQuery>
            </BooleanClause>
        </xsl:if>

I then fetch the topic category parameter in the gn_search.js and send it
via the searchform (and it is sent correctly):

function runAdvancedSearch()
{
...
pars += fetchParam('topicCat');
...

Also don't forget to reset your search option via the resetAdvancedSearch
function in the same file :

setParam('topicCat','');

Sofar so good. In the geonetwork 2.1 the next (and final) step would be to
open the 19139.xsl file and remove the codeListValue search in the
topicCategory
that is from
gmd:topicCategory/gmd:MD_TopicCategoryCode/@codeListValue
to
gmd:topicCategory/gmd:MD_TopicCategoryCode
in order to search for the topic category as plain text, because there
wasn't any
codeList for the topicCategories back then.

Have a look at the index-fields.xsl under the folder
.../xml/schemas/iso19139/index-fields.xsl (~ line 150).
Now indexed fields are defined for each schema, in its folder.

HTH,

--
Mathieu Coudert
mcoudert@anonymised.com