Skip to content

Commit

Permalink
validate for online resource protocol (#263)
Browse files Browse the repository at this point in the history
* validate for online resource protocol

* check protocol

* Retrieve protocol from label.xml and validate it.

* Protocol list in error message instead of hardcoding.

* merging error message into one.
  • Loading branch information
wangf1122 authored May 19, 2022
1 parent a936820 commit 8a42bd1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<DistributionFormatVersion>Value is required for distribution format - File version</DistributionFormatVersion>
<DistributionFormatInvalid>Value for distribution format is not valid</DistributionFormatInvalid>
<OnlineResourceUrl>Value is required for Online Resource URL</OnlineResourceUrl>
<OnlineResourceProtocol>Protocol of Online Resource is not valid. Valid values are: </OnlineResourceProtocol>

<MapResourcesREST>REST Map Resources should be available in english and french</MapResourcesREST>
<MapResourcesRESTNumber>The number of ESRI REST Map Resources should be at most 2 (one for english and one for french)</MapResourcesRESTNumber>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<DistributionFormatVersion>Une valeur est nécessaire pour: Version du Format de distribution</DistributionFormatVersion>
<DistributionFormatInvalid>Valeur du format de distribution n'est pas valide</DistributionFormatInvalid>
<OnlineResourceUrl>Value is required for Online Resource URL</OnlineResourceUrl>
<OnlineResourceProtocol>Protocole de ressource en ligne n'est pas valide. Les valeurs valides sont </OnlineResourceProtocol>

<MapResourcesREST>Les sources de la carte REST devraient être disponibles en anglais et en français</MapResourcesREST>
<MapResourcesRESTNumber>Le nombre de sources de la carte ESRI REST devrait être au plus 2 (une pour l'anglais et une pour le français)</MapResourcesRESTNumber>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@
<sch:let name="mainLanguageText" value="if ($mainLanguage = 'fra') then 'French' else 'English'"/>
<sch:let name="mainLanguage2char" value="if ($mainLanguage = 'fra') then 'fr' else 'en'"/>

<xsl:function xmlns:sch="http://purl.oclc.org/dsdl/schematron" name="geonet:protocolListString" as="xs:string">
<xsl:param name="protocolNode"/>

<xsl:variable name="v">
<xsl:for-each select="$protocolNode">
<xsl:sort select="lower-case(.)" order="ascending"/>
<xsl:value-of select="."/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:variable>

<xsl:value-of select="$v"/>
</xsl:function>

<xsl:function xmlns:sch="http://purl.oclc.org/dsdl/schematron" name="geonet:appendLocaleMessage">
<xsl:param name="localeStringNode"/>
<xsl:param name="appendText" as="xs:string"/>

<xsl:for-each select="$localeStringNode">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:value-of select="concat($localeStringNode, $appendText)"/>
</xsl:copy>
</xsl:for-each>
</xsl:function>

<!--- Metadata pattern -->
<sch:pattern>
<sch:title>$loc/strings/Metadata</sch:title>
Expand Down Expand Up @@ -403,6 +429,22 @@

</sch:rule>

<sch:rule context="//gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource">
<sch:let name="locLabel" value="document(concat('../loc/', $lang, '/labels.xml'))"/>
<sch:let name="protocolList" value="$locLabel/labels/element[@name='gmd:protocol']/helper/option"/>
<sch:let name="protocol" value="gmd:protocol/gco:CharacterString/text()"/>
<sch:let name="isValidProtocol" value="$protocol = $protocolList"/>

<sch:let name="resourceName" value="gmd:name/gco:CharacterString/text()" />

<sch:let name="protocolListString" value="geonet:protocolListString($protocolList)"/>

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

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

</sch:rule>

<!-- Online resource: MapResourcesREST, MapResourcesWMS-->
<sch:rule context="//gmd:distributionInfo/gmd:MD_Distribution">
Expand Down

0 comments on commit 8a42bd1

Please sign in to comment.