Skip to content

Commit

Permalink
Pass dynamic government name thesaurus to the validation error message (
Browse files Browse the repository at this point in the history
  • Loading branch information
wangf1122 authored Jun 5, 2024
1 parent e86ba2b commit 124caf7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@

<ContactGovEnglish>English value for Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</ContactGovEnglish>
<ContactGovFrench>French value for Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</ContactGovFrench>
<ContactGovAllowedEnglish>English value for Contact - Organisation name must be one of 'Government of Canada', 'Government of Alberta', 'Government of British Columbia', 'Government of Ontario', 'Government of Nova Scotia', 'Government of Prince Edward Island' or 'Government of Newfoundland and Labrador'.</ContactGovAllowedEnglish>
<ContactGovAllowedFrench>French value for Contact - Organisation name must be one of 'Gouvernement du Canada', 'Gouvernement de l'Alberta', 'Gouvernement de la Colombie-Britannique', 'Gouvernement de l'Ontario', 'Gouvernement de la Nouvelle-Écosse', 'Gouvernement de l'Île-du-Prince-Édouard' or 'Gouvernement de Terre-Neuve-et-Labrador'.</ContactGovAllowedFrench>
<ContactGovAllowedEnglish>English value for Contact - Organisation name must be one of: </ContactGovAllowedEnglish>
<ContactGovAllowedFrench>French value for Contact - Organisation name must be one of: </ContactGovAllowedFrench>

<CitedResponsibleContactGovEnglish>English value for Cited Responsible Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</CitedResponsibleContactGovEnglish>
<CitedResponsibleContactGovFrench>French value for Cited Responsible Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</CitedResponsibleContactGovFrench>
<CitedResponsibleContactGovAllowedEnglish>English value for Cited Responsible Contact - Organisation name must be one of 'Government of Canada', 'Government of Alberta', 'Government of British Columbia', 'Government of Ontario', 'Government of Nova Scotia', 'Government of Prince Edward Island' or 'Government of Newfoundland and Labrador'.</CitedResponsibleContactGovAllowedEnglish>
<CitedResponsibleContactGovAllowedFrench>French value for Cited Responsible Contact - Organisation name must be one of 'Gouvernement du Canada', 'Gouvernement de l'Alberta', 'Gouvernement de la Colombie-Britannique', 'Gouvernement de l'Ontario', 'Gouvernement de la Nouvelle-Écosse', 'Gouvernement de l'Île-du-Prince-Édouard' or 'Gouvernement de Terre-Neuve-et-Labrador'.</CitedResponsibleContactGovAllowedFrench>
<CitedResponsibleContactGovAllowedEnglish>English value for Cited Responsible Contact - Organisation name must be one of: </CitedResponsibleContactGovAllowedEnglish>
<CitedResponsibleContactGovAllowedFrench>French value for Cited Responsible Contact - Organisation name must be one of: </CitedResponsibleContactGovAllowedFrench>

<DistributorGovEnglish>English value for Distributor Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</DistributorGovEnglish>
<DistributorGovFrench>French value for Distributor Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</DistributorGovFrench>
<DistributorGovAllowedEnglish>English value for Distributor Contact - Organisation name must be one of 'Government of Canada', 'Government of Alberta', 'Government of British Columbia', 'Government of Ontario', 'Government of Nova Scotia', 'Government of Prince Edward Island' or 'Government of Newfoundland and Labrador'.</DistributorGovAllowedEnglish>
<DistributorGovAllowedFrench>French value for Distributor Contact - Organisation name must be one of 'Gouvernement du Canada', 'Gouvernement de l'Alberta', 'Gouvernement de la Colombie-Britannique', 'Gouvernement de l'Ontario', 'Gouvernement de la Nouvelle-Écosse', 'Gouvernement de l'Île-du-Prince-Édouard' or 'Gouvernement de Terre-Neuve-et-Labrador'.</DistributorGovAllowedFrench>
<DistributorGovAllowedEnglish>English value for Distributor Contact - Organisation name must be one of: </DistributorGovAllowedEnglish>
<DistributorGovAllowedFrench>French value for Distributor Contact - Organisation name must be one of: </DistributorGovAllowedFrench>

<OpenLicense>An Open Goverment Licence is required. Accepted English values: Open Government Licence - Canada (http://open.canada.ca/en/open-government-licence-canada) or Open Government Licence – Newfoundland and Labrador (https://opendata.gov.nl.ca/public/opendata/page/?page-id=licence) or Open Government Licence – Nova Scotia (https://novascotia.ca/opendata/licence.asp) or Open Government Licence – Ontario (https://www.ontario.ca/page/open-government-licence-ontario) or Open Government Licence – Prince Edward Island (https://www.princeedwardisland.ca/en/information/finance/open-government-licence-prince-edward-island) or Open Government Licence - British Columbia (https://www2.gov.bc.ca/gov/content/data/open-data/open-government-licence-bc) or Open Government Licence - Alberta (https://open.alberta.ca/licence).
Accepted French values : Licence du gouvernement ouvert - Canada (http://ouvert.canada.ca/fr/licence-du-gouvernement-ouvert-canada) or Licence du gouvernement ouvert – Terre-Neuve-et-Labrador (https://opendata.gov.nl.ca/public/opendata/page/?page-id=licence) or Licence du gouvernement ouvert – Nouvelle-Écosse (https://novascotia.ca/opendata/licence.asp) or Licence du gouvernement ouvert – Ontario (https://www.ontario.ca/fr/page/licence-du-gouvernement-ouvert-ontario) or Licence du gouvernement ouvert – Île-du-Prince-Édouard (https://www.princeedwardisland.ca/fr/information/finances/licence-du-gouvernement-ouvert-ile-du-prince-edouard) or Licence du gouvernement ouvert - Colombie-Britannique (https://www2.gov.bc.ca/gov/content/data/open-data/open-government-licence-bc) or Licence du gouvernement ouvert - Alberta (https://open.alberta.ca/licence)</OpenLicense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@

<ContactGovEnglish>English value for Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</ContactGovEnglish>
<ContactGovFrench>French value for Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</ContactGovFrench>
<ContactGovAllowedEnglish>English value for Contact - Organisation name must be one of 'Government of Canada', 'Government of Alberta', 'Government of British Columbia', 'Government of Ontario', 'Government of Nova Scotia', 'Government of Prince Edward Island' or 'Government of Newfoundland and Labrador'.</ContactGovAllowedEnglish>
<ContactGovAllowedFrench>French value for Contact - Organisation name must be one of 'Gouvernement du Canada', 'Gouvernement de l'Alberta', 'Gouvernement de la Colombie-Britannique', 'Gouvernement de l'Ontario', 'Gouvernement de la Nouvelle-Écosse', 'Gouvernement de l'Île-du-Prince-Édouard' or 'Gouvernement de Terre-Neuve-et-Labrador'.</ContactGovAllowedFrench>
<ContactGovAllowedEnglish>English value for Contact - Organisation name must be one of: </ContactGovAllowedEnglish>
<ContactGovAllowedFrench>French value for Contact - Organisation name must be one of: </ContactGovAllowedFrench>

<CitedResponsibleContactGovEnglish>English value for Cited Responsible Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</CitedResponsibleContactGovEnglish>
<CitedResponsibleContactGovFrench>French value for Cited Responsible Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</CitedResponsibleContactGovFrench>
<CitedResponsibleContactGovAllowedEnglish>English value for Cited Responsible Contact - Organisation name must be one of 'Government of Canada', 'Government of Alberta', 'Government of British Columbia', 'Government of Ontario', 'Government of Nova Scotia', 'Government of Prince Edward Island' or 'Government of Newfoundland and Labrador'.</CitedResponsibleContactGovAllowedEnglish>
<CitedResponsibleContactGovAllowedFrench>French value for Cited Responsible Contact - Organisation name must be one of 'Gouvernement du Canada', 'Gouvernement de l'Alberta', 'Gouvernement de la Colombie-Britannique', 'Gouvernement de l'Ontario', 'Gouvernement de la Nouvelle-Écosse', 'Gouvernement de l'Île-du-Prince-Édouard' or 'Gouvernement de Terre-Neuve-et-Labrador'.</CitedResponsibleContactGovAllowedFrench>
<CitedResponsibleContactGovAllowedEnglish>English value for Cited Responsible Contact - Organisation name must be one of: </CitedResponsibleContactGovAllowedEnglish>
<CitedResponsibleContactGovAllowedFrench>French value for Cited Responsible Contact - Organisation name must be one of: </CitedResponsibleContactGovAllowedFrench>

<DistributorGovEnglish>English value for Distributor Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</DistributorGovEnglish>
<DistributorGovFrench>French value for Distributor Contact - Organisation name in 'Goverment of Canada' should have a valid title value. See http://www.tbs-sct.gc.ca/fip-pcim/reg-eng.asp.</DistributorGovFrench>
<DistributorGovAllowedEnglish>English value for Distributor Contact - Organisation name must be one of 'Government of Canada', 'Government of Alberta', 'Government of British Columbia', 'Government of Ontario', 'Government of Nova Scotia', 'Government of Prince Edward Island' or 'Government of Newfoundland and Labrador'.</DistributorGovAllowedEnglish>
<DistributorGovAllowedFrench>French value for Distributor Contact - Organisation name must be one of 'Gouvernement du Canada', 'Gouvernement de l'Alberta', 'Gouvernement de la Colombie-Britannique', 'Gouvernement de l'Ontario', 'Gouvernement de la Nouvelle-Écosse', 'Gouvernement de l'Île-du-Prince-Édouard' or 'Gouvernement de Terre-Neuve-et-Labrador'.</DistributorGovAllowedFrench>
<DistributorGovAllowedEnglish>English value for Distributor Contact - Organisation name must be one of: </DistributorGovAllowedEnglish>
<DistributorGovAllowedFrench>French value for Distributor Contact - Organisation name must be one of: </DistributorGovAllowedFrench>

<OpenLicense>An Open Goverment Licence is required.</OpenLicense>
<Keyword>Keyword is required</Keyword>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@

<sch:let name="government-titles" value="document(concat('file:///', replace(concat($thesaurusDir, '/external/thesauri/theme/GC_Departments.rdf'), '\\', '/')))"/>
<sch:let name="government-names" value="document(concat('file:///', replace(concat($thesaurusDir, '/external/thesauri/theme/GC_Org_Names.rdf'), '\\', '/')))"/>
<sch:let name="governmentNamesStringMainLang" value=" string($government-names//rdf:Description/ns2:prefLabel[@xml:lang=$mainLanguage2char]) "/>
<sch:let name="governmentNamesStringAltLang" value=" string($government-names//rdf:Description/ns2:prefLabel[@xml:lang=$altLanguage2char]) "/>

<sch:let name="organisationName" value="gco:CharacterString" />
<sch:let name="isGovernmentOfCanada" value="starts-with(lower-case(normalize-space(tokenize($organisationName, ';')[1])), 'government of canada') or starts-with(lower-case(normalize-space(tokenize($organisationName, ';')[1])), 'gouvernement du canada')" />
Expand All @@ -246,7 +248,8 @@

<sch:assert test="not($isErrorContactGovMain)">$loc/strings/*[name() = concat('ContactGov', $mainLanguageText)]</sch:assert>

<sch:assert test="not($isErrorContactGovMainAllowed)">$loc/strings/*[name() = concat('ContactGovAllowed', $mainLanguageText)]</sch:assert>
<sch:let name="locMsgMainLang" value="geonet:appendLocaleMessage($loc/strings/*[name() = concat('ContactGovAllowed', $mainLanguageText)], $governmentNamesStringMainLang)" />
<sch:assert test="not($isErrorContactGovMainAllowed)">$locMsgMainLang</sch:assert>

<sch:let name="organisationNameOtherLang" value="gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale=concat('#', $altLanguageId)]" />
<sch:let name="isGovernmentOfCanadaOtherLang" value="starts-with(lower-case(normalize-space(tokenize($organisationNameOtherLang, ';')[1])), 'government of canada') or starts-with(lower-case(normalize-space(tokenize($organisationNameOtherLang, ';')[1])), 'gouvernement du canada')" />
Expand All @@ -268,7 +271,8 @@
)"/>

<sch:assert test="not($isErrorContactGovAlt)">$loc/strings/*[name() = concat('ContactGov', $altLanguageText)]</sch:assert>
<sch:assert test="not($isErrorContactGovAltAllowed)">$loc/strings/*[name() = concat('ContactGovAllowed', $altLanguageText)]</sch:assert>
<sch:let name="locMsgAltLang" value="geonet:appendLocaleMessage($loc/strings/*[name() = concat('ContactGovAllowed', $altLanguageText)], $governmentNamesStringAltLang)" />
<sch:assert test="not($isErrorContactGovAltAllowed)">$locMsgAltLang</sch:assert>

</sch:rule>

Expand Down Expand Up @@ -457,6 +461,8 @@

<sch:let name="government-titles" value="document(concat('file:///', replace(concat($thesaurusDir, '/external/thesauri/theme/GC_Departments.rdf'), '\\', '/')))"/>
<sch:let name="government-names" value="document(concat('file:///', replace(concat($thesaurusDir, '/external/thesauri/theme/GC_Org_Names.rdf'), '\\', '/')))"/>
<sch:let name="governmentNamesStringMainLang" value=" string($government-names//rdf:Description/ns2:prefLabel[@xml:lang=$mainLanguage2char]) "/>
<sch:let name="governmentNamesStringAltLang" value=" string($government-names//rdf:Description/ns2:prefLabel[@xml:lang=$altLanguage2char]) "/>

<sch:let name="organisationName" value="gco:CharacterString" />
<sch:let name="isGovernmentOfCanada" value="starts-with(lower-case(normalize-space(tokenize($organisationName, ';')[1])), 'government of canada') or starts-with(lower-case(normalize-space(tokenize($organisationName, ';')[1])), 'gouvernement du canada')" />
Expand All @@ -471,9 +477,10 @@
string($government-titles//rdf:Description[normalize-space(lower-case(ns2:prefLabel[@xml:lang=$altLanguage2char])) = $titleName]))
)">$loc/strings/*[name() = concat('CitedResponsibleContactGov', $mainLanguageText)]</sch:assert>

<sch:let name="locMsgMainLang" value="geonet:appendLocaleMessage($loc/strings/*[name() = concat('CitedResponsibleContactGovAllowed', $mainLanguageText)], $governmentNamesStringMainLang)" />
<sch:assert test="($missing and $missingOtherLang) or
$isGovernmentNameAllowed
">$loc/strings/*[name() = concat('CitedResponsibleContactGovAllowed', $mainLanguageText)]</sch:assert>
">$locMsgMainLang</sch:assert>

<sch:let name="organisationNameOtherLang" value="gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale=concat('#', $altLanguageId)]" />
<sch:let name="isGovernmentOfCanadaOtherLang" value="starts-with(lower-case(normalize-space(tokenize($organisationNameOtherLang, ';')[1])), 'government of canada') or starts-with(lower-case(normalize-space(tokenize($organisationNameOtherLang, ';')[1])), 'gouvernement du canada')" />
Expand All @@ -486,9 +493,10 @@
<sch:assert test="($missing and $missingOtherLang) or ($isGovernmentNameAllowedOtherLang and not($isGovernmentOfCanadaOtherLang)) or (not($isGovernmentNameAllowedOtherLang) and not($isGovernmentOfCanadaOtherLang)) or ($isGovernmentNameAllowedOtherLang and not($isGovernmentOfCanadaOtherLang)) or ($isGovernmentOfCanadaOtherLang and (string($government-titles//rdf:Description[normalize-space(lower-case(ns2:prefLabel[@xml:lang=$mainLanguage2char])) = $titleNameOtherLang]) or
string($government-titles//rdf:Description[normalize-space(lower-case(ns2:prefLabel[@xml:lang=$altLanguage2char])) = $titleNameOtherLang]))
)">$loc/strings/*[name() = concat('CitedResponsibleContactGov', $altLanguageText)]</sch:assert>
<sch:let name="locMsgAltLang" value="geonet:appendLocaleMessage($loc/strings/*[name() = concat('CitedResponsibleContactGovAllowed', $altLanguageText)], $governmentNamesStringAltLang)" />
<sch:assert test="($missing and $missingOtherLang) or
$isGovernmentNameAllowedOtherLang
">$loc/strings/*[name() = concat('CitedResponsibleContactGovAllowed', $altLanguageText)]</sch:assert>
">$locMsgAltLang</sch:assert>
</sch:rule>


Expand Down Expand Up @@ -894,6 +902,8 @@

<sch:let name="government-titles" value="document(concat('file:///', replace(concat($thesaurusDir, '/external/thesauri/theme/GC_Departments.rdf'), '\\', '/')))"/>
<sch:let name="government-names" value="document(concat('file:///', replace(concat($thesaurusDir, '/external/thesauri/theme/GC_Org_Names.rdf'), '\\', '/')))"/>
<sch:let name="governmentNamesStringMainLang" value=" string($government-names//rdf:Description/ns2:prefLabel[@xml:lang=$mainLanguage2char]) "/>
<sch:let name="governmentNamesStringAltLang" value=" string($government-names//rdf:Description/ns2:prefLabel[@xml:lang=$altLanguage2char]) "/>

<sch:let name="organisationName" value="gco:CharacterString" />
<sch:let name="isGovernmentOfCanada" value="starts-with(lower-case(normalize-space(tokenize($organisationName, ';')[1])), 'government of canada') or starts-with(lower-case(normalize-space(tokenize($organisationName, ';')[1])), 'gouvernement du canada')" />
Expand All @@ -908,9 +918,10 @@
string($government-titles//rdf:Description[normalize-space(lower-case(ns2:prefLabel[@xml:lang=$altLanguage2char])) = $titleName]))
)">$loc/strings/*[name() = concat('DistributorGov', $mainLanguageText)]</sch:assert>

<sch:let name="locMsgMainLang" value="geonet:appendLocaleMessage($loc/strings/*[name() = concat('DistributorGovAllowed', $mainLanguageText)], $governmentNamesStringMainLang)" />
<sch:assert test="($missing and $missingOtherLang) or
$isGovernmentNameAllowed
">$loc/strings/*[name() = concat('DistributorGovAllowed', $mainLanguageText)]</sch:assert>
">$locMsgMainLang</sch:assert>

<sch:let name="organisationNameOtherLang" value="gmd:PT_FreeText/gmd:textGroup/gmd:LocalisedCharacterString[@locale=concat('#', $altLanguageId)]" />
<sch:let name="isGovernmentOfCanadaOtherLang" value="starts-with(lower-case(normalize-space(tokenize($organisationNameOtherLang, ';')[1])), 'government of canada') or starts-with(lower-case(normalize-space(tokenize($organisationNameOtherLang, ';')[1])), 'gouvernement du canada')" />
Expand All @@ -923,9 +934,10 @@
<sch:assert test="($missing and $missingOtherLang) or ($isGovernmentNameAllowedOtherLang and not($isGovernmentOfCanadaOtherLang)) or (not($isGovernmentNameAllowedOtherLang) and not($isGovernmentOfCanadaOtherLang)) or ($isGovernmentNameAllowedOtherLang and not($isGovernmentOfCanadaOtherLang)) or ($isGovernmentOfCanadaOtherLang and (string($government-titles//rdf:Description[normalize-space(lower-case(ns2:prefLabel[@xml:lang=$mainLanguage2char])) = $titleNameOtherLang]) or
string($government-titles//rdf:Description[normalize-space(lower-case(ns2:prefLabel[@xml:lang=$altLanguage2char])) = $titleNameOtherLang]))
)">$loc/strings/*[name() = concat('DistributorGov', $altLanguageText)]</sch:assert>
<sch:let name="locMsgAltLang" value="geonet:appendLocaleMessage($loc/strings/*[name() = concat('DistributorGovAllowed', $altLanguageText)], $governmentNamesStringAltLang)" />
<sch:assert test="($missing and $missingOtherLang) or
$isGovernmentNameAllowedOtherLang
">$loc/strings/*[name() = concat('DistributorGovAllowed', $altLanguageText)]</sch:assert>
">$locMsgAltLang</sch:assert>

</sch:rule>

Expand Down
Loading

0 comments on commit 124caf7

Please sign in to comment.