metaleap / go-xsd

[stable since 2013] a lib for loading XML Schema Definition (XSD) files ➜ plus, a tool `makepkg` to code-generate from any *.xsd your Go package with all needed `struct`s to readily `xml.Unmarshal()` documents into, based on the XSD's schema definitions. NOT REALLY MAINTAINED FOR YEARS NOW: try the forks if running into issues.
http://www.reddit.com/r/golang/comments/12g6sl/is_there_a_tool_that_generates_go_source_code_for/
MIT License
216 stars 66 forks source link

Error adding musicxml #19

Closed BashfulBits closed 7 years ago

BashfulBits commented 9 years ago

I tried to add musicxml support by adding the following bottom three values to schemas:

schemas = []string{
        "www.w3.org/2001/xml.xsd",
...
        "khronos.org/files/collada_schema_1_5",
        "www.musicxml.org/xsd/xml.xsd",
        "www.musicxml.org/xsd/xlink.xsd",
        "www.musicxml.org/xsd/musicxml.xsd",
    }

After this, I can rebuild and run xsd-makepkg and it properly generates musicxml.xsd.go, xlink.xsd.go, and xml.xsd.go. However, when creating a boilerplate program and simply including this new package:

package main
import fmt "fmt"
import "github.com/metaleap/go-xsd-pkg/www.musicxml.com/xsd/musicxml.xsd_go"

I get the following error at the command line when building or running this test program:

# github.com/metaleap/go-xsd-pkg/www.musicxml.com/xsd/musicxml.xsd_go
../../github.com/metaleap/go-xsd-pkg/www.musicxml.com/xsd/musicxml.xsd_go/musicxml.xsd.go:2234: undefined: XsdtNonNegativeInteger

I get the same error in a test.go file I created based on your other tests in go-xsd

Am I doing something wrong?

ghost commented 8 years ago

Not sure if this is useful for original poster anymore, but might help someone else running into a similar issue. This looks similar to issue 12: https://github.com/metaleap/go-xsd/issues/12 It seems that the generator is writing XsdtType instead of xsdt.Type. I believe the solution for your case is to change all instances of XsdtNonNegativeInteger to xsdt.NonNegativeInteger.