metadata101 / iso19139.ca.HNAP

ISO Harmonized North American Profile (HNAP)
GNU General Public License v2.0
4 stars 19 forks source link

None mandatory Linkage field has red asterisk mark #315

Open wangf1122 opened 1 year ago

wangf1122 commented 1 year ago

Some none mandatory fields for example linkage has the red astrix mark in front

image

The label for this field has no such condition as in this code. https://github.com/metadata101/iso19139.ca.HNAP/blob/33a7855cb24d72425337563d03d13738af713e52/src/main/plugin/iso19139.ca.HNAP/loc/eng/labels.xml#L1298-L1303

I found the logic to place such required mark is probably related to the form builder and its parentEditInfo

https://github.com/geonetwork/core-geonetwork/blob/2731e560fd9e3a8cea16047082cf557d3c0978c5/web/src/main/webapp/xslt/ui-metadata/form-builder.xsl#L116-L120

And this parentEditInfo was passed from HNAP layout.xsl https://github.com/metadata101/iso19139.ca.HNAP/blob/33a7855cb24d72425337563d03d13738af713e52/src/main/plugin/iso19139.ca.HNAP/layout/layout.xsl#L95-L96

So far, this is my investigation. This gmd:linkage is just one of them. There are couple of other fields are forced to set the gn_required (red astrix ) without stating the condition as mandatory.

josegar74 commented 1 year ago

The "problem" is that the code check is using also the cardinality of the element, that indeed is mandatory to be present in the XML:

http://www.datypic.com/sc/niem21/t-gmd_CI_OnlineResource_Type.html

But that doesn't really imply that the element must contain a value.

We could try to remove that check, and verify how affects other elements as probably some will require to add the condition as mandatory to be displayed as currently.

ianwallen commented 11 months ago

Isn't the real problem that it should be based on gmd:onlineResource which is not mandatory according to the following:

http://www.datypic.com/sc/niem21/e-gmd_CI_Contact.html

And only if a the gmd:onlineResource is added then the linkage is required.

josegar74 commented 8 months ago

gmd:linkage is mandatory in http://www.datypic.com/sc/niem21/e-gmd_CI_OnlineResource.html

By default, gmd:onlineResource is not added to contacts, unless you have that in your template, or add it in the advanced view, which adds the following:

 <gmd:onlineResource>
    <gmd:CI_OnlineResource>
        <gmd:linkage>
            <gmd:URL></gmd:URL>
        </gmd:linkage>
        <gmd:protocol gco:nilReason="missing">
            <gco:CharacterString/>
        </gmd:protocol>
        <gmd:name gco:nilReason="missing" xsi:type="gmd:PT_FreeText_PropertyType">
            <gco:CharacterString/>
        </gmd:name>
        <gmd:description gco:nilReason="missing" xsi:type="gmd:PT_FreeText_PropertyType">
            <gco:CharacterString/>
        </gmd:description>
    </gmd:CI_OnlineResource>
</gmd:onlineResource>  

In the default view, this information is flatten, so you just the linkage element, not the container. To remove it you need to go to the full view.

About the mandatory calculation, I think is used for 2 things:

1) Show / hide the delete button. In this case as gmd:linkage is mandatory in the XSD doesn't allow you to remove it, what is correct.

2) Add the mandatory asterisk. This is a bit more confusing, as the usage in GeoNetwork is to indicate XSD mandatory elements, but also can be customised in the labels.xml to define some non XSD mandatory elements, but that require the value filled to validate in the schema.

Maybe we should keep the current check just for 1) and for 2) use the configuration in labels.xml, but need some research.

wangf1122 commented 2 weeks ago

The "problem" is that the code check is using also the cardinality of the element, that indeed is mandatory to be present in the XML:

http://www.datypic.com/sc/niem21/t-gmd_CI_OnlineResource_Type.html

But that doesn't really imply that the element must contain a value.

We could try to remove that check, and verify how affects other elements as probably some will require to add the condition as mandatory to be displayed as currently.

@josegar74

Do you have any sample or suggestion where I can remove such check so I can give it some tests on my localhost?

wangf1122 commented 2 weeks ago

@josegar74 @ianwallen

I have prepared two pull request. One is for Geonetwork render-element in form-builder to have extra parameter to force checking the xsd schema.

https://github.com/geonetwork/core-geonetwork/pull/8294

And one within the HNAP schema, to update the label xml to have the required fields be mandatory and not force to check the xsd schema.

https://github.com/metadata101/iso19139.ca.HNAP/pull/391

Please review and see if it fits the purpose of removing this linkage's red asterisk mark