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

Nil pointer dereference with http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd #24

Closed jrobsonchase closed 7 years ago

jrobsonchase commented 8 years ago

Trying to get a package generated to parse web.xml files. This was built from commit 56ab80f.

╰─>$ xsd-makepkg -uri "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" -gofmt
2016/08/23 11:20:12 LOAD:   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x47759a]

goroutine 1 [running]:
panic(0x657400, 0xc420014100)
    /home/jchase/.local/lib/go/src/runtime/panic.go:500 +0x1a1
github.com/metaleap/go-xsd.(*RestrictionSimpleEnumeration).makePkg(0xc4201e6840, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/elemmakepkg.go:621 +0x8a
github.com/metaleap/go-xsd.(*hasElemsEnumeration).makePkg(0xc42013fc40, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/hasmakepkg.go:89 +0x55
github.com/metaleap/go-xsd.(*RestrictionSimpleContent).makePkg(0xc42013fb80, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/elemmakepkg.go:605 +0x111
github.com/metaleap/go-xsd.(*hasElemRestrictionSimpleContent).makePkg(0xc42010d770, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/hasmakepkg.go:221 +0x47
github.com/metaleap/go-xsd.(*SimpleContent).makePkg(0xc42010d700, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/elemmakepkg.go:733 +0x73
github.com/metaleap/go-xsd.(*hasElemSimpleContent).makePkg(0xc42017e7d8, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/hasmakepkg.go:251 +0x47
github.com/metaleap/go-xsd.(*ComplexType).makePkg(0xc42017e6c0, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/elemmakepkg.go:179 +0x371
github.com/metaleap/go-xsd.(*hasElemsComplexType).makePkg(0xc420180400, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/hasmakepkg.go:71 +0x55
github.com/metaleap/go-xsd.(*Schema).makePkg(0xc420180280, 0xc4200fcd20)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/elemmakepkg.go:707 +0xd6
github.com/metaleap/go-xsd.(*Schema).MakeGoPkgSrcFile(0xc420180280, 0x28, 0xc42004fe01, 0xc420180280, 0x0)
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/xsd-schema.go:170 +0x377
main.main()
    /home/jchase/Dev/src/github.com/metaleap/go-xsd/xsd-makepkg/main.go:65 +0x21a
jamesboswell commented 7 years ago

@metaleap I'm having the same issue with a Juniper JUNOS XSD file (I have to serve it from a localhost since it's not on a public URI)

$ xsd-makepkg  -uri http://localhost:8090/config-14.2.xsd
2016/11/07 17:56:30 LOAD:   http://localhost:8090/config-14.2.xsd
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x7706a]

goroutine 1 [running]:
panic(0x256160, 0xc4200140a0)
    /usr/local/Cellar/go/1.7.3/libexec/src/runtime/panic.go:500 +0x1a1
github.com/metaleap/go-xsd.(*RestrictionSimpleEnumeration).makePkg(0xc421560120, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:620 +0x8a
github.com/metaleap/go-xsd.(*hasElemsEnumeration).makePkg(0xc4219676c0, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:89 +0x55
github.com/metaleap/go-xsd.(*RestrictionSimpleContent).makePkg(0xc421967600, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:605 +0x111
github.com/metaleap/go-xsd.(*hasElemRestrictionSimpleContent).makePkg(0xc42158d4f0, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:221 +0x47
github.com/metaleap/go-xsd.(*SimpleContent).makePkg(0xc42158d480, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:731 +0x73
github.com/metaleap/go-xsd.(*hasElemSimpleContent).makePkg(0xc4215726b8, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:251 +0x47
github.com/metaleap/go-xsd.(*ComplexType).makePkg(0xc4215725a0, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:179 +0x371
github.com/metaleap/go-xsd.(*hasElemComplexType).makePkg(0xc4214fca20, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:65 +0x47
github.com/metaleap/go-xsd.(*Element).makePkg(0xc4214fc900, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:367 +0x131
github.com/metaleap/go-xsd.(*hasElemsElement).makePkg(0xc4215b75b0, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:83 +0x55
github.com/metaleap/go-xsd.(*Choice).makePkg(0xc4215b7500, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:145 +0xd6
github.com/metaleap/go-xsd.(*hasElemsChoice).makePkg(0xc4215b7298, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:53 +0x55
github.com/metaleap/go-xsd.(*Choice).makePkg(0xc4215b7200, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:142 +0x79
github.com/metaleap/go-xsd.(*hasElemsChoice).makePkg(0xc4215b7198, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:53 +0x55
github.com/metaleap/go-xsd.(*Sequence).makePkg(0xc4215b7100, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:721 +0x79
github.com/metaleap/go-xsd.(*hasElemSequence).makePkg(0xc421572590, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:239 +0x47
github.com/metaleap/go-xsd.(*ComplexType).makePkg(0xc421572480, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:177 +0x327
github.com/metaleap/go-xsd.(*hasElemComplexType).makePkg(0xc4215a1c20, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:65 +0x47
github.com/metaleap/go-xsd.(*Element).makePkg(0xc4215a1b00, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:367 +0x131
github.com/metaleap/go-xsd.(*hasElemsElement).makePkg(0xc4215b70b0, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:83 +0x55
github.com/metaleap/go-xsd.(*Choice).makePkg(0xc4215b7000, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:145 +0xd6
github.com/metaleap/go-xsd.(*hasElemsChoice).makePkg(0xc4215b6e98, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:53 +0x55
github.com/metaleap/go-xsd.(*Sequence).makePkg(0xc4215b6e00, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:721 +0x79
github.com/metaleap/go-xsd.(*hasElemSequence).makePkg(0xc421572350, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:239 +0x47
github.com/metaleap/go-xsd.(*ComplexType).makePkg(0xc421572240, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:177 +0x327
github.com/metaleap/go-xsd.(*hasElemComplexType).makePkg(0xc4215a1620, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:65 +0x47
github.com/metaleap/go-xsd.(*Element).makePkg(0xc4215a1500, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:367 +0x131
github.com/metaleap/go-xsd.(*hasElemsElement).makePkg(0xc4215b6db0, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:83 +0x55
github.com/metaleap/go-xsd.(*Choice).makePkg(0xc4215b6d00, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:145 +0xd6
github.com/metaleap/go-xsd.(*hasElemsChoice).makePkg(0xc4215b6c98, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:53 +0x55
github.com/metaleap/go-xsd.(*Sequence).makePkg(0xc4215b6c00, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:721 +0x79
github.com/metaleap/go-xsd.(*hasElemSequence).makePkg(0xc4215dff70, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:239 +0x47
github.com/metaleap/go-xsd.(*ComplexType).makePkg(0xc4215dfe60, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:177 +0x327
github.com/metaleap/go-xsd.(*hasElemsComplexType).makePkg(0xc4200c2680, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/hasmakepkg.go:71 +0x55
github.com/metaleap/go-xsd.(*Schema).makePkg(0xc4200c2500, 0xc42000eb40)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/elemmakepkg.go:705 +0xd6
github.com/metaleap/go-xsd.(*Schema).MakeGoPkgSrcFile(0xc4200c2500, 0x1e, 0xc42004fe01, 0xc4200c2500, 0x0)
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/xsd-schema.go:170 +0x377
main.main()
    /Users/jboswell/go/src/github.com/metaleap/go-xsd/xsd-makepkg/main.go:65 +0x21a