XMLSchemaConverter, text_key
Hello, Thank you very much for the package. I just have a quick question about the XMLSchemaConverter.
For the XMLSchemaConverter, why is it necessary for the text_key to not be letters or underscores?
XMLSchemaConverter(text_key='_')
raise XMLSchemaValueError(msg.format(name, value))]
xmlschema.exceptions.XMLSchemaValueError: text_key cannot includes latters or underscores: '_'`
This limits the converted dictionary or JSON to be used with JSON operating packages such as jsonpath_ng. For example, the jsonpath_ng package is unable to parse paths which include symbols in the str path.
Are there any drawbacks from creating my own Converter and overwriting the setattr function to exclude the error check?
Hi,
it is a precaution for avoiding conflicts between attribute/element names and prefixes. This is especially true for attribute prefix, that can cause problems with each element that have the name starting with the same prefix.
I can try to remove this constraint but also adding checks on proposed prefixes at schema level, when creating the converter instance used for decoding/encoding (raising a ValueError in case a prefix has a conflict with any element/attribute).
Considering this meanwhile you can derive your custom class that remove this check.
Thanks
In new release v1.2.1 the text_key, attr_prefix and cdata_prefix can be set also with letters and underscores. I didn't wrote any check at schema level, only refined the prefix checks in converters to avoid collisions with names (anyway collisions could affect the encoding process only, the decoding have no problems).
Cheers