xuri / xgen

XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
BSD 3-Clause "New" or "Revised" License
313 stars 74 forks source link

Empty type on xsd:element not handled as anyType ? #49

Closed Eusebiotrigo closed 4 months ago

Eusebiotrigo commented 2 years ago

Description

I am using xgen to generate code in go.

The xsd extract is:

and the code generated for that Type is: type AccountHolderType struct { XMLName xml.Name `xml:"AccountHolder_Type"` Individual *NameReportableSellerType `xml:"Individual"` Organisation *OrganisationPartyType `xml:"Organisation"` AcctHolderType *AcctHolderType `xml:"AcctHolderType"` } And that **AcctHolderType** points to nothing, and, to be honest, not sure if it should generate a type or a string or it is that the XSD needs to declare its type there. **Steps to reproduce the issue:** 1. Use xgen to generate the code in goLang 2. Use the DPIXML_v1.08.xsd from https://www.oecd.org/tax/exchange-of-tax-information/DPI-DAC7-XML-Schema-and-User-Guide-v2.03.zip **Describe the results you received:** type AccountHolderType struct { XMLName xml.Name `xml:"AccountHolder_Type"` Individual *NameReportableSellerType `xml:"Individual"` Organisation *OrganisationPartyType `xml:"Organisation"` AcctHolderType *AcctHolderType `xml:"AcctHolderType"` } **Describe the results you expected:** Not really sure what to expect, but code does not compile as there is no AcctHolderType type declared **Output of `go version`:** ```text go version go1.16.15 linux/amd64 ``` **xgen version or commit ID:** ```text xgen version: 0.1.0 ``` **Environment details (OS, physical, etc.):** Fedora35