geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
429 stars 489 forks source link

unparsable schema.org if iso19139:md_distribution has no description #6137

Closed pvgenuchten closed 7 months ago

pvgenuchten commented 2 years ago

on geonetwork 3.10.10 when a iso19139:md_distribution has no description, the schema.org json created is unparsable:

this xml

               <gmd:onLine>
                  <gmd:CI_OnlineResource>
                     <gmd:linkage>
                        <gmd:URL>https://files.isric.org/public/global_soil_salinity/salmap1986/</gmd:URL>
                     </gmd:linkage>
                     <gmd:protocol>
                        <gco:CharacterString>WWW:DOWNLOAD-1.0-http--download</gco:CharacterString>
                     </gmd:protocol>
                     <gmd:name>
                        <gco:CharacterString>Download GeoTIFF (1986)</gco:CharacterString>
                     </gmd:name>
                     <gmd:function>
                        <gmd:CI_OnLineFunctionCode codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_OnLineFunctionCode"
                                                   codeListValue="download"/>
                     </gmd:function>
                  </gmd:CI_OnlineResource>
               </gmd:onLine>

renders

{
description: 
}

below case is rendered fine:

 <gmd:onLine>
                  <gmd:CI_OnlineResource>
                     <gmd:linkage>
                        <gmd:URL>https://files.isric.org/public/global_soil_salinity/</gmd:URL>
                     </gmd:linkage>
                     <gmd:protocol>
                        <gco:CharacterString>WWW:DOWNLOAD-1.0-ftp--download</gco:CharacterString>
                     </gmd:protocol>
                     <gmd:name>
                        <gco:CharacterString>Download VRT files (all years)</gco:CharacterString>
                     </gmd:name>
                     <gmd:description gco:nilReason="missing">
                        <gco:CharacterString/>
                     </gmd:description>
                     <gmd:function>
                        <gmd:CI_OnLineFunctionCode codeListValue="download"
                                                   codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_OnLineFunctionCode"/>
                     </gmd:function>
                  </gmd:CI_OnlineResource>
               </gmd:onLine>
pvgenuchten commented 2 years ago

The approach to apply templates may not work if the element does not exist (also relevent for other elements) a for-each approach would be better suggestion here would be to use xsl:if

https://github.com/geonetwork/core-geonetwork/blob/bae1ba6eaabc5c7d739ccd19efc3b1a76b1cd5ea/schemas/iso19139/src/main/plugin/iso19139/formatter/jsonld/iso19139-to-jsonld.xsl#L255