core-geonetwork
core-geonetwork copied to clipboard
CSW GetRecords with elementSetName=full returns "Invalid XPath expression"
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:
- Go to 'Geonetwork admin > Settings > CSW > Customize element set'
- Click 'Add'
- Enter a single space character in the XPath definition and save
- Run a GetRecords request on the CSW endpoint with
elementsetName=full
=> error - Remove the invalid xpath from step 3 and save
- Re-run the request from step 4 => ok
Expected behavior
The GetRecords request returns results.
Log file
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
tobrief
orsummary
insteand offull
. - Replace
elementsetName=full
withElementName=//*
.
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