[GeoNetwork-devel] Namespace prefix in PropertyName and CSW server

Hi all,

I am trying to query the GeoNetwork CSW 2.0.2 server with our CSW client.

I have the following problem : the CSW client put a namespace prefix in the PropertyName of the filter (this is allowed in the OGC Filter 1.1.0)
GeoNetwork don't understand them. I tracked it down, it's because the OGC filter is translated to a Lucene search without any change of the PropertyName.

Examle CSW query

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope&quot;&gt;
  <soapenv:Body>
    <GetRecords xmlns="http://www.opengis.net/cat/csw/2.0.2&quot; xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0&quot; xmlns:dc="http://purl.org/dc/elements/1.1/&quot; xmlns:dct="http://purl.org/dc/terms/&quot; xmlns:gmd="http://www.isotc211.org/2005/gmd&quot; xmlns:gml="http://www.opengis.net/gml&quot; xmlns:ogc="http://www.opengis.net/ogc&quot; xmlns:ows="http://www.opengis.net/ows&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema\-instance&quot; maxRecords="9999" outputFormat="application/xml" outputSchema="http://www.isotc211.org/2005/gmd&quot; resultType="results" service="CSW" startPosition="1" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2\.\./\.\./\.\./\.\./\.\./CSW\-discovery\.xsd&quot;&gt;
      <Query typeNames="csw:Record">
        <ElementSetName>brief</ElementSetName>
        <Constraint version="1.1.0">
          <ogc:Filter>
            <ogc:PropertyIsLike escape="\" singleChar="?" wildCard="*">
              <ogc:PropertyName>apiso:AnyText</ogc:PropertyName>
              <ogc:Literal>Y*</ogc:Literal>
            </ogc:PropertyIsLike>
          </ogc:Filter>
        </Constraint>
      </Query>
    </GetRecords>
  </soapenv:Body>
</soapenv:Envelope>

As namespace prefix are allowed, I think it's preferable to modify GeoNetwork to handle it. I don't know how Lucene work, so I modifyed the XSL translator style sheet to remove the namespace prefix. The modifications are:

<xsl:template match="ogc:PropertyIsLike">
    <xsl:variable name="property">
      <xsl:call-template name="remove_prefix">
        <xsl:with-param name="value" select="ogc:PropertyName"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="ogc:PropertyName and ogc:Literal">
        <WildcardQuery fld="{$property}" txt="{translate(translate(ogc:Literal, @wildCard, '*'), @singleChar, '?')}"/>
      </xsl:when>
      <xsl:otherwise>
        <error type="Unknown content of expression">
          <xsl:copy-of select="."/>
        </error>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- ============================================================================= -->
  <xsl:template name="remove_prefix">
    <xsl:param name="value"/>
    <xsl:choose>
      <xsl:when test="contains($value,':')">
        <xsl:value-of select="substring-after($value,':')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$value"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

With this modification, the our CSW client is working with GeoNetwork. Is it the correct approach, or a real handling of namespace prefix is possible with Lucene?

If this is correct, I will modify the whole XSL and send it to the list, so a commiter can put it in SVN.

Thanks

Pierre-Yann Bridé
Application Engineer

GeoTask AG
Margarethenstrasse 38
4053 Basel
Schweiz/Suisse
http://www.geotask.ch

Telefon / téléphone: +41 61 337 84 84
Fax / télécopie: +41 61 337 84 85
E-Mail / courriel: mailto:pybride@anonymised.com

Hello Pierre-Yann,

Bridé, Pierre-Yann wrote:

I am trying to query the GeoNetwork CSW 2.0.2 server with our CSW client.

I have the following problem : the CSW client put a namespace prefix in the PropertyName of the filter (this is allowed in the OGC Filter 1.1.0)
GeoNetwork don't understand them. I tracked it down, it's because the OGC filter is translated to a Lucene search without any change of the PropertyName.

Yep, that's an issue we also noticed in using namespace in propertyName
(see CSW Search parameters in [1]). We made a fix for that and also make
propertyName in configuration option (see OGC-CSW Configuration system
in [1]).

So the fix will be part of the patch we're going to propose to
GeoNetwork CSW.

One question about your client : is it available for test also ? is this
a web client or an application ?

Ciao.
Francois

[1] http://trac.osgeo.org/geonetwork/wiki/CSW202Improvements

Examle CSW query

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope&quot;&gt;
  <soapenv:Body>
    <GetRecords xmlns="http://www.opengis.net/cat/csw/2.0.2&quot; xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0&quot; xmlns:dc="http://purl.org/dc/elements/1.1/&quot; xmlns:dct="http://purl.org/dc/terms/&quot; xmlns:gmd="http://www.isotc211.org/2005/gmd&quot; xmlns:gml="http://www.opengis.net/gml&quot; xmlns:ogc="http://www.opengis.net/ogc&quot; xmlns:ows="http://www.opengis.net/ows&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema\-instance&quot; maxRecords="9999" outputFormat="application/xml" outputSchema="http://www.isotc211.org/2005/gmd&quot; resultType="results" service="CSW" startPosition="1" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2\.\./\.\./\.\./\.\./\.\./CSW\-discovery\.xsd&quot;&gt;
      <Query typeNames="csw:Record">
        <ElementSetName>brief</ElementSetName>
        <Constraint version="1.1.0">
          <ogc:Filter>
            <ogc:PropertyIsLike escape="\" singleChar="?" wildCard="*">
              <ogc:PropertyName>apiso:AnyText</ogc:PropertyName>
              <ogc:Literal>Y*</ogc:Literal>
            </ogc:PropertyIsLike>
          </ogc:Filter>
        </Constraint>
      </Query>
    </GetRecords>
  </soapenv:Body>
</soapenv:Envelope>

As namespace prefix are allowed, I think it's preferable to modify GeoNetwork to handle it. I don't know how Lucene work, so I modifyed the XSL translator style sheet to remove the namespace prefix. The modifications are:

<xsl:template match="ogc:PropertyIsLike">
    <xsl:variable name="property">
      <xsl:call-template name="remove_prefix">
        <xsl:with-param name="value" select="ogc:PropertyName"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="ogc:PropertyName and ogc:Literal">
        <WildcardQuery fld="{$property}" txt="{translate(translate(ogc:Literal, @wildCard, '*'), @singleChar, '?')}"/>
      </xsl:when>
      <xsl:otherwise>
        <error type="Unknown content of expression">
          <xsl:copy-of select="."/>
        </error>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- ============================================================================= -->
  <xsl:template name="remove_prefix">
    <xsl:param name="value"/>
    <xsl:choose>
      <xsl:when test="contains($value,':')">
        <xsl:value-of select="substring-after($value,':')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$value"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

With this modification, the our CSW client is working with GeoNetwork. Is it the correct approach, or a real handling of namespace prefix is possible with Lucene?

If this is correct, I will modify the whole XSL and send it to the list, so a commiter can put it in SVN.

Thanks

Pierre-Yann Bridé
Application Engineer

GeoTask AG
Margarethenstrasse 38
4053 Basel
Schweiz/Suisse
http://www.geotask.ch

Telefon / téléphone: +41 61 337 84 84
Fax / télécopie: +41 61 337 84 85
E-Mail / courriel: mailto:pybride@anonymised.com

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork