Skip to content

Formatter / Full view missing/extra matching nodes#9203

Open
fxprunayre wants to merge 1 commit intomainfrom
44-formatterdeepequal
Open

Formatter / Full view missing/extra matching nodes#9203
fxprunayre wants to merge 1 commit intomainfrom
44-formatterdeepequal

Conversation

@fxprunayre
Copy link
Member

@fxprunayre fxprunayre commented Mar 16, 2026

In #9000, we added a tentative fix for improving labels when translations contains labels with xpath context.

eg.

<element name="gmd:description" context="/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:description"> <label>Beschrijving temporele dekking</label> <description>temporele dekking van de data, gespecificeerd als een periode.</description> </element>

This was not working due to the formatter reading the editor config, find matching field/section to render using saxon evaluate function. One drawback is that when using this function, the returned node does not have its context (eg. .. to get its parent). So the logic to get label based on xpath can't work.

To avoid this a check was made to retrieve the corresponding the original node in the document and deep-equal function was used for that. But we noticed some case not handled

  • Fix missing section in full view #9163 2 sections matching the xpath of the editor config (due to wrong usage of deep-equal)
  • More than one node matching at different location in the document (eg. a DCAT-AP document with the same license in Catalog and DataService will display the 2 license for the service). This should only happen on custom editor view (ISO default and advanced view should probably not be affected by that case)
<section name="serviceInformation"> <section xpath="/rdf:RDF/dcat:Catalog/dcat:service/dcat:DataService/dct:license"/>
image
  • No matching element when using a section with a forEach attribute (eg. dct:rights is not rendered).
 <section name="distribution" forEach="/rdf:RDF/dcat:Catalog/dcat:dataset/dcat:Dataset/dcat:distribution" del="."> <section xpath="dcat:Distribution/dct:rights"/>

Note: In edit mode, unique ref in gn:element is used to retrieve
original node which is more reliable but can't be used in view mode.

Proposal is to find the original node using deep-equal and then checking using node xpath matching when the xpath does not make use of wildcard. If wildcard, then evaluate returned nodes are used (and may cause the label issue).

Related

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation
@fxprunayre fxprunayre force-pushed the 44-formatterdeepequal branch 2 times, most recently from e16ce57 to 4fe4fc4 Compare March 16, 2026 16:56
@fxprunayre fxprunayre marked this pull request as ready for review March 17, 2026 08:10
Copy link
Contributor

@joachimnielandt joachimnielandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally for DCAT record that has two equal LicenseDocuments on DataService and Catalog levels.

@fxprunayre fxprunayre force-pushed the 44-formatterdeepequal branch from eae176d to cda303f Compare March 17, 2026 14:26
@fxprunayre fxprunayre mentioned this pull request Mar 19, 2026
10 tasks
In #9000, we added a tentative fix for improving labels when translations contains labels with xpath context. eg. ```xml <element name="gmd:description" context="/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:description"> <label>Beschrijving temporele dekking</label> <description>temporele dekking van de data, gespecificeerd als een periode.</description> </element> ``` This was not working due to the formatter reading the editor config, find matching field/section to render using saxon `evaluate` function. One drawback is that when using this function, the returned node does not have its context (eg. `..` to get its parent). So the logic to get label based on xpath can't work. To avoid this a check was made to retrieve the corresponding the original node in the document and `deep-equal` function was used for that. But we noticed some case not handled * #9163 2 sections matching the xpath of the editor config (due to wrong usage of deep-equal) * More than one node matching at different location in the document (eg. a DCAT-AP document with the same license in Catalog and Service will display the 2 license for the service). * No matching element when using a section with a forEach attribute. Note: In edit mode, unique ref in `gn:element` is used to retrieve original node which is more reliable but can't be used in view mode. Proposal is to find the original node using `deep-equal` and then checking using node xpath matching when the xpath does not make use of wildcard. If wildcard, then `evaluate` returned nodes are used (and may cause the label issue). Related * #9000 * #9163
@fxprunayre fxprunayre force-pushed the 44-formatterdeepequal branch from cda303f to b18b2ef Compare March 19, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants