The error you are reporting indicates that, somehow, ant has been instructed to read the same XML Schema definitions twice. Indeed, the error message says that one definition is in
C:\Temp\jaxb\apps\create-marshal\POCD_MT000040_SDTC.xsd
and the other one was found in
...\create-marshal\infrastructure\cda\POCD_MT000040_SDTC.xsd
You should clean up the file tree below create-marshal. You need one of these two, and, relatived to this file, the ones included by it, e.g.:
..\coreschemas\datatypes.xsd
..\coreschemas\voc.xsd
..\coreschemas\NarrativeBlock.xsd
Finally, datatypes-base.xsd
must be in the same folder as these three, as it is included by datatypes.xsd
.
But when you have tidied this up, you'll run into another problem, at least with the JAXB that comes with JDK 1.8. This is a bug in xjc, triggered by the (unintentional) duplication of a field "id" in a number of complex types, e.g., here:
<xs:complexType name="POCD_MT000040.ObservationMedia">
...
<xs:element name="id" type="II" minOccurs="0" maxOccurs="unbounded"/>
...
<xs:attribute name="ID" type="xs:ID"/>
The mapping of XML Schema names to Java names is defined in the JAXB spec, and, no matter how a clash is produced, this should result in an error message (not a stack dump, as it happens).
You have to handle this problem (bug or no bug) using customization with a JAXB binding file. Here's one (let'S call it rename.xjb
), renaming the field matching @ID in POCD_MT000040.ObservationMedia to `xsid
FIXES ALL NAME CLASHES id vs. ID
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.1">
<bindings schemaLocation="./POCD_MT000040.xsd" node="/xs:schema">
<bindings node="//xs:complexType[@name='POCD_MT000040.ObservationMedia']/xs:attribute[@name='ID']">
<property name="xsid"/>
</bindings>
</bindings>
<bindings schemaLocation="./POCD_MT000040.xsd" node="/xs:schema">
<bindings node="//xs:complexType[@name='POCD_MT000040.RegionOfInterest']/xs:attribute[@name='ID']">
<property name="xsid"/>
</bindings>
</bindings>
<bindings schemaLocation="./POCD_MT000040.xsd" node="/xs:schema">
<bindings node="//xs:complexType[@name='POCD_MT000040.Section']/xs:attribute[@name='ID']">
<property name="xsid"/>
</bindings>
</bindings>
</bindings>
You have to add the bindings file to the xjc invocation. In ant, this would be the @binding
of <xjc>
:
<xjc schema="POCD_MT000040_SDTC.xsd" binding="rename.xjb" ...
Best Answer
According to this documentation for the ant xjc task -
In gradle it would look like this:
I think this would also work: