Częściowe unmarshalling z JAXB

Chcę zrobić częściowe unmarshaling dużego XML.

XML ma następującą strukturę:

<Records>
    <Contract>
        ...
    </Contract>
    <Contract>
        ...
    </Contract>
    ...
    <Contract>
        ...
    </Contract>
    <Contract>
        ...
    </Contract>
</Records>

Klasa wynikowa wygenerowana za pomocą XJC:

- Records
    |- Contract

Jeśli podążamte(przykład z jaxb-ri), otrzymuję błąd:

Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"http://somedomain.com", local:"Contract"). Expected elements are <{http://somedomain.com}Records>

Jeśli używam:

<jaxb:globalBindings localScoping="toplevel"/>

Dostaję błąd:

org.xml.sax.SAXParseException: A class/interface with the same name "com.my.package.Text" is already in use. Use a class customization to resolve this conflict.

Ale potrzebuję zmienić wiele klas. I to nie jest rozwiązanie.

questionAnswers(2)

yourAnswerToTheQuestion