go-xml icon indicating copy to clipboard operation
go-xml copied to clipboard

xsdfetch utility

Open droyo opened this issue 8 years ago • 0 comments

Some XML schema, such as http://schema.bolagsverket.se/extern/foretagsinformation/F5_Rakenskapsinformation_2.00.xsd , make heavy use of imports. Add a tool, xsdfetch, that can be used to retrieve all the schema imported by a target schema.

Example usage:

xsdfetch url
xsdfetch filename

Some notes:

  • Oftentimes the schemaLocation field can be relative. In that case, we should treat it as relative to the targetNamespace of the main schema. If that file is not found, we can then consider it relative to the URL of the main file (if we are fetching via URL).
  • Many <import> statements do not contain a schemaLocation. One heuristic to find the schema file, in that case, is to append .xsd to the schema's name space.
  • Some name spaces are not URLs. In that case, if there is no schemaLocation, there's not much we can do.
  • Should handle <import> and <include>.
  • Should fetch dependent schema, and dependencies of their dependencies, and so on.

All schema should be downloaded to the current directory, using path.Base(targetNS) + ".xsd" as the file name, if unique.

droyo avatar Oct 20 '17 01:10 droyo