eclipse-basyx / basyx-python-sdk

MIT License
61 stars 28 forks source link

model: Allow empty strings in SubmodelElement.value #242

Open WelliSolutions opened 9 months ago

WelliSolutions commented 9 months ago

AAS before processing with Basyx: it has an empty manufacturer name: image

AAS after processing with Basyx: the manufacturer name is gone: image

So, basically the difference is between "" (empty string) and None (null).

IMHO, the cause is in line 219 of xml_deserialization.py

Proposed fix:

    if element is None:
        return None
    return element.text if element.text is not None else ""
s-heppner commented 9 months ago

I see what the problem is there.

Before version 3.0 of the specification, there existed a constraint:

Constraint AASd-100: An attribute with data type "string" is not allowed to be empty

However, that constraint has been removed with v3.0:

AASd-100 Removed: Since new string types with length constraints were added, this constraint is no longer needed

So, the idea behind the removal was, that it already exists implicitly in every data type that is based on string anyway. However, such constraint appears to have been forgotten with the most basic xs:String.

Semantically, it is unclear what is meant with an empty string "" in comparision to a None, therefore we (and the specification as well) did not allow it. Due to the fact, that the behavior of the function you provided is expected in every case except for values of SubmodelElements, your fix sadly is not sufficient.

In order to be fully compliant to the specification, I will convert your Issue to a Bug and we will fix it for v3.0 However, I will also bring this issue up with the specification group.

Thanks for helping to uncover this issue!