If it makes sense one could switch from string based ZF2 pull provider to a JAXB based one like for ZF1, as kindly described by Svante
Hi Jochen,
just some notes to forward, if someone asks us on JAXB ever again ;-)
It is messy with the change of JAXB being no longer part of JDK12 and deprecated since JDK 9, many exceptions... :-(
Too much time invested already, I will stick with what I have attached ZIP:
As a quick introduction on JAXB:
The JAXB mapping of datatypes is described at: https://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding
Some performance tips at: https://timjansen.github.io/jarfiller/guide/jaxb/performance.xhtml
JAXB stand-alone downloadable (see JDK below)
The latest downloadable version is currently: https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-ri/2.3.2/jaxb-ri-2.3.2.zip (CII worked, UBL had a problem, but latest sources form Github worked with JDK 12 and Ubuntu 19.04, I assume it is better to test the former releases with something prior JDK 12)
Best you take a look at https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-ri/
or build the latest version by the sources: https://github.com/eclipse-ee4j/jaxb-ri (see below)
I find the tutorial helpful when trying to use it on command line: http://theopentutorials.com/examples/java/jaxb/generate-xml-schema-from-java-class-using-schemagen-tool/
JAXB and the JDK
The bundled JAXB once with the JDK (I guess it started with JDK 6), but to make the JDK modular and lightweighted, they removed it again.
Starting from JDK 9 it is deprecated (but still can be accessed from the JDK bundle) with JDK 12 it is no longer being shipped. Therefore I have tested it with JDK 12
I upgraded my Ubunto to 19.04 (disco) to be able to access JDK 12, see https://www.linuxbabe.com/ubuntu/upgrade-ubuntu-18-04-to-ubuntu-19-04-directly-from-command-line
JAXB Documentation
Latest Docu is in the standalone ZIP bundle or the latest and greated documentation should be part of the GitHub Repro: (same as above) -> https://github.com/eclipse-ee4j/jaxb-ri Old release notes and full documentation can be found at the old Sun/Oracle JavaEE site: https://javaee.github.io/jaxb-v2/doc/user-guide/ch02.html#a-2-4-0
But when you take a look at https://javaee.github.io/jaxb-v2/ and click on the sources right, you see the github is READ-ONLY and all music happens at eclipse now (github link above). [There had been a JBoss Fork but it is 7 years old https://github.com/jboss/jaxb and can be ignored]
JAXB Sources building
I wanted to work on the latest and greated an build the sources from GitHub (same as above) -> https://github.com/eclipse-ee4j/jaxb-ri
For me a test failed under W10 and under Linux I had to adjust the batch files (see PullRequest).
The build itself is easy with 'mvn clean install', but the directory structure is not adjusted to Maven defaults. For instance the final bundle to work on is after the build beyond:
./jaxb-ri/bundles/ri/target/jaxb-ri.zip
EN16931 XML Schema
The UBL 2.1 I took from OASIS, see http://docs.oasis-open.org/ubl/os-UBL-2.1/ <-- DOWNLOAD ZIP for XSD
I unzipped and started directly from build directory like:
svante@devel:~/dev/jaxb-ri_Svante/jaxb-ri/bundles/ri/target/jaxb-ri/bin$ ./xjc.sh -d ./ubl-out/ ~/Downloads/UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd
The CII I took from the EU validation artefact project: https://github.com/CenPC434/validation
svante@devel:~/Downloads/jaxb-ri-2.3.2/jaxb-ri/bin$ ./xjc.sh -d cii-out/ ../../../../dev/validation/cii/schema/D16B\ SCRDM\ \(Subset\)/uncoupled\ clm/CII/uncefact/data/standard/CrossIndustryInvoice_100pD16B.xsd
Removing Data String from Java Files
To compare the generated files from different versions, I removed the date sting via
svante@devel:~/dev/jaxb-ri_Svante/jaxb-ri/bundles/ri/target/jaxb-ri/bin/cii-out$ find . -type f | xargs sed -i '/\/\/ Generated on: 201/d'
see https://unix.stackexchange.com/questions/32907/what-characters-do-i-need-to-escape-when-using-sed-in-a-sh-script
PS: There is another line to be removed, with a varying version number in the end:
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.2
since the jaxb dependencies are troublesome and it's hard to debug error messages in the meantime the idea is the other way and remove jaxb from zf1 instead of adding it to zf2
If it makes sense one could switch from string based ZF2 pull provider to a JAXB based one like for ZF1, as kindly described by Svante