Skip to content

Commit 51404cd

Browse files
authored
Editor / Keywords / Add option to configure keyword encoding for a view. (geonetwork#8118)
* Editor / Keywords / Add option to configure keyword encoding for a view. More and more the default encoding for keywords is using `Anchor` instead of `CharacterString`. It is even mandatory in a number of case like INSPIRE validation. Quite often, all editor views are configured using: ```xml <thesaurusList> <thesaurus key="external.theme.httpinspireeceuropaeutheme-theme" transformations="to-iso19115-3.2018-keyword-with-anchor"/> <thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistSpatialScope-SpatialScope" transformations="to-iso19115-3.2018-keyword-with-anchor"/> ... ``` to enable usage of `Anchor` for a number of thesaurus. This change propose to be able to configure the default keyword encoding for all thesaurus using: ```xml <thesaurusList defaultTransformation="to-iso19115-3.2018-keyword-with-anchor"/> </view> ``` If defined, it takes priority over the current encoding in the metadata record. It also hide the XLink encoding mode in the encoding selector if the XLink resolver is not enabled. Funded by Service Public de Wallonie * Editor / Keywords / Encoding using anchor for simple and advanced view in ISO19139 and 115-3.
1 parent 9c8baf5 commit 51404cd

File tree

6 files changed

+67
-36
lines changed

6 files changed

+67
-36
lines changed

schemas/config-editor.xsd

+10-1
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,15 @@ e.g. only 2 INSPIRE themes:
10041004
]]></xs:documentation>
10051005
</xs:annotation>
10061006
<xs:complexType>
1007+
<xs:attribute name="defaultTransformation" minOccurs="0" type="xs:string">
1008+
<xs:annotation>
1009+
<xs:documentation><![CDATA[
1010+
The default encoding for all thesaurus eg. to-iso19139-keyword-with-anchor.
1011+
Conversion are defined in `convert/thesaurus-transformation.xsl`.
1012+
]]>
1013+
</xs:documentation>
1014+
</xs:annotation>
1015+
</xs:attribute>
10071016
<xs:sequence>
10081017
<xs:element name="thesaurus" minOccurs="1" maxOccurs="unbounded">
10091018
<xs:complexType>
@@ -2304,7 +2313,7 @@ This can allow to build dynamic snippet based on the current record.
23042313
<mrd:onLine>
23052314
<cit:CI_OnlineResource>
23062315
<cit:linkage>
2307-
<gco:CharacterString>https://geoadata.wallonie.be/dataset/${uuid}</gco:CharacterString>
2316+
<gco:CharacterString>https://geodata.wallonie.be/dataset/${uuid}</gco:CharacterString>
23082317
</cit:linkage>
23092318
23102319

schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/layout/config-editor.xml

+4-14
Original file line numberDiff line numberDiff line change
@@ -720,13 +720,8 @@
720720
<for name="cit:CI_Organisation"/>
721721
<for name="gfc:listedValue"/>
722722
</flatModeExceptions>
723-
<thesaurusList>
724-
<thesaurus key="external.theme.httpinspireeceuropaeutheme-theme" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
725-
<thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistIACSData-IACSData" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
726-
<thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistSpatialScope-SpatialScope" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
727-
<thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistPriorityDataset-PriorityDataset" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
728-
<thesaurus key="external.theme.httpinspireeceuropaeufeatureconcept-featureconcept" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
729-
</thesaurusList>
723+
724+
<thesaurusList defaultTransformation="to-iso19115-3.2018-keyword-with-anchor"/>
730725
</view>
731726

732727

@@ -861,13 +856,8 @@
861856
<section xpath="/mdb:MD_Metadata/mdb:applicationSchemaInfo" or="applicationSchemaInfo"
862857
in="/mdb:MD_Metadata"/>
863858
</tab>
864-
<thesaurusList>
865-
<thesaurus key="external.theme.httpinspireeceuropaeutheme-theme" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
866-
<thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistIACSData-IACSData" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
867-
<thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistSpatialScope-SpatialScope" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
868-
<thesaurus key="external.theme.httpinspireeceuropaeumetadatacodelistPriorityDataset-PriorityDataset" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
869-
<thesaurus key="external.theme.httpinspireeceuropaeufeatureconcept-featureconcept" transformations="to-iso19115-3.2018-keyword-with-anchor"/>
870-
</thesaurusList>
859+
860+
<thesaurusList defaultTransformation="to-iso19115-3.2018-keyword-with-anchor"/>
871861
</view>
872862
<view name="xml">
873863
<sidePanel>

schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/layout/layout-custom-fields-keywords.xsl

+18-5
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,28 @@
184184
else mri:keyword/*[1][. != '']/replace(text(), ',', ',,'), ',')"/>
185185

186186
<!-- Define the list of transformation mode available. -->
187+
<xsl:variable name="listOfTransformation"
188+
select="if ($thesaurusConfig/@transformations)
189+
then tokenize($thesaurusConfig/@transformations, ',')
190+
else if ($thesaurusList/@defaultTransformation)
191+
then ($thesaurusList/@defaultTransformation)
192+
else ()"
193+
as="xs:string*"/>
194+
187195
<xsl:variable name="transformations"
188196
as="xs:string"
189-
select="if ($thesaurusConfig/@transformations != '')
190-
then $thesaurusConfig/@transformations
191-
else 'to-iso19115-3.2018-keyword,to-iso19115-3.2018-keyword-with-anchor,to-iso19115-3.2018-keyword-as-xlink'"/>
197+
select="if (count($listOfTransformation) > 0)
198+
then string-join($listOfTransformation, ',')
199+
else if ($isXlinkEnabled)
200+
then 'to-iso19115-3.2018-keyword,to-iso19115-3.2018-keyword-with-anchor,to-iso19115-3.2018-keyword-as-xlink'
201+
else 'to-iso19115-3.2018-keyword,to-iso19115-3.2018-keyword-with-anchor'"/>
192202

193-
<!-- Get current transformation mode based on XML fragement analysis -->
203+
<!-- Current transformation is the editor configuration if only one mode is allowed
204+
and if not then the mode is based on the XML fragment analysis -->
194205
<xsl:variable name="transformation"
195-
select="if (parent::node()/@xlink:href)
206+
select="if (count($listOfTransformation) = 1)
207+
then $listOfTransformation[1]
208+
else if (parent::node()/@xlink:href)
196209
then 'to-iso19115-3.2018-keyword-as-xlink'
197210
else if (count(mri:keyword/gcx:Anchor) > 0)
198211
then 'to-iso19115-3.2018-keyword-with-anchor'

schemas/iso19139/src/main/plugin/iso19139/layout/config-editor.xml

+4-7
Original file line numberDiff line numberDiff line change
@@ -3233,7 +3233,7 @@
32333233
editActions: []}]"
32343234
/>
32353235

3236-
<directive data-gn-associated-resources-panel="gnCurrentEdit.metadata" />
3236+
<directive data-gn-associated-resources-panel="gnCurrentEdit.metadata"/>
32373237

32383238
<directive gn-geo-publisher=""
32393239
data-ng-if="gnCurrentEdit.geoPublisherConfig"
@@ -3334,12 +3334,7 @@
33343334
transformations="to-iso19139-keyword-with-anchor"/>
33353335
</thesaurusList>
33363336
-->
3337-
3338-
<thesaurusList>
3339-
<thesaurus key="external.none.allThesaurus"
3340-
fieldset="false"/>
3341-
</thesaurusList>
3342-
3337+
<thesaurusList defaultTransformation="to-iso19139-keyword-with-anchor"/>
33433338
</view>
33443339
<view name="advanced"
33453340
class="gn-label-above-input gn-indent-bluescale">
@@ -3441,6 +3436,8 @@
34413436
<section xpath="/gmd:MD_Metadata/gmd:applicationSchemaInfo" or="applicationSchemaInfo"
34423437
in="/gmd:MD_Metadata"/>
34433438
</tab>
3439+
3440+
<thesaurusList defaultTransformation="to-iso19139-keyword-with-anchor"/>
34443441
</view>
34453442
<view name="xml">
34463443
<sidePanel>

schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-fields-keywords.xsl

+25-9
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,35 @@
220220
gmd:keyword//*[@locale = concat('#', $guiLangId)][. != '']/replace(text(), ',', ',,')
221221
else gmd:keyword/*[1][. != '']/replace(text(), ',', ',,'), ',')"/>
222222

223+
223224
<!-- Define the list of transformation mode available. -->
225+
<xsl:variable name="listOfTransformation"
226+
select="if ($thesaurusConfig/@transformations)
227+
then tokenize($thesaurusConfig/@transformations, ',')
228+
else if ($thesaurusList/@defaultTransformation)
229+
then ($thesaurusList/@defaultTransformation)
230+
else ()"
231+
as="xs:string*"/>
232+
224233
<xsl:variable name="transformations"
225234
as="xs:string"
226-
select="if ($thesaurusConfig/@transformations != '')
227-
then $thesaurusConfig/@transformations
228-
else 'to-iso19139-keyword,to-iso19139-keyword-with-anchor,to-iso19139-keyword-as-xlink'"/>
229-
230-
<!-- Get current transformation mode based on XML fragment analysis -->
235+
select="if (count($listOfTransformation) > 0)
236+
then string-join($listOfTransformation, ',')
237+
else if ($isXlinkEnabled)
238+
then 'to-iso19139-keyword,to-iso19139-keyword-with-anchor,to-iso19139-keyword-as-xlink'
239+
else 'to-iso19139-keyword,to-iso19139-keyword-with-anchor'"/>
240+
241+
<!-- Current transformation is the editor configuration if only one mode is allowed
242+
and if not then the mode is based on the XML fragment analysis -->
231243
<xsl:variable name="transformation"
232-
select="if (parent::node()/@xlink:href) then 'to-iso19139-keyword-as-xlink'
233-
else if (count(gmd:keyword/gmx:Anchor) > 0)
234-
then 'to-iso19139-keyword-with-anchor'
235-
else 'to-iso19139-keyword'"/>
244+
select="if (count($listOfTransformation) = 1)
245+
then $listOfTransformation[1]
246+
else if (parent::node()/@xlink:href)
247+
then 'to-iso19139-keyword-as-xlink'
248+
else if (count(gmd:keyword/gmx:Anchor) > 0)
249+
then 'to-iso19139-keyword-with-anchor'
250+
else 'to-iso19139-keyword'"/>
251+
236252

237253
<xsl:variable name="parentName" select="name(..)"/>
238254

web/src/main/webapp/xslt/common/base-variables-metadata-editor.xsl

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2626
xmlns:saxon="http://saxon.sf.net/"
27+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
28+
xmlns:util="java:org.fao.geonet.util.XslUtil"
2729
version="2.0" extension-element-prefixes="saxon"
2830
>
2931
<!--
@@ -35,6 +37,10 @@
3537

3638
<xsl:variable name="showValidationErrors" select="/root/request/showvalidationerrors"/>
3739

40+
<xsl:variable name="isXlinkEnabled"
41+
as="xs:boolean"
42+
select="util:getSettingValue('system/xlinkResolver/enable') = 'true'"/>
43+
3844
<!-- Default form field type is text input. -->
3945
<xsl:variable name="defaultFieldType" select="'text'"/>
4046

0 commit comments

Comments
 (0)