fix keyError default
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <dccXMLJSONConv.dccConv.XMLSchemaConverter object at 0x7fa3f9fba660>
input_data = '<?xml version="1.0" encoding="UTF-8"?>\n<rtd:refTypeDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...stics:result_reciprocity</rtd:dccElement>\n\t\t</rtd:mandatorySubElements>\n\t</rtd:entry>\n</rtd:refTypeDefinition>\n'
def convert_xml_to_json(self, input_data) -> tuple[dict, list[Exception]]:
"""Deserialize XML to JSON
Args:
input_data: xml data to parse. Can be an XMLResource instance, a file-like object a path to a file or a URI of a resource or an Element instance or an ElementTree instance or a string containing the XML data.
Returns:
tuple[dict, list[Exception]]: converted dict; and list of exceptions that occurred during parsing
"""
try:
#TODO check if we have to parse the errors
return self.schema.to_dict(input_data, validation="lax")
except Exception as e:
warnings.warn(f"XML->JSON Validation error: {e}. Attempting template insertion.")
#TODO add logic to find fragments root tag
root_tag = self._getRootElement(input_data)
templateName = self.templateMapping.get(root_tag, "default")
> template_info=self.templates[templateName]
E KeyError: 'default'
/usr/local/lib/python3.13/site-packages/dccXMLJSONConv/dccConv.py:107: KeyError