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">
<soapenv:Body>
<GetRecords xmlns="http://www.opengis.net/cat/csw/2.0.2" xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengis.net/ows" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema\-instance" maxRecords="9999" outputFormat="application/xml" outputSchema="http://www.isotc211.org/2005/gmd" resultType="results" service="CSW" startPosition="1" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2\.\./\.\./\.\./\.\./\.\./CSW\-discovery\.xsd">
<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