Skip to content

Commit

Permalink
extract file storage if not available
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrighi committed Oct 8, 2024
1 parent ef29c74 commit 7678f7f
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions xslt/mmd-to-NOiso.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,25 @@
<xsl:element name="gmd:MD_Distribution">

<!--format-->
<xsl:apply-templates select="mmd:storage_information" />
<xsl:choose>
<xsl:when test="mmd:storage_information and mmd:storage_information/mmd:file_format !=''">
<xsl:apply-templates select="mmd:storage_information" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="mmd:data_access[mmd:type = 'HTTP']">
<xsl:call-template name="format">
<xsl:with-param name="ext" select="mmd:data_access[mmd:type = 'HTTP']/mmd:resource" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="format">
<xsl:with-param name="ext" select="mmd:data_access[mmd:type = 'OPeNDAP']/mmd:resource" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>

<xsl:element name="gmd:distributor">
<xsl:apply-templates select="mmd:data_center" />
Expand Down Expand Up @@ -767,6 +785,48 @@
</xsl:element>
</xsl:template>

<xsl:template name="format">
<xsl:param name="ext"/>
<xsl:variable name="suffix">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="$ext"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="gmd:distributionFormat">
<xsl:element name="gmd:MD_Format">
<xsl:element name="gmd:name">
<xsl:element name="gco:CharacterString">
<xsl:variable name="format_mapping" select="document('')/*/mapping:file_format[@mmd=$suffix]/@iso" />
<xsl:value-of select="$format_mapping" />
</xsl:element>
</xsl:element>
<xsl:element name="gmd:version">
<xsl:attribute name="gco:nilReason">unknown</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>

<xsl:template name="get-file-extension">
<xsl:param name="path"/>
<xsl:choose>
<xsl:when test="contains($path, '/')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path, '.')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '.')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('.',$path)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<!--iso topic category-->
<xsl:template match="mmd:iso_topic_category">
<xsl:element name="gmd:topicCategory">
Expand Down Expand Up @@ -1414,7 +1474,6 @@
</xsl:element>
</xsl:template>


<!-- Mappings for data_access type specification to OSGEO -->
<mapping:data_access_type_osgeo iso="OGC:WMS" mmd="OGC WMS" />
<mapping:data_access_type_osgeo iso="OGC:WCS" mmd="OGC WCS" />
Expand All @@ -1425,6 +1484,8 @@

<mapping:language_code iso="eng" mmd="en" />

<mapping:file_format iso="NetCDF" mmd=".nc" />

<!--Mapping to https://register.geonorge.no/metadata-kodelister/lisenser-->
<mapping:use_constraint geon="Creative Commons 0" mmd="CC0-1.0" />
<mapping:use_constraint geon="Creative Commons BY 3.0 (CC BY 3.0)" mmd="CC-BY-3.0" />
Expand Down

0 comments on commit 7678f7f

Please sign in to comment.