xgen
xgen copied to clipboard
Structs missing in generated go code
Description
Some simple types are not generated under given circumstances. The original XSD is not created by me, but is i understand, is old and widely used.
I have no clue of XML, but i managed to dumb the issue down to this short code.
Steps to reproduce the issue:
- See reproducible minimal example code below.
- xgen -l Go -p internal -i resources/xsd/ -o internal/model/
- Check the output.
Describe the results you received: AAA has a struct in go code created.
Describe the results you expected: GGG and DDD has types in go code created as well.
Output of go version
:
go version go1.22.5 linux/amd64
xgen version or commit ID:
xgen version: 0.1.0
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/schemas"
xmlns:ak="http://example.com/schemas"
elementFormDefault="qualified">
<xsd:complexType name="AAA">
<xsd:annotation><xsd:documentation>BBB</xsd:documentation></xsd:annotation>
<xsd:sequence>
<xsd:element name="CCC">
<xsd:simpleType>
<xsd:restriction base="ak:GGG">
<!-- This seems to be the issue, CCC is not generated with this restriction enabled -->
<xsd:minLength value = "4" fixed = "true" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="DDD">
<xsd:annotation><xsd:documentation>EEE</xsd:documentation></xsd:annotation>
<xsd:restriction base="ak:GGG">
<!-- While CCC is ok, this is okay as well. While CCC has the invalid restriction: if any of the following it commented in, DDD is not generated anymore as well. -->
<!-- <xsd:whiteSpace value="collapse" />
<!-- <xsd:minLength value="1" />-->
<!-- <xsd:maxLength value="43" />-->
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="GGG">
<xsd:annotation><xsd:documentation>FFF</xsd:documentation></xsd:annotation>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
Environment details (OS, physical, etc.):