-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
order of repeating xml tags #433
Comments
I call this case an effective choice of a elements or repeating elements. If the elements were part of a <xsd:complexType name="MSCONS">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="UNH" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="BGM" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="DTM" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="NAD" type="xsd:string" minOccurs="2" maxOccurs="2"/>
<xsd:element name="UNS" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="NAD" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="UNT" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:choice>
</xsd:complexType> You would get a model like this @dataclass
class Mscons:
class Meta:
name = "MSCONS"
choice: List[object] = field(
default_factory=list,
metadata={
"type": "Elements",
"choices": (
{
"name": "UNH",
"type": str,
"namespace": "",
},
{
"name": "BGM",
"type": str,
"namespace": "",
},
{
"name": "DTM",
"type": str,
"namespace": "",
},
{
"name": "NAD",
"type": str,
"namespace": "",
},
{
"name": "UNS",
"type": str,
"namespace": "",
},
{
"name": "UNT",
"type": str,
"namespace": "",
},
),
}
) That model can ensure the input/output ordering of elements. But for now no it's not possible with It's on my todo list for some time now though, I am going to prioritize this one. |
Thank You ! Will waiting. |
The change is master @morskibg give it a try, it should catch most of the cases now For the above example the generator will now create with the flag @dataclass
class Mscons:
class Meta:
name = "MSCONS"
unh: Optional[str] = field(
default=None,
metadata={
"name": "UNH",
"type": "Element",
"namespace": "",
"required": True,
}
)
bgm: Optional[str] = field(
default=None,
metadata={
"name": "BGM",
"type": "Element",
"namespace": "",
"required": True,
}
)
dtm: Optional[str] = field(
default=None,
metadata={
"name": "DTM",
"type": "Element",
"namespace": "",
"required": True,
}
)
nad_or_uns_or_unt: List[object] = field(
default_factory=list,
metadata={
"type": "Elements",
"choices": (
{
"name": "NAD",
"type": str,
"namespace": "",
},
{
"name": "UNS",
"type": str,
"namespace": "",
},
{
"name": "UNT",
"type": str,
"namespace": "",
},
),
"min_occurs": 3,
"max_occurs": 5,
}
) |
Work as a charm !!! Thank You very much ! |
Hello, great work !
I have a little issue (sorry if had been discussed). The schema states:
final created class is:
The XML file for parsing is:
After parsing the segment:
is after 3 NAD, instead to be between 2 and 3 NAD segment
Is there any option to rearrange such a case?
Thank You !
The text was updated successfully, but these errors were encountered: