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

Multiple "xs:list" in "xs:complexType" Causing Error #30

Open barnesew opened 2 years ago

barnesew commented 2 years ago

Description

I am attempting to generate code based on some XSD files that utilize the "include" and "import" syntax. The problem is that I get the following error:

process error on schema/process/services/service/LibraryConfiguration.xsd: 14:7: expected 'IDENT', found '['

I did some investigating and discovered it happens when there are multiple xs:list types at the same level under an xs:complexType. When I comment out two of the three xs:element sections that contain the xs:list, the code can be successfully generated.

Example files used: process.zip

Steps to reproduce the issue:

  1. Using the files above, I run the following command on the process directory: xgen -i schema/process/ -p generatedxml -o output/ -l Go
  2. Get the following error: process error on schema/process/services/service/LibraryConfiguration.xsd: 14:7: expected 'IDENT', found '['

Steps to fix the example files:

  1. Comment out lines 17-32 of the "LibraryConfiguration.xsd" file (The second and third xs:element sections).
  2. With the modified files run: xgen -i schema/process/ -p generatedxml -o output/ -l Go
  3. Code generates successfully.

Output of go version:

go version go1.16.7 darwin/arm64

xgen version or commit ID:

xgen version: 0.1.0

Environment details (OS, physical, etc.):

Output of go env:

GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/barnesew/Library/Caches/go-build"
GOENV="/Users/barnesew/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/barnesew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/barnesew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16.7"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/barnesew/Documents/tms/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y0/0w2cgh_s3ls1jbw51q6zrq4r0000gn/T/go-build3987189383=/tmp/go-build -gno-record-gcc-switches -fno-common"
ndew623 commented 2 years ago

Same problem, this works:

<xs:sequence>
            <xs:element name="element1" type="xs:int"></xs:element>
            <!--<xs:element name="element2">
                <xs:simpleType>
                    <xs:list itemType="Character">
                    </xs:list>
                </xs:simpleType>
            </xs:element> -->
            <xs:element name="element3" type="xs:double"></xs:element>
            <xs:element name="element4" type="Character"></xs:element>

            <xs:element name="element5" >
                <xs:simpleType>
                    <xs:list itemType="Character">
                    </xs:list>
                </xs:simpleType>

            </xs:element>
</xs:sequence>

But if I uncomment "element2" I get the expected 'IDENT', found '[' error.