JAXB is unmarshalling the first elements encountered of each type in an XML document fine but leaving the children of any nested elements of the same type null.
Briefly, the problematic structure is as follows:
sequence->media->audio->track->clipitem(->sequence etc etc)
So, a clipitem may also have a nested sequence, and the whole cycle can repeat recursively.
The first sequence encountered always has media set correctly.
However, for a nested sequence the media element is always null (even though it is in XML)
The classes were generated with xjc from an XSD.
Why would unmarshall not like nested elements? Apart from nesting elements it is all working fine. Is there something special to annotate nested elements? The code and annotations are pretty simple.
Any clues would be appreciated. Thanks, John
JAXBContext jc = JAXBContext.newInstance(Xmeml.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Xmeml xmeml = (Xmeml) unmarshaller.unmarshal(inFile);
@XmlRootElement(name = "sequence")
public class Sequence {
@XmlElement(required = true)
protected String name;
@XmlElement(required = true)
protected BigInteger duration;
@XmlElement(required = true)
protected Rate rate;
@XmlElement(required = true)
protected Timecode timecode;
@XmlElement(required = true)
protected BigInteger in;
@XmlElement(required = true)
protected BigInteger out;
@XmlElement(required = true)
protected Media media;
@XmlRootElement(name = "clipitem")
public class Clipitem {
@XmlElement(required = true)
protected String name;
@XmlElement(required = true)
protected BigInteger duration;
@XmlElement(required = true)
protected Rate rate;
protected boolean enabled;
@XmlElement(required = true)
protected BigInteger in;
@XmlElement(required = true)
protected BigInteger out;
@XmlElement(required = true)
protected BigInteger start;
@XmlElement(required = true)
protected BigInteger end;
@XmlElement(required = true)
protected String masterclipid;
protected boolean ismasterclip;
@XmlElement(required = true)
protected Labels labels;
@XmlElement(required = true)
protected Comments comments;
@XmlElement(required = true)
protected Sequence sequence;
The XML is huge but here is a snippet where media inside a sequence is null when it shouldn't be.
<track>
<clipitem id="Nested Sequence">
<name>Nested Sequence</name>
<duration>815</duration>
<rate>
<ntsc>FALSE</ntsc>
<timebase>25</timebase>
</rate>
<in>0</in>
<out>815</out>
<start>815</start>
<end>1630</end>
<sequence id="Nested Sequence1">
<name>Nested Sequence</name>
<duration>815</duration>
<rate>
<ntsc>FALSE</ntsc>
<timebase>25</timebase>
</rate>
<timecode>
<rate>
<ntsc>FALSE</ntsc>
<timebase>25</timebase>
</rate>
<string>01:00:00:00</string>
<frame>90000</frame>
<source>source</source>
<displayformat>NDF</displayformat>
</timecode>
<in>-1</in>
<out>-1</out>
<media>
<video>
<format>
<samplecharacteristics>
<width>1920</width>
<height>1080</height>
<anamorphic>FALSE</anamorphic>
<pixelaspectratio>NTSC-601</pixelaspectratio>
<fielddominance>lower</fielddominance>
<rate>
<ntsc>FALSE</ntsc>
<timebase>25</timebase>
</rate>