We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi!
I have an external provided XSD-schema that contains a type definition like that:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://wu.ac.at/myns" targetNamespace="http://wu.ac.at/myns" elementFormDefault="qualified" version="1.0"> <xs:simpleType name="myType"> <xs:restriction base="xs:decimal"> <xs:whiteSpace value="collapse"/> <xs:fractionDigits value="1"/> <xs:totalDigits value="3"/> <xs:pattern value="^[0-9]{1,3}(|[,.][0-9]{1})$"/> </xs:restriction> </xs:simpleType> <xs:element name="myelem" type="myType"/> </xs:schema>
Unfortunately the generated dataclass contains a value field of type str, not Decimal:
value
str
Decimal
@dataclass class Myelem: class Meta: name = "myelem" namespace = "http://wu.ac.at/myns" value: str = field( default="", metadata={ "required": True, "total_digits": 3, "fraction_digits": 1, "white_space": "collapse", "pattern": r"^[0-9]{1,3}(|[,.][0-9]{1})$", } )
If I comment out the xs:pattern restriction, the field is generated as expected: as type Decimal.
xs:pattern
I am not an xsd expert but for me it looks like xs:pattern should be allowed in this context: https://www.oreilly.com/library/view/xml-schema/0596002521/re62.html
Cheers, --leo
The text was updated successfully, but these errors were encountered:
I just found a related issue #720
--ignore-patterns solves my problem.
--ignore-patterns
Sorry for the noise. Cheers, --leo
Sorry, something went wrong.
No branches or pull requests
Hi!
I have an external provided XSD-schema that contains a type definition like that:
Unfortunately the generated dataclass contains a
value
field of typestr
, notDecimal
:If I comment out the
xs:pattern
restriction, the field is generated as expected: as typeDecimal
.I am not an xsd expert but for me it looks like
xs:pattern
should be allowed in this context:https://www.oreilly.com/library/view/xml-schema/0596002521/re62.html
Cheers,
--leo
The text was updated successfully, but these errors were encountered: