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

Fix for issue #9 #11

Closed lobatt closed 9 years ago

lobatt commented 9 years ago

the problem is that the protocol header is not included in the loadedschemas but in the tmpUrl. stripping the header then it works fine.

Also included some clean up for previous commit, but the fix focused on the following part:

-       if sd = loadedSchemas[tmpUrl]; sd == nil {
+       var ok bool
+       var toLoadUri string
+       if pos := strings.Index(tmpUrl, protSep); pos >= 0 {
+           toLoadUri = tmpUrl[pos+len(protSep):]
+       } else {
+           toLoadUri = tmpUrl
+       }
+       if sd, ok = loadedSchemas[toLoadUri]; !ok {