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
410 stars 487 forks source link

EditLib - xml fragment replacement doesn't replace the element attributes #5844

Open josegar74 opened 3 years ago

josegar74 commented 3 years ago

Sending a xml fragment to replace in the metadata, like for example do some directives, replaces the element children, but not the attributes of the element:

_X124_replace=<gmd:pass xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco"><gco:Boolean>true</gco:Boolean></gmd:pass>

With the previous snippet, if the original element gmd:pass has an attribute gco:nilReason='unknown', the attribute is preserved, what seem not correct.

Related code:

https://github.com/geonetwork/core-geonetwork/blob/57a963d64262eb9625f04bae0247ab6cec799078/core/src/main/java/org/fao/geonet/kernel/EditLib.java#L339-L359

archaeogeek commented 3 months ago

@josegar74 I think I'm still seeing this, in GeoNetwork 4.2.x but I'm not sure if it's quite the same problem! With the data-gn-checkbox-with-nilreason directive for the gmd:pass element for conformity, I see a conflict between inflate-metadata.xsl(where the boolean is expanded) and update-fixed-info.xsl where it is removed. When validating, update-fixed-info fires first, then inflate-metadata.xsl, so you always end up with an empty <boolean/> element, which fails validation. Is this the same issue? Happy to open a new issue if not.