xml: IndexError when parsing XML with empty <qualifier/> tags
I used the AASX Package Explorer (version 2021-01-16.alpha) to create a minimal AASX file with one asset, one AAS, one submodel and one property (see test1.aasx). When opening the file with PyI40AAS, I get an IndexError
:
Traceback (most recent call last):
File "open-aas.py", line 16, in <module>
reader.read_into(object_store, file_store)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\aasx.py", line 139, in read_into
self._read_aas_part_into(aas_part, object_store, file_store, read_identifiables, override_existing)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\aasx.py", line 180, in _read_aas_part_into
for obj in self._parse_aas_part(part_name):
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\aasx.py", line 210, in _parse_aas_part
return read_aas_xml_file(p)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 1398, in read_aas_xml_file
read_aas_xml_file_into(object_store, file, **kwargs)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 1366, in read_aas_xml_file_into
for element in _child_construct_multiple(list_, element_tag, constructor, decoder_.failsafe):
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 326, in _failsafe_construct_multiple
parsed = _failsafe_construct(element, constructor, failsafe, **kwargs)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 280, in _failsafe_construct
return constructor(element, **kwargs)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 982, in construct_submodel
constructed = _failsafe_construct(submodel_element[0], cls.construct_submodel_element, cls.failsafe)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 280, in _failsafe_construct
return constructor(element, **kwargs)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 665, in construct_submodel_element
return cls.construct_data_element(element, abstract_class_name="SubmodelElement", **kwargs)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 685, in construct_data_element
return data_elements[element.tag](element, **kwargs)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 851, in construct_property
cls._amend_abstract_attributes(property_, element)
File "c:\users\krahlro\venv\aas\src\pyi40aas\aas\adapter\xml\xml_deserialization.py", line 446, in _amend_abstract_attributes
constructed = _failsafe_construct(constraint[0], cls.construct_constraint, cls.failsafe)
File "src\lxml\etree.pyx", line 1161, in lxml.etree._Element.__getitem__
IndexError: list index out of range
This is the code I used to open the file:
filename = sys.argv[1]
try:
object_store = model.DictObjectStore()
file_store = aasx.DictSupplementaryFileContainer()
with aasx.AASXReader(filename) as reader:
reader.read_into(object_store, file_store)
cp = reader.get_core_properties()
print(filename, "SUCCESS", cp, sep="\t")
except:
print(filename, "ERROR", sep="\t", flush=True)
traceback.print_exc()
The error occurs both with the 0.2.0 release and the current development version 852c6f0a.