XMLスニペットをNULLに。JAXB非整列化ネストされた要素は
@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::私がnullに成功し、出力データソースフィールド "formattedName" と "インライン"、しかし "repositoryLocation" であることができ
JAXBContext jaxbContext = JAXBContext.newInstance(DataSource.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(responseXML);
dataSourceResponse = (DataSource) unmarshaller.unmarshal(reader);
ここに私のDataSourceクラスです。誰か助けてもらえますか?
それが動作するはずですが。 'repositoryLocation'のgetter/setterがありますか? – ulab
はい、私はそれらを持っています。 – toadead
どのようにアンマーシャリングしますか? plsコードを追加します。 – ulab