XML fragment:
<datasource formatted-name="blah" inline="blah"> <repository-location derived-from="blah" id="blah" path="blah" revision="blah" site="blah"/> </datasource>
I am trying to unmount everything under one class (DataSource) with nested static classes. Here is my DataSource class:
@XmlRootElement(name = "datasource") @XmlAccessorType(XmlAccessType.FIELD) public class DataSource { @XmlAttribute(name = "formatted-name") protected String formattedName; @XmlAttribute(name = "inline") protected String inline; @XmlElement(name = "repository-location") protected RepositoryLocation repositoryLocation; // public getters and setters for fields above @XmlAccessorType(XmlAccessType.FIELD) public static class RepositoryLocation { @XmlAttribute(name = "derived-from") protected String derivedFrom; @XmlAttribute(name = "id") protected String id; @XmlAttribute(name = "path") protected String path; @XmlAttribute(name = "revision") protected String revision; @XmlAttribute(name = "site") protected String site; // public getters and setters for fields above } }
Unmarshaller:
JAXBContext jaxbContext = JAXBContext.newInstance(DataSource.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(responseXML); dataSourceResponse = (DataSource) unmarshaller.unmarshal(reader);
I can successfully display the DataSource fields "formattedName" and "inline", but "repositoryLocation" is null. Can someone help please?
java xml jaxb unmarshalling
toadead
source share