geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
427 stars 489 forks source link

Editor / Custom view (eg. INSPIRE) / multilingual elements lost when a template mode is used #1262

Closed josegar74 closed 8 years ago

josegar74 commented 9 years ago

issue-multilingual.xml.txt

Test case:

1) System settings, set the Configuration per standard field default view for iso19139 to inspire, like:

{"iso19110":{"defaultTab":"default","displayToolTip":false,"related":
{"display":true,"readonly":true,"categories":["dataset"]},"validation":{"display":true}},
"iso19139":{"defaultTab":"inspire","displayToolTip":false,
"related":{"display":true,"categories":[]},"suggestion":{"display":true},
"validation":{"display":true}},"dublin-core":{"defaultTab":"default",
"related":{"display":true,"readonly":false,"categories":["parent","onlinesrc"]}}}

2) Import the attached metadata that has 2 data quality sections with a lineage statement each one.

3) Edit the metadata -> No fields are displayed and the console the following error is output:

Error on line 21 of functions-metadata.xsl:
  XTTE0780: A sequence of more than one item is not allowed as the result of function
  gn-fn-metadata:getOriginalNode() (<gco:CharacterString/>, <gmd:PT_FreeText/>)

4) System settings, set the Configuration per standard field default view for iso19139 to simple, like:

{"iso19110":{"defaultTab":"default","displayToolTip":false,"related":
{"display":true,"readonly":true,"categories":["dataset"]},"validation":{"display":true}},
"iso19139":{"defaultTab":"simple","displayToolTip":false,
"related":{"display":true,"categories":[]},"suggestion":{"display":true},
"validation":{"display":true}},"dublin-core":{"defaultTab":"default",
"related":{"display":true,"readonly":false,"categories":["parent","onlinesrc"]}}}

3) Edit the metadata -> Metadata can be edited.

josegar74 commented 9 years ago

The problem is that

https://github.com/geonetwork/core-geonetwork/blob/3.0.x/web/src/main/webapp/xslt/common/functions-metadata.xsl#L21

returns a list of ref ids, for the gco:CharacterString and the gmd:PT_FreeText

I have change this:

https://github.com/geonetwork/core-geonetwork/blob/3.0.x/web/src/main/webapp/xslt/common/functions-metadata.xsl#L22

To this, to select the first element and the INSPIRE view looks fine displaying both values, but to check further:

<xsl:variable name="node" select="$metadata//*[gn:element/@ref = $nodeRef[0]]"/>

@fxprunayre if you can take a look to the change proposed, would be great. You know better this code.

fxprunayre commented 9 years ago

The problem only applies to the template mode widget.

For the record, getOriginalNode was introduced to fix https://github.com/geonetwork/core-geonetwork/issues/875

It is related to that call https://github.com/geonetwork/core-geonetwork/blob/3.0.x/web/src/main/webapp/xslt/ui-metadata/form-configurator.xsl#L341 which send a list of nodes.

Turning debug mode on:

#getOriginalNode ==================
289 290
Match with ref: 289 290
<gco:CharacterString xmlns:gn="http://www.fao.org/geonetwork" xmlns:xlink="http://www.w3.org/1999/xlink"
                     xmlns:gmd="http://www.isotc211.org/2005/gmd"
                     xmlns:srv="http://www.isotc211.org/2005/srv"
                     xmlns:gmx="http://www.isotc211.org/2005/gmx"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:gco="http://www.isotc211.org/2005/gco"
                     xmlns:gml="http://www.opengis.net/gml"
                     xmlns:gts="http://www.isotc211.org/2005/gts"
                     xmlns:geonet="http://www.fao.org/geonetwork">INSPIRE Data Specification on Administrative Units - Guidelines v3.0.1<geonet:element ref="289" parent="288"
                   uuid="gco:CharacterString_df3a69a5-72b8-4d49-86fb-6cb298f2e350"
                   min="1"
                   max="1"/></gco:CharacterString><gmd:PT_FreeText xmlns:gn="http://www.fao.org/geonetwork" xmlns:xlink="http://www.w3.org/1999/xlink"
                 xmlns:gmd="http://www.isotc211.org/2005/gmd"

So the template mode does not support multilingual editing. eg.

          <field name="conformity" templateModeOnly="true"
                 xpath="/gmd:MD_Metadata/gmd:dataQualityInfo/gmd:DQ_DataQuality/
                    gmd:report/gmd:DQ_DomainConsistency/gmd:result"
                 del="../..">
            <template>
              <values>
                <key label="conformity_title"
                     xpath="gmd:DQ_ConformanceResult/
                          gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString"
                     tooltip="gmd:pass">
                  <helper name="gmd:title" context="/gmd:MD_Metadata/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:title"/>
                </key>
              </values>
              <snippet>
                <gmd:result>
                  <gmd:DQ_ConformanceResult>
                    <gmd:specification>
                      <gmd:CI_Citation>
                        <gmd:title>
                          <gco:CharacterString>{{conformity_title}}</gco:CharacterString>
                        </gmd:title>

We could at least copy PT_FreeText to avoid losing the information using :

                        <gmd:title>
                          <gco:CharacterString>{{conformity_title}}</gco:CharacterString>
                          <gn:copy select="gmd:PT_FreeText"/>
                        </gmd:title>

But it would be better to have the multilingual editing widget here. Not sure how to improve that.

fxprunayre commented 8 years ago

FYI, getOriginalNode has been improved in https://github.com/geonetwork/core-geonetwork/issues/1328 but would not solve the multilingual editing in INSPIRE view.

fxprunayre commented 8 years ago

Applied the fix suggested - a template field will allow editing the main language (and preserve translation). Closing that ticket.

Create a new one, if you need to add support for multilingual element in template field.