I am working with large xml files called .arxml, the schema for which can be seen here. When I parse an .arxml file and then serialize to a new file and compare the input and output, all UUID attributes are dropped. For example, the element
<AR-PACKAGE UUID="9cf6b2b6-a372-4379-a9c8-221de5abe4e1-ECUSystem">
is reduced to
<AR-PACKAGE>
Why is this? The UUID attributes might not be specified as mandatory in the xsd, but should they be dropped if they aren't? Examples of elements that lose their UUID elements are AR-PACKAGE, ECU-INSTANCE, SDG, SD, COUPLING-PORT.
Below are the steps that I have taken to arrive at my current problem.
xsdata "C:\<path_to_file>\AUTOSAR_4-2-2.xsd" --package autosar_classes
Followed by running the below python script
from pathlib import Path
from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig
import autosar_classes as ac
parser = XmlParser()
root = parser.from_path(Path("sample.arxml"), ac.Autosar)
serializer_config = SerializerConfig(pretty_print=True)
serializer = XmlSerializer(serializer_config)
path = Path("modified.arxml")
with path.open("w") as fp:
serializer.write(fp, root, ns_map={"": "http://autosar.org/schema/r4.0"})
CodePudding user response:
UUID does not have a semantic meaning and therefore AUTOSAR Tools are not required to load or persist it.
I haven't processed ARXML with Python yet but I assume there is an option to persist UUID or drop it.
If you are creating a new ARXML file from an input file(s) then you shouldn't even care about carrying over the UUID.
CodePudding user response:
I created an issue in the github repository of xsData, and it appears to have been a bug that caused the dropping of some attributes. The maintainer responded promptly and the fix is now on master.