I am actually using a schema first approach, however I hit a roadblock with the "ominous" JAXB Map problem! and worked around it by switching to a code first approach for this one. Now I'd like to reuse this type in other modules and continue my schema first approach by creating an episode file from the generated schema. Unfortunately the generated episode file is empty. Here is what I tried:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<generateEpisode>true</generateEpisode>
<transformSchemas>
<transformSchema>
<uri>http://some/schema/types</uri>
<toPrefix>core</toPrefix>
<toFile>core-types.xsd</toFile>
</transformSchema>
</transformSchemas>
</configuration>
</plugin>
This generated me the following schema:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:core="http://some/schema/types" targetNamespace="http://some/schema/types" version="1.0">
<xs:element name="Map" type="core:MapType"/>
<xs:complexType name="MapType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="entries" nillable="true" type="core:EntryType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EntryType">
<xs:sequence>
<xs:element name="key" type="xs:anyType"/>
<xs:element name="value" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
And an episode file with this content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:bindings version="2.1" xmlns:ns1="http://java.sun.com/xml/ns/jaxb"/>
I tried to use schemagen standalone (version 2.2.11) with similar results. The documentation at https://jaxb.java.net/2.2.4/docs/schemagen.html and http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/schemagen-mojo.html seams to indicate this should be it, but I can't figure out what I am doing wrong.