goxsd icon indicating copy to clipboard operation
goxsd copied to clipboard

Imported XSD files are not supported

Open sotex opened this issue 6 years ago • 0 comments

If the imported XSD file is not a local file, the No such file or directory will be misreported. I simply modified the parseXSDFile function to satisfy my use. (Not a good modification)

func parseXSDFile(fname string) ([]xsdSchema, error) {
        if fname[0:4] == "http" {
                url := strings.Replace(fname,"http:/","http://",-1)
                url = strings.Replace(url,"https:/","https://",-1)
                res,err := http.Get(url)
                if err != nil {
                        return nil,err
                }
                f,err := os.Create(filepath.Base(fname))
                if err != nil {
                        return nil,err
                }
                defer f.Close()
                io.Copy(f,res.Body)
                fname = filepath.Base(fname)
        }
        f, err := os.Open(fname)
        if err != nil {
                return nil, err
        }
        defer f.Close()

        return parse(f, fname)
}

sotex avatar May 27 '19 08:05 sotex