Skip to content

Fix #354: Remove empty RDF Description nodes after unsetModifiedDates#481

Open
dyrpsf wants to merge 2 commits into
sbmlteam:developmentfrom
dyrpsf:fix-issue-354-empty-rdf
Open

Fix #354: Remove empty RDF Description nodes after unsetModifiedDates#481
dyrpsf wants to merge 2 commits into
sbmlteam:developmentfrom
dyrpsf:fix-issue-354-empty-rdf

Conversation

@dyrpsf

@dyrpsf dyrpsf commented Jun 27, 2026

Copy link
Copy Markdown

Description

Updated the SBase::reconstructRDFAnnotation() cleanup logic in src/sbml/SBase.cpp. Added a routine at the end of the function to iterate backwards through the RDF node's children and delete any <rdf:Description> elements that have zero inner children. If the parent <rdf:RDF> block becomes completely empty as a result, it is also safely removed.
I also added a unit test (test_SBase_unsetModifiedDates_issue354) in src/sbml/test/TestSBase.cpp to explicitly verify that no detritus is left behind when dates are removed.

Motivation and Context

Previously, calling unsetModifiedDates would successfully remove the date nodes but leave behind empty <rdf:Description rdf:about="#foo"/> elements in the XML tree. Over multiple cycles, these empty tags would accumulate as detritus in the model's annotation. This change ensures the XML tree remains clean after node removal.
Fixes #354

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Change in documentation

Checklist:

  • I have updated all documentation necessary.
  • I have checked spelling in (new) comments.

Testing

  • Testing is done automatically and codecov shows test coverage
  • This cannot be tested automatically ```

@fbergmann fbergmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dyrpsf thank you for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding and removing modified times leaves detritus

2 participants