Skip to content

PROV-XML round-trip drops attributes whose value is the empty string #224

Description

@trungdong

Found by the Task 13 Hypothesis property-based round-trip tests (src/prov/tests/test_property_roundtrip.py).

An other_attributes entry whose value is the empty string "" round-trips correctly through PROV-JSON and PROV-O (RDF) but is dropped entirely by the PROV-XML serializer — the attribute vanishes, so the reloaded document is unequal to the original.

Reproduction:

import io
from prov.model import ProvDocument

def rt(d, fmt):
    s = io.BytesIO(); d.serialize(destination=s, format=fmt, indent=4); s.seek(0)
    return ProvDocument.deserialize(source=s, format=fmt)

d = ProvDocument(); d.add_namespace("ex", "http://example.org/")
d.agent("ex:g0", {"ex:k0": ""})
print("json:", rt(d, "json") == d)  # True
print("xml: ", rt(d, "xml")  == d)  # False  <-- attribute dropped
print("rdf: ", rt(d, "rdf")  == d)  # True

The XML round trip yields agent(ex:g0) with no ex:k0 attribute.

Status: deferred to 3.0.0 under the 2.x output freeze. Excluded from Hypothesis generation via min_size=1 on the text-value strategy (src/prov/tests/strategies.py), commented pointing here. No behaviour change made in 2.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions