Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata editor - data identification dates - support only date format #272

Open
wants to merge 2 commits into
base: 3.12.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@
data-label=""
data-element-name="{name(gco:Date|gco:DateTime)}"
data-element-ref="{concat('_X', gn:element/@ref)}"
data-hide-time="{if ($viewConfig/@hideTimeInCalendar = 'true') then 'true' else 'false'}">
data-hide-date-mode="true"
data-hide-time="{not(gco:DateTime)}">
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PublicationDate>Value is required for Metadata publication date</PublicationDate>
<CreationDate>Value is required for Metadata creation date</CreationDate>
<MissingDate>Value is required for Date</MissingDate>
<InvalidDate>Date format is not valid. Should be: YYYY-MM-DD</InvalidDate>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed (and shown in your screenshot) the date format can be in different formats depending on locale so maybe this message should be changed to be more generic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest:

The date is entered using your current locale, it will store the date in YYYY-MM-DD format

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternate:

The date entered is not in the correct format for your locale

<InvalidDateTypeCode>Date type is not valid</InvalidDateTypeCode>
<BeginDate>Value is required for Begin Date</BeginDate>
<BeginPositionFormat>Begin position format is not valid value</BeginPositionFormat>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PublicationDate>Une valeur est nécessaire pour: Métadonnées date de publication</PublicationDate>
<CreationDate>>Une valeur est nécessaire pour: Métadonnées date de création</CreationDate>
<MissingDate>Une valeur est nécessaire pour la Date</MissingDate>
<InvalidDate>Le format de date n'est pas valide. Devrait être: YYYY-MM-DD</InvalidDate>
<InvalidDateTypeCode>Le code de type de date n'est pas valide</InvalidDateTypeCode>
<BeginDate>Une valeur est nécessaire pour la Date de début</BeginDate>
<BeginPositionFormat>Le format de la date de début n’est pas valide</BeginPositionFormat>
Expand Down
40 changes: 40 additions & 0 deletions src/main/plugin/iso19139.ca.HNAP/process/fix-date-format.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:geonet="http://www.fao.org/geonetwork"
exclude-result-prefixes="#all">

<xsl:template match="gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date[gco:Date and string-length(gco:Date) != 10]/gco:Date">
Copy link
Contributor

@ianwallen ianwallen Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question?

Is this required for the following as well?

gmd:identificationInfo/*/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition

We currently have issues when publishing this date to Open Data. It does not support single date as a year so we have to add the 01-01 as well. It is possible that this is an Open Data issues and not necessarily an HNAP issue so I'm just asking the question.


<xsl:variable name="value" select="." />

<xsl:copy>
<xsl:choose>
<xsl:when test="matches($value, '^\d{4}$')">
<xsl:value-of select="concat($value, '-01-01')"/>
</xsl:when>
<xsl:when test="matches($value, '^\d{4}-(0[1-9]|1[0-2])$')">
<xsl:value-of select="concat($value, '-01')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>

</xsl:copy>

</xsl:template>


<!-- Do a copy of every nodes and attributes -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<!-- Remove geonet:* elements. -->
<xsl:template match="geonet:*" priority="2"/>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@
<sch:assert
test="not($missing)"
>$loc/strings/MissingDate</sch:assert>

<sch:assert
test="not($missing)"
>$loc/strings/MissingDate</sch:assert>

<sch:assert
test="($missing) or matches(., '^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$')"
>$loc/strings/InvalidDate</sch:assert>
</sch:rule>


Expand Down Expand Up @@ -440,7 +448,7 @@
<sch:let name="protocolListString" value="geonet:protocolListString($protocolList)"/>

<sch:let name="locMsg" value="geonet:appendLocaleMessage($loc/strings/OnlineResourceProtocol, $protocolListString)"/>

<sch:assert test="$isValidProtocol">$locMsg</sch:assert>

</sch:rule>
Expand Down