NOTE: This fork fixes maven build for Java 1.11 (by packaging dependencies into
single jar), fixes some type mappings, contains cherry-picked commit from
kazkansouh
branch (keeping tags order) and contains make script to test tool
with downloaded Amazon MWS xsd files.
Given a XSD (XML Schema Definition) file, generating corresponding Golang XML structs. This tool is written in Java.
* Java 1.6 or above.
* XJC (Jaxb Binding Compiler)
See ./Makefile
for example of usage (look into test
recipe).
You may build tool and test it with Amazon MWS xsd files with just make
command.
Script will download and patch xsd files from Amazon.
Patching is needed, because not everything in those files this tool can handle. Probably, with due manual binding configuration it'd be possible to make it work with original files, but I had had no time for it. So, for now I just removed some parts, which caused compilation errors. Still, it can handle big portion of them.
To use it with your own xsd files, you may replace content of ./xsd-samples
folder and execute make test
. Generated Go file goes into ./target/model.go
.
This is how generated Go code may look like:
type XMLVendor struct {
XMLName xml.Name `xml:"vendor"`
Value []string `xml:"value"`
}
type XMLVersion struct {
XMLName xml.Name `xml:"version"`
Id string `xml:"id,attr"`
Value bool `xml:"value,attr"`
}
Since version 1.11 JAXB packages were removed from JRE, so, I had to add them back via additional maven dependencies and classpath arguments.
To make it simpler (for me), I just used maven assemble plugin to make single jar file, containing all dependencies.
I don't know, how to fix unit tests, so, I just skipped them. Original author
of the tool hardcoded his local paths there. It'd be better to use model classes,
generated by the script within ./target
folder. I tried, but was lazy to
resolve classpath issues.
Make file was tested on my laptop with following environment:
$ uname -a
Linux n76vj 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64 GNU/Linux
$ mvn -version
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 11.0.2, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.0-8-amd64", arch: "amd64", family: "unix"
$ make -version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.