Skip to content

Commit

Permalink
Revert "online resource language and its validation"
Browse files Browse the repository at this point in the history
This reverts commit c01caf0
  • Loading branch information
wangf1122 committed Apr 25, 2024
1 parent 97e8ac5 commit 2241c9c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/main/plugin/iso19139.ca.HNAP/process/onlinesrc-add.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,9 @@ Note: It assumes that it will be adding new items in
<xsl:choose>
<xsl:when test="starts-with($protocol, 'OGC:') and $name != ''">

<xsl:variable name="descMainLang" select="tokenize(substring-before($desc, '|'), ';')[last()]" />

<xsl:variable name="resourceLang">
<xsl:choose>
<xsl:when test="ends-with($descMainLang, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:when test="ends-with($desc, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:otherwise><xsl:value-of select="'urn:xml:lang:eng-CAN'"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
Expand Down Expand Up @@ -425,11 +423,9 @@ Note: It assumes that it will be adding new items in
<gmd:onLine>
<xsl:variable name="isMapProtocol" select="starts-with($protocol, 'ESRI REST:') or starts-with($protocol, 'OGC:')" />

<xsl:variable name="descMainLang" select="tokenize(substring-before($desc, '|'), ';')[last()]" />

<xsl:variable name="resourceLang">
<xsl:choose>
<xsl:when test="ends-with($descMainLang, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:when test="ends-with($desc, 'fra')"><xsl:value-of select="'urn:xml:lang:fra-CAN'"/></xsl:when>
<xsl:otherwise><xsl:value-of select="'urn:xml:lang:eng-CAN'"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@
</xsl:for-each>
</xsl:function>


<xsl:function xmlns:sch="http://purl.oclc.org/dsdl/schematron"
name="geonet:getDuplicateResources"
as="xs:string">
<xsl:param name="elements" as="element()*"/>

<!-- Find groups of elements with duplicates -->
<xsl:variable name="duplicateResourcesElements">
<xsl:for-each-group select="$elements"
group-by="concat(gmd:linkage/gmd:URL/text(), '|', tokenize(gmd:description/gco:CharacterString/text(), ';')[3])">
<xsl:if test="count(current-group()) &gt; 1">
<xsl:sequence select="."/>
</xsl:if>
</xsl:for-each-group>
</xsl:variable>

<!-- Iterate over duplicate groups and generate the list of duplicates -->
<xsl:variable name="duplicateResources">
<xsl:for-each select="$duplicateResourcesElements/*">
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="concat(' ', tokenize(gmd:description/gco:CharacterString/text(), ';')[3], ';')"/>
<xsl:value-of select="gmd:linkage/gmd:URL/text()"/>
</xsl:for-each>
</xsl:variable>

<!-- Return the results -->
<xsl:value-of select="$duplicateResources"/>
</xsl:function>

<!--- Metadata pattern -->
<sch:pattern>
<sch:title>$loc/strings/Metadata</sch:title>
Expand Down Expand Up @@ -517,20 +548,24 @@
<sch:let name="smallcase" value="'abcdefghijklmnopqrstuvwxyz'" />
<sch:let name="uppercase" value="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

<sch:let name="mapRESTCountE" value="count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:eng-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'esri rest: map service'])" />
<sch:let name="mapRESTCountF" value="count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:fra-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'esri rest: map service'])" />
<sch:let name="mapRESTCount" value="$mapRESTCountE + $mapRESTCountF" />
<sch:let name="mapRESTCount" value="count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:eng-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'esri rest: map service']) +
count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:fra-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'esri rest: map service'])" />

<sch:let name="onlineResources" value="gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource" />

<sch:assert test="$mapRESTCount &lt;= 2">$loc/strings/MapResourcesRESTNumber</sch:assert>
<sch:assert test="$mapRESTCount = 0 or $mapRESTCount = 2 or $mapRESTCount &gt; 2">$loc/strings/MapResourcesREST</sch:assert>

<sch:assert test="($mapRESTCountE = 0 and $mapRESTCountF = 0) or ($mapRESTCountE = 1 and $mapRESTCountF = 1) or $mapRESTCount &gt; 2">$loc/strings/MapResourcesREST</sch:assert>
<sch:assert test="$mapRESTCount = 0 or $mapRESTCount &lt;= 2">$loc/strings/MapResourcesRESTNumber</sch:assert>
<sch:let name="mapWMSCount" value="count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:eng-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'ogc:wms']) +
count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:fra-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'ogc:wms'])" />

<sch:assert test="$mapWMSCount &lt;= 2">$loc/strings/MapResourcesWMSNumber</sch:assert>
<sch:assert test="$mapWMSCount = 0 or $mapWMSCount = 2 or $mapWMSCount &gt; 2">$loc/strings/MapResourcesWMS</sch:assert>

<sch:let name="mapWMSCountE" value="count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:eng-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'ogc:wms'])" />
<sch:let name="mapWMSCountF" value="count(gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[@xlink:role='urn:xml:lang:fra-CAN' and translate(gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString, $uppercase, $smallcase) = 'ogc:wms'])" />
<sch:let name="mapWMSCount" value="$mapWMSCountE + $mapWMSCountF" />
<sch:let name="duplicatedResource" value="geonet:getDuplicateResources($onlineResources)" />
<sch:let name="locMsg" value="geonet:appendLocaleMessage($loc/strings/hasDuplicatedOnlineResource, $duplicatedResource)" />

<sch:assert test="($mapWMSCountE = 0 and $mapWMSCountF = 0) or ($mapWMSCountE = 1 and $mapWMSCountF = 1) or $mapWMSCount &gt; 2">$loc/strings/MapResourcesWMS</sch:assert>
<sch:assert test="$mapWMSCount = 0 or $mapWMSCount &lt;= 2">$loc/strings/MapResourcesWMSNumber</sch:assert>
<sch:assert test="not(string($duplicatedResource))">$locMsg</sch:assert>
</sch:rule>

<!-- Distribution - Format -->
Expand Down

0 comments on commit 2241c9c

Please sign in to comment.