Step 2 of 8

Part 1: Data Model (swim-fixm-ffice-model)

1.1 Download the XSD schemas

Download the FIXM 4.3 + FF-ICE 1.1 schemas from fixm.aero. The distribution contains three top-level directories:

schemas/
  core/         FIXM 4.3 core (base types, flight types)
  applications/ FF-ICE Application 1.1 (message types, templates)
  extensions/   Bug fix extensions

1.2 Generate the model project

Choose a working directory for your new project and run:

mvn archetype:generate \
  -DarchetypeGroupId=com.github.swim-developer \
  -DarchetypeArtifactId=swim-model-archetype \
  -DarchetypeVersion=1.0.0-SNAPSHOT \
  -DgroupId=com.github.swim-developer \
  -DartifactId=swim-fixm-ffice-model \
  -Dversion=1.0.0-SNAPSHOT \
  -Dpackage=aero.fixm.ffice \
  -DmodelName=ffice \
  -DmodelDisplayName="FF-ICE" \
  -DmodelPrefix=Ffice \
  -DrootSchema=FficeMessage.xsd \
  -DdataStandard=FIXM \
  -DinteractiveMode=false

Enter the generated project:

cd swim-fixm-ffice-model
chmod +x mvnw                            # Linux / macOS only

On Windows, use mvnw.cmd instead of ./mvnw in all subsequent commands. The chmod step is not needed.

1.3 Copy the XSD schemas

Copy the three directories from the FIXM distribution into src/main/resources/schemas/. Use your file manager or the appropriate command for your OS:

# Linux / macOS
cp -r /path/to/fixm-distribution/schemas/core       src/main/resources/schemas/
cp -r /path/to/fixm-distribution/schemas/applications src/main/resources/schemas/
cp -r /path/to/fixm-distribution/schemas/extensions  src/main/resources/schemas/
# Windows (PowerShell)
Copy-Item -Recurse C:\path\to\fixm-distribution\schemas\core       src\main\resources\schemas\
Copy-Item -Recurse C:\path\to\fixm-distribution\schemas\applications src\main\resources\schemas\
Copy-Item -Recurse C:\path\to\fixm-distribution\schemas\extensions  src\main\resources\schemas\

The final structure should be:

src/main/resources/schemas/
  core/
    base/          Base.xsd, Types.xsd, AeronauticalReference.xsd, ...
    flight/        Flight.xsd, Arrival.xsd, Departure.xsd, ...
  applications/
    fficemessage/  FficeMessage.xsd
      fficetemplates/
        filedflightplan/
        flightdeparture/
        ...
  extensions/
    fficemessagebugfix/  FficeMessageBugFix.xsd

1.4 Configure the JAXB binding file

Edit src/main/resources/bindings/ffice.xjb to map each XSD namespace to a Java package:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
               xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
               jaxb:extensionBindingPrefixes="xjc"
               version="3.0">

    <jaxb:globalBindings>
        <xjc:serializable uid="1"/>
    </jaxb:globalBindings>

    <jaxb:bindings schemaLocation="../schemas/applications/fficemessage/FficeMessage.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="aero.fixm.ffice"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="../schemas/core/base/Base.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="aero.fixm.base"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="../schemas/core/flight/Flight.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="aero.fixm.flight"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="../schemas/extensions/fficemessagebugfix/FficeMessageBugFix.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="aero.fixm.ffice.bugfix"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>

</jaxb:bindings>

1.5 Configure the JAXB Maven plugin

In pom.xml, update the schemaIncludes inside the generate-xjc profile to point to your root schemas:

<schemaIncludes>
    <include>applications/fficemessage/FficeMessage.xsd</include>
    <include>extensions/fficemessagebugfix/FficeMessageBugFix.xsd</include>
</schemaIncludes>

Update the clean-generated-sources execution to list the generated packages:

<target>
    <delete dir="${project.basedir}/src/main/java/aero/fixm/base" failonerror="false"/>
    <delete dir="${project.basedir}/src/main/java/aero/fixm/flight" failonerror="false"/>
    <delete dir="${project.basedir}/src/main/java/aero/fixm/ffice/bugfix" failonerror="false"/>
    <delete failonerror="false">
        <fileset dir="${project.basedir}/src/main/java/aero/fixm/ffice" includes="*.java"/>
    </delete>
</target>

1.6 Generate JAXB classes

./mvnw process-sources -Pgenerate-xjc        # Linux / macOS
mvnw.cmd process-sources -Pgenerate-xjc      # Windows

This generates Java classes from the XSD schemas and copies them into src/main/java/. The hand-written FficeUnmarshallerPool and FficeXsdValidator in the validation package are preserved.

1.7 Update the UnmarshallerPool

Edit src/main/java/aero/fixm/ffice/validation/FficeUnmarshallerPool.java and register all generated ObjectFactory classes in the JAXBContext:

this.jaxbContext = JAXBContext.newInstance(
    aero.fixm.ffice.ObjectFactory.class,
    aero.fixm.base.ObjectFactory.class,
    aero.fixm.flight.ObjectFactory.class,
    aero.fixm.ffice.bugfix.ObjectFactory.class);

Set the ROOT_XSD constant to match the path of your root schema on the classpath:

private static final String ROOT_XSD = "schemas/applications/fficemessage/FficeMessage.xsd";

1.8 Build and install

./mvnw clean install -DskipTests        # Linux / macOS
mvnw.cmd clean install -DskipTests      # Windows