elifesciences / elife-tools

Python library for parsing eLife article XML data.
MIT License
15 stars 7 forks source link

Add empty attributes from minidom to elementtree. #317

Closed gnott closed 4 years ago

gnott commented 4 years ago

A bug fix with xmlio.append_minidom_xml_to_elementtree_xml() found when refactoring the PubMed generation library (https://github.com/elifesciences/elife-pubmed-xml-generation).

Trying to retain a minidom element's attributes when adding its data to an ElementTree element, if the tag attribute's value is blank then it is ignored and not added.

Fixing it so an attribute with a blank string as a value is added, by using hasAttribute() instead of getAttribute() in the conditional check.

Test case is updated to show the attribute with a blank value gets added to the XML.

I think we can consider this a bug fix, and it will have limited adverse effect on eLife's code running this library. As such, I don't think this is a breaking change, but a bug fix, that should be safe to integrate into other libraries.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 99.762% when pulling 130a80fca898dce41bafef67e4ab5d6af27ca8f5 on xmlio into 1ca1de40c9747a2ba25559ec5c5f52f00c1fd85e on develop.