Java
Approaches are based on the XML Schema:
JAXB and XMLBeans
JAXB - Eclipse Jakarta XML Binding provides an API and tools that automate the mapping between XML documents and Java objects.
Apache XMLBeans is a technology for accessing XML by binding it to Java types.
JAXB Generation - Windows Batch File
1set JAXB_HOME=C:\Programs\jaxb\jaxb-ri-4.0.3\jaxb-ri
2set XSD_HOME=..\..\model_based\xsd_variants
3
4IF EXIST jaxb_42 RMDIR /S /Q jaxb_42
5IF NOT EXIST jaxb_42 MKDIR jaxb_42
6call %JAXB_HOME%\bin\xjc.bat -d jaxb_42 "%XSD_HOME%\ddi-cdi_42_noXsdTypeInName.xsd"
7
8IF EXIST jaxb_43 RMDIR /S /Q jaxb_43
9IF NOT EXIST jaxb_43 MKDIR jaxb_43
10call %JAXB_HOME%\bin\xjc.bat -d jaxb_43 "%XSD_HOME%\ddi-cdi_43_noXsdTypeInName.xsd"
11
12IF EXIST jaxb_44 RMDIR /S /Q jaxb_44
13IF NOT EXIST jaxb_44 MKDIR jaxb_44
14call %JAXB_HOME%\bin\xjc.bat -d jaxb_44 "%XSD_HOME%\ddi-cdi_44_noXsdTypeInName.xsd"
15
16IF EXIST jaxb_45 RMDIR /S /Q jaxb_45
17IF NOT EXIST jaxb_45 MKDIR jaxb_45
18call %JAXB_HOME%\bin\xjc.bat -d jaxb_45 "%XSD_HOME%\ddi-cdi_45_noXsdTypeInName.xsd"
19
20set JAXB_HOME=
21set XSD_HOME=
Generation with XMLBeans - Ant Build File
1<?xml version="1.0" encoding="UTF-8"?>
2<project name="ddi-cdi-xmlbeans" default="create-xmlbeans">
3 <!-- xmlbeans location -->
4 <property name="xmlbeans.lib.dir" location="C:/Programs/xmlbeans-5.2.0/lib"/>
5 <!-- Set the classpath -->
6 <path id="build.classpath">
7 <fileset dir="${xmlbeans.lib.dir}">
8 <include name="*.jar"/>
9 </fileset>
10 </path>
11 <taskdef name="xmlbeans" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpath="${xmlbeans.lib.dir}/xmlbeans-5.2.0.jar" classpathref="build.classpath"/>
12 <!-- ddi-cdi schema -->
13 <property name="xsd_42" location="../../model_based/xsd_variants/ddi-cdi_42_noXsdTypeInName.xsd"/>
14 <property name="xsd_43" location="../../model_based/xsd_variants/ddi-cdi_43_noXsdTypeInName.xsd"/>
15 <property name="xsd_44" location="../../model_based/xsd_variants/ddi-cdi_44_noXsdTypeInName.xsd"/>
16 <property name="xsd_45" location="../../model_based/xsd_variants/ddi-cdi_45_noXsdTypeInName.xsd"/>
17 <target name="create-xmlbeans">
18 <xmlbeans schema="${xsd_42}" download="true" classpath="ddi-cdi-xmlbeans.jar" srconly="true" srcgendir="xmlbeans_42"/>
19 <xmlbeans schema="${xsd_43}" download="true" classpath="ddi-cdi-xmlbeans.jar" srconly="true" srcgendir="xmlbeans_43"/>
20 <xmlbeans schema="${xsd_44}" download="true" classpath="ddi-cdi-xmlbeans.jar" srconly="true" srcgendir="xmlbeans_44"/>
21 <xmlbeans schema="${xsd_45}" download="true" classpath="ddi-cdi-xmlbeans.jar" srconly="true" srcgendir="xmlbeans_45"/>
22 </target>
23</project>
Evaluation
JAXB seems to be the better choice. XMLBeans doesn’t … (to be filled in)