Skip to content

Commit

Permalink
Thesaurus / Avoid having multiple dates with same type code
Browse files Browse the repository at this point in the history
geonetwork#6972 adds retrieval of `dct:issued|modified|created` dates but multiple dates could be added more than one time with same date type code. Improve the mapping.
  • Loading branch information
fxprunayre committed Sep 30, 2024
1 parent daa3a92 commit 89b5b3a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
<xsl:param name="withThesaurusAnchor"/>

<mri:descriptiveKeywords>
<xsl:namespace name="mri" select="'http://standards.iso.org/iso/19115/-3/mri/1.0'"/>
<xsl:namespace name="mcc" select="'http://standards.iso.org/iso/19115/-3/mcc/1.0'"/>
<xsl:namespace name="cit" select="'http://standards.iso.org/iso/19115/-3/cit/2.0'"/>
<xsl:namespace name="gco" select="'http://standards.iso.org/iso/19115/-3/gco/1.0'"/>
<xsl:namespace name="gcx" select="'http://standards.iso.org/iso/19115/-3/gcx/1.0'"/>
<xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/>
<xsl:choose>
<xsl:when test="$withXlink">
<xsl:variable name="multiple"
Expand Down Expand Up @@ -257,20 +263,22 @@
codeListValue="{$thesauri/thesaurus[key = $currentThesaurus]/dname}" />
</mri:type>
<xsl:if test="$thesaurusInfo">
<xsl:variable name="thesaurus"
select="$thesauri/thesaurus[key = $currentThesaurus]"/>

<xsl:variable name="thesaurusInMainLanguage"
select="$thesauri/thesaurus[key = $currentThesaurus]
/multilingualTitles/multilingualTitle[
select="$thesaurus/multilingualTitles/multilingualTitle[
lang = util:twoCharLangCode($mainLanguage, '')]/title"/>
<xsl:variable name="thesaurusTitle"
select="if ($thesaurusInMainLanguage != '')
then $thesaurusInMainLanguage
else $thesauri/thesaurus[key = $currentThesaurus]/title"/>
else $thesaurus/title"/>
<mri:thesaurusName>
<cit:CI_Citation>
<cit:title>
<xsl:choose>
<xsl:when test="$withThesaurusAnchor = true()">
<gcx:Anchor xlink:href="{$thesauri/thesaurus[key = $currentThesaurus]/defaultNamespace}">
<gcx:Anchor xlink:href="{$thesaurus/defaultNamespace}">
<xsl:value-of select="$thesaurusTitle"/>
</gcx:Anchor>
</xsl:when>
Expand All @@ -282,121 +290,30 @@
</xsl:choose>
</cit:title>

<xsl:variable name="thesaurusDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/date)" />
<xsl:variable name="thesaurusCreatedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/createdDate)"/>
<xsl:variable name="thesaurusIssuedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/issuedDate)"/>
<xsl:variable name="thesaurusModifiedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/modifiedDate)"/>
<xsl:variable name="thesaurusDates" as="node()*">
<publication date="{normalize-space($thesaurus/date)}"/>
<creation date="{normalize-space($thesaurus/createdDate)}"/>
<publication date="{normalize-space($thesaurus/issuedDate)}"/>
<publication date="{normalize-space($thesaurus/modifiedDate)}"/>
</xsl:variable>

<xsl:if test="$thesaurusDate != ''">
<xsl:for-each-group select="$thesaurusDates[@date != '']" group-by="@date">
<xsl:sort select="@date" order="descending"/>
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="{if (contains(current-grouping-key(), 'T')) then 'gco:DateTime' else 'gco:Date'}">
<xsl:value-of select="current-grouping-key()" />
</xsl:element>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication" />
codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_DateTypeCode"
codeListValue="{name(current-group()[1])}"/>
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:if>

<!-- Publication Date-->
<xsl:choose>
<xsl:when test="$thesaurusIssuedDate != ''">
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusIssuedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusIssuedDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusIssuedDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication" />
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:when>
<xsl:otherwise>
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication" />
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:otherwise>
</xsl:choose>

<!--Creation Date-->
<xsl:if test="$thesaurusCreatedDate != ''">
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusCreatedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusCreatedDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusCreatedDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="creation" />
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:if>
</xsl:for-each-group>

<xsl:if test="$withThesaurusAnchor">
<cit:identifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@
<xsl:param name="withThesaurusAnchor"/>

<gmd:descriptiveKeywords>
<xsl:namespace name="gmd" select="'http://www.isotc211.org/2005/gmd'"/>
<xsl:namespace name="gco" select="'http://www.isotc211.org/2005/gco'"/>
<xsl:namespace name="gmx" select="'http://www.isotc211.org/2005/gmx'"/>
<xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/>
<xsl:choose>
<xsl:when test="$withXlink">
<xsl:variable name="isLocalXlink"
Expand Down Expand Up @@ -314,22 +318,24 @@
codeListValue="{$thesauri/thesaurus[key = $currentThesaurus]/dname}"/>
</gmd:type>
<xsl:if test="$thesaurusInfo">
<xsl:variable name="thesaurus"
select="$thesauri/thesaurus[key = $currentThesaurus]"/>

<xsl:variable name="thesaurusInMainLanguage"
select="$thesauri/thesaurus[key = $currentThesaurus]
select="$thesaurus
/multilingualTitles/multilingualTitle[
lang = util:twoCharLangCode($mainLanguage, '')]/title"/>
<xsl:variable name="thesaurusTitle"
select="if ($thesaurusInMainLanguage != '')
then $thesaurusInMainLanguage
else $thesauri/thesaurus[key = $currentThesaurus]/title"/>
else $thesaurus/title"/>

<gmd:thesaurusName>
<gmd:CI_Citation>
<gmd:title>
<xsl:choose>
<xsl:when test="$withTitleAnchor = true()">
<gmx:Anchor xlink:href="{$thesauri/thesaurus[key = $currentThesaurus]/defaultNamespace}">
<gmx:Anchor xlink:href="{$thesaurus/defaultNamespace}">
<xsl:value-of select="$thesaurusTitle"/>
</gmx:Anchor>
</xsl:when>
Expand All @@ -341,95 +347,31 @@
</xsl:choose>
</gmd:title>

<xsl:variable name="thesaurusDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/date)"/>
<xsl:variable name="thesaurusCreatedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/createdDate)"/>
<xsl:variable name="thesaurusIssuedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/issuedDate)"/>
<xsl:variable name="thesaurusModifiedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/modifiedDate)"/>

<!-- Publication Date-->
<xsl:choose>
<xsl:when test="$thesaurusIssuedDate != ''">
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($thesaurusIssuedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusIssuedDate"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusIssuedDate"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:when>
<xsl:otherwise>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($thesaurusDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusDate"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusDate"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="thesaurusDates" as="node()*">
<publication date="{normalize-space($thesaurus/date)}"/>
<creation date="{normalize-space($thesaurus/createdDate)}"/>
<publication date="{normalize-space($thesaurus/issuedDate)}"/>
<publication date="{normalize-space($thesaurus/modifiedDate)}"/>
</xsl:variable>

<!--Creation Date-->
<xsl:if test="$thesaurusCreatedDate != ''">
<xsl:for-each-group select="$thesaurusDates[@date != '']" group-by="@date">
<xsl:sort select="@date" order="descending"/>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($thesaurusCreatedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusCreatedDate"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusCreatedDate"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="{if (contains(current-grouping-key(), 'T')) then 'gco:DateTime' else 'gco:Date'}">
<xsl:value-of select="current-grouping-key()" />
</xsl:element>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="creation"/>
codeListValue="{name(current-group()[1])}"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:if>
</xsl:for-each-group>

<!--
You can pull in the publisher from the Thesaurus XML. See Metadata101/iso19139.ca.HNAP
Expand Down

0 comments on commit 89b5b3a

Please sign in to comment.