Fix PT_FreeText handling in eu-geodcat-ap-semiceu/view.xsl#9333
Conversation
…cat-ap-semiceu/view.xsl
|
@laers is that change also in the SEMICeu repository? See https://github.com/SEMICeu/iso-19139-to-dcat-ap/commits/main/iso-19139-to-dcat-ap.xsl In https://github.com/geonetwork/core-geonetwork/pull/9111/commits, SEMICeu conversion was aligned couple of times. Updated today. Maybe you can check that PR and see if it resolve your case? and we can align GeoNetwork with latest version of the conversion. |
… with PT_FreeText fields
There was a problem hiding this comment.
I tested the XLST (eu-geodcat-ap-semiceu/view.xsl) from #9111 but it did not work... I've updated my PR to build on top of the changes from #9111. The approach is the same, but with the following additional fixes required for Saxon 9.1 Basic compatibility:
- xsl:function is not supported in Saxon 9.1 Basic — local:getTextContent and local:normalize-number have been replaced with inline XPath equivalents (normalize-space(*[self::gco:CharacterString|self::gmx:Anchor]) and format-number())
- as="node()", as="xs:string" type annotations and xsl:sequence removed
- *[self::gco:CharacterString|gmx:Anchor] → *[self::gco:CharacterString|self::gmx:Anchor] (missing self:: prefix caused runtime errors with PT_FreeText fields)
- electronicMailAddress/* → electronicMailAddress/gco:CharacterString to prevent malformed mailto URIs
Tested on our Test-GeoNetwork instance (test.geodata-info.dk) with ISO 19139 records using xsi:type="PT_FreeText_PropertyType" and validated successfully against the data.europa.eu MQA SHACL Validator.
I have made a PR with the changes to #116
159468f to
a366409
Compare
laers
left a comment
There was a problem hiding this comment.
- Locale lookup root context: //gmd:PT_Locale[...] failed with The root of the tree containing the context item is not a document node when called from within a result-tree-fragment. Fixed by using root(.)//gmd:PT_Locale[...].
- PT_Locale structure variance: records converted by GeoNetwork from ISO 19115-3.2018 use gmd:otherLocale/gmd:language, while native ISO 19139 records use gmd:locale/gmd:languageCode. The lookup now handles both.
- Missing PT_Locale fallback: when GeoNetwork's 19115-3→19139 conversion drops defaultLocale, PT_FreeText values for that language had no matching PT_Locale and ended up with xml:lang="". Added a fallback that uses the locale-id itself (e.g. "DA"/"EN" from locale="#DA") when the PT_Locale lookup fails.
- Duplicate prefLabel/keyword values: re-added deduplication so a PT_FreeText value identical to the primary gco:CharacterString isn't emitted twice.
- Malformed language URIs: a data quality issue in source records (codeListValue="Dansk" instead of "dan") produced invalid URIs like .../language/DANSK. Added a normalization step for common full language names.
- Text concatenation in online resource titles/descriptions: gmd:name/gmd:description for foaf:page links used an unrestricted * selector, causing PT_FreeText text to concatenate across languages. Restricted to gco:CharacterString/gmx:Anchor.
All fixes verified against multiple real production records (Saxon 9.1 Basic) with no remaining empty xml:lang attributes or duplicated content.
Attempt to serve ISO 19139 records via CSW with outputSchema=http://data.europa.eu/930/#semiceu fails with either:
The root cause is that many ISO 19139 records use xsi:type="gmd:PT_FreeText_PropertyType" on text fields such as individualName, name, description and electronicMailAddress. This means these elements have multiple child nodes — both a gco:CharacterString and a gmd:PT_FreeText element — rather than a single child.
Additionally, the LocalisedString template emitted duplicate language-tagged literals when a PT_FreeText locale value was identical to the primary gco:CharacterString value.
Changes:
Tested against https://data.europa.eu/mqa/shacl-validator-ui/data-provision
Response with current XSLT:
https://geodata-info.dk/srv/dan/csw?service=CSW&version=2.0.2&request=GetRecordById&outputSchema=http://data.europa.eu/930/%23semiceu&elementsetname=full&id=4aaf72e6-b4eb-4c4f-a472-d8639f60710f&resulttype=results&constraintlanguage=FILTER&constraint_language_version=1.1.0&namespace=xmlns(gmd=http%3A%2F%2Fwww.isotc211.org%2F2005%2Fgmd)&typenames=gmd:MD_Metadata&constraint=%3Cogc%3AFilter%20xmlns%3Acsw%3D%22http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2F2.0.2%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%3C%2Fogc%3AFilter%3E
Response with fixed XSLT:
https://test.geodata-info.dk/srv/dan/csw?service=CSW&version=2.0.2&request=GetRecordById&outputSchema=http://data.europa.eu/930/%23semiceu&elementsetname=full&id=4aaf72e6-b4eb-4c4f-a472-d8639f60710f&resulttype=results&constraintlanguage=FILTER&constraint_language_version=1.1.0&namespace=xmlns(gmd=http%3A%2F%2Fwww.isotc211.org%2F2005%2Fgmd)&typenames=gmd:MD_Metadata&constraint=%3Cogc%3AFilter%20xmlns%3Acsw%3D%22http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2F2.0.2%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%3C%2Fogc%3AFilter%3E