xmlschema
xmlschema copied to clipboard
Add GData converter please
class GData(xmlschema.converters.BadgerFishConverter):
def __init__(self, namespaces: Optional[NamespacesType] = None,
dict_class: Optional[Type[Dict[str, Any]]] = None,
list_class: Optional[Type[List[Any]]] = None,
**kwargs: Any) -> None:
kwargs.update(attr_prefix='', text_key='$t', cdata_prefix='$')
super(xmlschema.converters.BadgerFishConverter, self).__init__(
namespaces, dict_class, list_class, **kwargs
)
Ok, i will for the next minor version ... seems simple but I haven't tried test cases yet.
If you want to make a PR add a module in xmlschema.converters
subpackage (e.g. gdata.py).
thank you
my code doesn't work for encode. I haven't figured it out yet.
Tell me, is it possible to run a check and get not the first error, but all the errors? I admit that in this case the nodes embedded in the prelem element are no longer checked.
After checking http://code.google.com/apis/gdata/docs/json.html the GData convention seems not to be so similar to Badgerfish, so better to derive it from the default converter.
There is other relevant source of information about the GData protocol?
The protocol seems to be a bit lossy if there is a name collision between an attribute and a child element, mitigated by namespace prefixes.
I'll try to implement the GData converter for the next minor release.
The GDataConverter
is available with release v3.1.0.
The new converter is a subclass of the default converter. Similarities with BadgerFishConverter are many but there are differences on mapping the namespaces, so I started copying the BadgerFish converter code and then refactoring as GData requires.
The pecuilarity of namespace mapping og GData has been resolved overriding the methods map_qname()
and unmap_qname()
.
The potential conflict between attributes and child elements has been solver giving the priority to the latters.
Hi @businka, have you tried the GDataConverter
? Does it work as expected?
I close this assuming that GDataConverter works as exptected, reopen if it's not.