Skip to content

Commit

Permalink
Use dates from the thesaurus file if exists instead of file system la…
Browse files Browse the repository at this point in the history
…st modified date from thesaurusDate (#327)

* Exclude file system last modified date from thesaurusDate

* thesaurusDate

* default HNAP template date to GC_Core_Subject.rdf

* default HNAP template date to GC_Core_Subject.rdf .

* group duplicate date parsing logic to single function
  • Loading branch information
wangf1122 authored Apr 28, 2023
1 parent 317e08d commit 5b3c3f4
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
>
<skos:ConceptScheme rdf:about="http://www.thesaurus.gc.ca/#CoreSubjectThesaurus">
<dc:title>Government of Canada Core Subject Thesaurus</dc:title>
Expand All @@ -15,6 +16,8 @@
<dc:publisher xml:lang="en">Government of Canada; Library and Archives Canada</dc:publisher>
<dc:publisher xml:lang="fr">Gouvernement du Canada; Bibliothèque et Archives Canada</dc:publisher>
<dc:description></dc:description>
<dcterms:issued>2004</dcterms:issued>
<dcterms:created>2016-07-04</dcterms:created>
</skos:ConceptScheme>

<skos:Concept rdf:about="http://www.thesaurus.gc.ca/concept/#Abbreviations">
Expand Down
120 changes: 73 additions & 47 deletions src/main/plugin/iso19139.ca.HNAP/convert/thesaurus-transformation.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@

<xsl:import href="../../iso19139/convert/functions.xsl"/>


<xsl:function name="geonet:parseDateString" >
<xsl:param name="dateString"/>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($dateString, 'T')">
<gco:DateTime>
<xsl:value-of select="$dateString"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$dateString"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</gmd:date>
</xsl:function>


<!-- Override template -->
Expand Down Expand Up @@ -351,53 +367,63 @@

<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>
<xsl:sequence select="geonet:parseDateString($thesaurusIssuedDate)"/>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://nap.geogratis.gc.ca/metadata/register/napMetadataRegister.xml#IC_87" codeListValue="RI_367">publication; publication</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:when>
<xsl:otherwise>
<gmd:date>
<gmd:CI_Date>
<xsl:sequence select="geonet:parseDateString($thesaurusDate)"/>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://nap.geogratis.gc.ca/metadata/register/napMetadataRegister.xml#IC_87" codeListValue="RI_367">publication; publication</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:otherwise>
</xsl:choose>

<xsl:if test="$thesaurusDate != ''">
<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://nap.geogratis.gc.ca/metadata/register/napMetadataRegister.xml#IC_87" codeListValue="RI_367">publication; publication</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>

<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 codeListValue="RI_366"
codeList="http://nap.geogratis.gc.ca/metadata/register/napMetadataRegister.xml#IC_87">creation;création</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:if>
<!--Creation Date-->
<xsl:choose>
<xsl:when test="$thesaurusCreatedDate != ''">
<gmd:date>
<gmd:CI_Date>
<xsl:sequence select="geonet:parseDateString($thesaurusCreatedDate)"/>
<gmd:dateType>
<gmd:CI_DateTypeCode codeListValue="RI_366"
codeList="http://nap.geogratis.gc.ca/metadata/register/napMetadataRegister.xml#IC_87">creation;création</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:when>

<xsl:otherwise>
<gmd:date>
<gmd:CI_Date>
<xsl:sequence select="geonet:parseDateString($thesaurusDate)"/>
<gmd:dateType>
<gmd:CI_DateTypeCode codeListValue="RI_366"
codeList="http://nap.geogratis.gc.ca/metadata/register/napMetadataRegister.xml#IC_87">creation;création</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:otherwise>
</xsl:choose>


<xsl:if test="$withThesaurusAnchor">
Expand Down

0 comments on commit 5b3c3f4

Please sign in to comment.