Skip to content

Commit 128a2ef

Browse files
authored
sdk\basyx\aas\adapter\xml\xml_serialization.py: Remove code duplication (#406)
Previously, the method `object_to_xml_element()` in `sdk\basyx\aas\adapter\xml\xml_serialization.py` contained duplicated code from `submodel_element_to_xml()` and `data_element_to_xml()`. This was due to the class hierarchy of the objects being compared in the if statements. For instance, some models inherit from `model.SubmodelElement`. Because of that, the associated objects are checked for in `submodel_element_to_xml()`. With that, any additional check for these objects in `object_to_xml_element()` are redundant. This removes the code duplication. Fixes #396
1 parent 2755dd7 commit 128a2ef

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

sdk/basyx/aas/adapter/xml/xml_serialization.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -883,38 +883,10 @@ def object_to_xml_element(obj: object) -> etree._Element:
883883
return administrative_information_to_xml(obj)
884884
elif isinstance(obj, model.Qualifier):
885885
return qualifier_to_xml(obj)
886-
elif isinstance(obj, model.AnnotatedRelationshipElement):
887-
return annotated_relationship_element_to_xml(obj)
888-
elif isinstance(obj, model.BasicEventElement):
889-
return basic_event_element_to_xml(obj)
890-
elif isinstance(obj, model.Blob):
891-
return blob_to_xml(obj)
892-
elif isinstance(obj, model.Capability):
893-
return capability_to_xml(obj)
894-
elif isinstance(obj, model.Entity):
895-
return entity_to_xml(obj)
896886
elif isinstance(obj, model.Extension):
897887
return extension_to_xml(obj)
898-
elif isinstance(obj, model.File):
899-
return file_to_xml(obj)
900888
elif isinstance(obj, model.Resource):
901889
return resource_to_xml(obj)
902-
elif isinstance(obj, model.MultiLanguageProperty):
903-
return multi_language_property_to_xml(obj)
904-
elif isinstance(obj, model.Operation):
905-
return operation_to_xml(obj)
906-
elif isinstance(obj, model.Property):
907-
return property_to_xml(obj)
908-
elif isinstance(obj, model.Range):
909-
return range_to_xml(obj)
910-
elif isinstance(obj, model.ReferenceElement):
911-
return reference_element_to_xml(obj)
912-
elif isinstance(obj, model.RelationshipElement):
913-
return relationship_element_to_xml(obj)
914-
elif isinstance(obj, model.SubmodelElementCollection):
915-
return submodel_element_collection_to_xml(obj)
916-
elif isinstance(obj, model.SubmodelElementList):
917-
return submodel_element_list_to_xml(obj)
918890
elif isinstance(obj, model.AssetAdministrationShell):
919891
return asset_administration_shell_to_xml(obj)
920892
elif isinstance(obj, model.AssetInformation):
@@ -936,8 +908,6 @@ def object_to_xml_element(obj: object) -> etree._Element:
936908
elif isinstance(obj, model.DataSpecificationIEC61360):
937909
return data_specification_iec61360_to_xml(obj)
938910
# generic serialization using the functions for abstract classes
939-
elif isinstance(obj, model.DataElement):
940-
return data_element_to_xml(obj)
941911
elif isinstance(obj, model.SubmodelElement):
942912
return submodel_element_to_xml(obj)
943913
elif isinstance(obj, model.DataSpecificationContent):

0 commit comments

Comments
 (0)