core-geonetwork icon indicating copy to clipboard operation
core-geonetwork copied to clipboard

CSW GetRecords with elementSetName=full returns "Invalid XPath expression"

Open streino opened this issue 9 months ago • 0 comments

Describe the bug

On some catalogs, the following request :

geonetwork/srv/fre/csw-test?service=CSW&version=2.0.2&namespace=xmlns:csw=http://www.opengis.net/cat/csw&outputFormat=application/xml&outputSchema=http://www.isotc211.org/2005/gmd&request=GetRecords&typeNames=csw:Record&resultType=results&elementSetName=full

returns no results, with error in comments :

<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
  <csw:SearchStatus timestamp="2024-05-07T16:02:24" />
  <csw:SearchResults numberOfRecordsMatched="41" numberOfRecordsReturned="10" elementSet="full" nextRecord="11">
    <!-- Invalid XPath expression: "/csw:Record//": Expected one of '.', '..', '@', '*', <QName> -->
    <!-- Invalid XPath expression: "/csw:Record//": Expected one of '.', '..', '@', '*', <QName> -->
    ...
  </csw:SearchResults>
</csw:GetRecordsResponse>

To Reproduce

I was able to reproduce with the following steps:

  1. Go to 'Geonetwork admin > Settings > CSW > Customize element set'
  2. Click 'Add'
  3. Enter a single space character in the XPath definition and save
  4. Run a GetRecords request on the CSW endpoint with elementsetName=full => error
  5. Remove the invalid xpath from step 3 and save
  6. Re-run the request from step 4 => ok

Expected behavior

The GetRecords request returns results.

Log file

log.txt

Additional context

Encountered issue on GN 3.10.4 and 4.4.1.

The following changes in the problematic request will return results as expected:

  • Set elementsetName to brief or summary insteand of full.
  • Replace elementsetName=full with ElementName=//*.

I traced the issue to the following: Invalid xpath can be added to elemNames, then processed.

Possibly related issues :

  • https://sourceforge.net/p/geonetwork/mailman/message/51783917/
  • https://github.com/geonetwork/core-geonetwork/issues/1901

streino avatar May 07 '24 14:05 streino