Skip to content

Commit

Permalink
Merge pull request #242 from metno/issue239
Browse files Browse the repository at this point in the history
parent/child support and some minor updates to xsl
  • Loading branch information
ferrighi authored Feb 29, 2024
2 parents 7f27b37 + 62de092 commit 24ce5a8
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 80 deletions.
27 changes: 24 additions & 3 deletions xslt/mmd-to-dif.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
xmlns:dif="http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/"
xmlns:mmd="http://www.met.no/schema/mmd"
xmlns:mapping="http://www.met.no/schema/mmd/mmd2dif"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0">

<xsl:key name="isoc" match="skos:Collection[@rdf:about='https://vocab.met.no/mmd/ISO_Topic_Category']/skos:member/skos:Concept" use="skos:prefLabel"/>
<xsl:variable name="isoLUD" select="document('../thesauri/mmd-vocabulary.xml')"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<xsl:template match="/mmd:mmd">
Expand Down Expand Up @@ -50,6 +55,7 @@
<xsl:apply-templates select="mmd:abstract" />
<xsl:apply-templates select="mmd:related_information"/>
<xsl:apply-templates select="mmd:data_access" />
<xsl:apply-templates select="mmd:related_dataset" />
<xsl:apply-templates select="mmd:quality" />

<xsl:element name="dif:Metadata_Name">CEOS IDN DIF</xsl:element>
Expand Down Expand Up @@ -83,6 +89,14 @@
</xsl:if>
</xsl:template>

<xsl:template match="mmd:related_dataset">
<xsl:if test="@relation_type = 'parent' and . !=''">
<xsl:element name="dif:Parent_DIF">
<xsl:value-of select="." />
</xsl:element>
</xsl:if>
</xsl:template>

<xsl:template match="mmd:last_metadata_update">
<xsl:if test="mmd:update/mmd:type = 'Created'">
<xsl:element name="dif:DIF_Creation_Date">
Expand Down Expand Up @@ -419,9 +433,14 @@
</xsl:template>

<xsl:template match="mmd:iso_topic_category">
<xsl:variable name="isov" select="." />
<xsl:for-each select="$isoLUD">
<xsl:value-of select ="name()" />
<xsl:variable name="isoe" select="key('isoc',$isov)/skos:altLabel"/>
<xsl:element name="dif:ISO_Topic_Category">
<xsl:value-of select="." />
<xsl:value-of select="$isoe" />
</xsl:element>
</xsl:for-each>
</xsl:template>

<xsl:template match="mmd:keywords">
Expand Down Expand Up @@ -497,9 +516,11 @@
</xsl:template>

<xsl:template match="mmd:personnel">
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:element name="dif:Personnel">
<xsl:element name="dif:Role">
<xsl:value-of select="mmd:role" />
<xsl:value-of select="translate(mmd:role,$lowercase,$uppercase)" />
</xsl:element>
<!--
<xsl:element name="dif:First_Name">
Expand Down Expand Up @@ -556,7 +577,7 @@
<xsl:element name="dif:Related_URL">
<xsl:element name="dif:URL_Content_Type">
<xsl:element name="dif:Type">
<xsl:text>VIEW DATASET LANDING PAGE</xsl:text>
<xsl:text>VIEW DATA SET LANDING PAGE</xsl:text>
</xsl:element>
</xsl:element>
<xsl:element name="dif:URL">
Expand Down
34 changes: 31 additions & 3 deletions xslt/mmd-to-dif10.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
xmlns:dif="http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/"
xmlns:mmd="http://www.met.no/schema/mmd"
xmlns:mapping="http://www.met.no/schema/mmd/mmd2dif"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0">
<xsl:key name="isoc" match="skos:Collection[@rdf:about='https://vocab.met.no/mmd/ISO_Topic_Category']/skos:member/skos:Concept" use="skos:prefLabel"/>
<xsl:variable name="isoLUD" select="document('../thesauri/mmd-vocabulary.xml')"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<xsl:template match="/mmd:mmd">
Expand Down Expand Up @@ -65,6 +69,7 @@
<xsl:apply-templates select="mmd:abstract[@xml:lang = 'en']" />
<xsl:apply-templates select="mmd:related_information"/> <!--tbd-->
<xsl:apply-templates select="mmd:data_access" />
<xsl:apply-templates select="mmd:related_dataset" />

<xsl:element name="dif:Metadata_Name">CEOS IDN DIF</xsl:element>
<xsl:element name="dif:Metadata_Version">VERSION 10.3</xsl:element>
Expand All @@ -79,7 +84,7 @@
<xsl:value-of select="." />
</xsl:element>
<xsl:element name="dif:Version">
<xsl:text>1.0</xsl:text>
<xsl:text>Not provided</xsl:text>
</xsl:element>
</xsl:element>
</xsl:template>
Expand All @@ -103,7 +108,7 @@
<xsl:element name="dif:Related_URL">
<xsl:element name="dif:URL_Content_Type">
<xsl:element name="dif:Type">
<xsl:text>DATASET LANDING PAGE</xsl:text>
<xsl:text>DATA SET LANDING PAGE</xsl:text>
</xsl:element>
</xsl:element>
<xsl:element name="dif:URL">
Expand Down Expand Up @@ -516,6 +521,24 @@
</xsl:element>
</xsl:template>

<xsl:template match="mmd:related_dataset">
<xsl:if test="@relation_type = 'parent' and . !=''">
<xsl:element name="dif:Metadata_Association">
<xsl:element name="dif:Entry_ID">
<xsl:element name="dif:Short_Name">
<xsl:value-of select="." />
</xsl:element>
<xsl:element name="dif:Version">
<xsl:text>Not provided</xsl:text>
</xsl:element>
</xsl:element>
<xsl:element name="dif:Type">
<xsl:text>Parent</xsl:text>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:template>

<xsl:template match="mmd:project">
<xsl:element name="dif:Project">
<xsl:element name="dif:Short_Name">
Expand Down Expand Up @@ -599,9 +622,14 @@
</xsl:template>

<xsl:template match="mmd:iso_topic_category">
<xsl:variable name="isov" select="." />
<xsl:for-each select="$isoLUD">
<xsl:value-of select ="name()" />
<xsl:variable name="isoe" select="key('isoc',$isov)/skos:altLabel"/>
<xsl:element name="dif:ISO_Topic_Category">
<xsl:value-of select="." />
<xsl:value-of select="$isoe" />
</xsl:element>
</xsl:for-each>
</xsl:template>

<xsl:template match="mmd:keywords">
Expand Down
Loading

0 comments on commit 24ce5a8

Please sign in to comment.