Closed Jacob-Flasheye closed 1 year ago
I guess sequence is implemented using list[...]
and here minOccurs=0 means that it can be omitted, therefore you have to type something like:
class SequenceXmlModel(BaseXmlModel, tag='sequence'):
sequence_item: list[str] = element()
Which will work with:
<sequence>
<sequence_item>a</sequence_item>
<sequence_item>b</sequence_item>
<sequence_item>c</sequence_item>
</sequence>
RESULT: {'sequence': ['a', 'b', 'c']}
and
<sequence>
</sequence>
RESULT: {'sequence': []}
Discussed in https://github.com/dapper91/pydantic-xml/issues/100.
Hi.
I'm trying to implement a schema that includes
sequence
,any
, andanyAttribute
tags. I am still getting familiar with XML (have worked with JSON data mostly) and I'm not sure how, or if it's even possible currently, to implement such types in this library.Here are two snippets from the schema file:
If it is not possible to do, are there any plans to implement this feature? If there is interest, I'm willing to help!