Skip to content

Redeclaration in output go code #73

@jgoodall

Description

@jgoodall

Description

This seems related to #8, but I dont need an enhancement in the xgen tool, just a way to solve the problem below.

I am having a similar problem when trying to use xgen on the Grobid xsd files: xgen -i ./grobid/grobid-home/schemas/xsd -o ./pkg/extraction/grobid -p grobid -l Go

It creates all the corresponding go files, albeit in a weird directory path (pkg/extraction/grobid/grobid/grobid-home/schemas/xsd/), but after moving the files to the expected path, the go compiler complains found packages schema (Grobid.xsd.go) and grobid (dcr.xsd.go). If I manually change the package from schema to grobid in Grobid.xsd.go I get a bunch of errors related to redeclared in this block. Is there any way to work around this issue?

Steps to reproduce the issue:

  1. xgen -i ./grobid/grobid-home/schemas/xsd -o ./pkg/extraction/grobid -p grobid -l Go
  2. mv pkg/extraction/grobid/grobid/grobid-home/schemas/xsd/* pkg/extraction/grobid && rm -rf pkg/extraction/grobid/grobid/grobid-home
  3. Build:
pkg/extraction/extraction.go:25:2: found packages schema (Grobid.xsd.go) and grobid (dcr.xsd.go) in /Users/ojg/code/corpora/server/pkg/extraction/grobid```
5. Change package name to `grobid` in `Grobid.xsd.go` and build:
```go build -o bin/test .
pkg/extraction/grobid/tei.xsd.go:10:6: P redeclared in this block
	pkg/extraction/grobid/Grobid.xsd.go:2606:6: other declaration of P
pkg/extraction/grobid/tei.xsd.go:20:6: Hi redeclared in this block
	pkg/extraction/grobid/Grobid.xsd.go:2616:6: other declaration of Hi

Describe the results you received:

The code did not compile compile - see output above.

Describe the results you expected:

The code to compile.

Output of go version:

go version go1.22.1 darwin/arm64

xgen version or commit ID:

xgen version: 0.1.0

Environment details (OS, physical, etc.):

macOS 14.4 on MacBook Pro with M2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions