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

SimpleContentExtensions not working #20

Closed insect9 closed 7 years ago

insect9 commented 8 years ago

In file elemmakepkg.go, line 284 if ctBaseType = bag.resolveQnameRef(ctBaseType, "T", nil); len(ctBaseType) > 0 { td.addEmbed(nil, bag.safeName(ctBaseType)) } else if ctValueType = bag.resolveQnameRef(ctValueType, "T", nil); len(ctValueType) > 0 { Here, ctBaseType may contain "." when the simpleContent is extended from built-in type. And when you run safeName again here, you get rid of the dot, and cause the generated file has compile error. My easy fix here is don't call safeName here, because the resolveQnameRef more like guaranteed the name is already safe. Maybe fix the implementation of safeName to whitelist "." is a better fix.

You can reproduce the issue by using https://raw.githubusercontent.com/chrisdinn/vast/master/lib/vast3_draft.xsd