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

Errors in generated Go code: <modelName> redeclared in this block #51

Closed jo-me closed 2 years ago

jo-me commented 2 years ago

Description

Generated Go code contains errors

Steps to reproduce the issue:

  1. Download https://developer.tomtom.com/assets/downloads/intermediate-traffic-service/DATEXIISchema_1_0_1_0_HDT_HDF__TomTomVersion9.xsd
  2. xgen -i DATEXIISchema_1_0_1_0_HDT_HDF__TomTomVersion9.xsd -o .\output -l Go

Describe the results you received: Several errors due to redeclaration of certain identifiers, e.g.: MeasurementSpecificCharacteristics redeclared in this block MeasuredValue redeclared in this block (see details)

Describe the results you expected: Naming conficts should be avoided if the XSD is valid. In go, you could create separate packages to isolate the models or generate model names differently.

Output of go version:

go version go1.17 windows/amd64

xgen version or commit ID:

 github.com/xuri/xgen v0.0.0-20220303053931-2afb9de4af9b

Environment details (OS, physical, etc.): Windows 10 x64

xuri commented 2 years ago

Thanks for your issue. @peng has been fixed this issue, please upgrade to the master branch code.