Closed lucabotti closed 2 years ago
Hey @lucabotti can you provide the schema please or a sample? The error refers to a case I thought it was impossible to occur.
Here is the issue
<xsd:complexType name="GenderCodeType">
<xsd:simpleContent>
<xsd:restriction base="cdt:CodeType">
<xsd:enumeration value="Male" />
<xsd:enumeration value="Female" />
<xsd:enumeration value="Neutral" />
<xsd:enumeration value="Other" />
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="CodeType">
<xsd:simpleContent>
<xsd:extension base="xsd:token">
<xsd:attribute
name="listID"
type="xsd:token"
use="optional">
</xsd:attribute>
<xsd:attribute
name="listAgencyID"
type="xsd:token"
use="optional">
</xsd:attribute>
<xsd:attribute
name="listAgencyName"
type="xsd:string"
use="optional">
</xsd:annotation>
</xsd:attribute>
...
...
...
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
The gender code type is clearly an enumeration and the base class is not. Jaxb translates that to
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "GenderCodeType")
public class GenderCodeType
extends CodeType
{
}
Which practically eliminates the enumeration, I am not so sure if this is the correct way, do you have any xml samples that go with that suite?
I thought this scenario was not allowed or something, since none of my 25k samples have it. The easiest approach would be to mimick xjc but I am not so sure that's correct either, that's why I would like some xml samples to see if there is a better alternative.
Hi,
Pyxbgen (old, I know) managed the enumeration with the attached file. I have same examples of Agreement I attach.
Hey @lucabotti thanks for reporting this issue, interesting suite, I added it in the samples.
A fix is on master, it's not really what I wanted but it follows jaxb practise. The issue is about restricting complex/simple content types with specific enumeration values. Ideally I wanted to be able to something like this, but mypy doesn't allow for that.
class Foo:
value: str
class Bar(Foo):
value : SomeEnumeration
class SomeEnumeration(Enum):
A = 1
B = 2
So for now the end result will be like this, I will try to find a solution to somehow keep the enumeration values either as python Literals
or try to make enumerations to play nicely with mypy but that will require some more time.
class Foo:
value: str
class Bar(Foo):
pass
I opened a new issue to follow up with a proper, if possible, solution in the future #663
HI Tefra,
thanks. Will check everything.
While generating bindings with the following command:
xsdata generate -r xsd --package generali.service-models
I receive the following error
xsdata.exceptions.CodeGenerationError: Enumeration class with a complex extension.
JAXB (Java API) manages the xsd , and I submitted the same to w3c org validator. Any way to get more details about the error?