ルート要素SearchResourceResponseを持つ応答xmlがあります。これを別のカスタム(HSIDetails)オブジェクトにアンマーシャリングする必要があります。JAXB(JSR-222)実装としてMOXyを使用し始めました。私の以下の意図は正しいですか?これはMOXyで可能ですか?
JAXBContext jc = JAXBContext.newInstance(HSIDetails.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
HSIDetails hsiDetails = (HSIDetails) unmarshaller.unmarshal(new StreamSource(new StringReader(responseXml)));
と私のHSIDetailsクラス
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class HSIDetails implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4352912510533245455L;
@XmlPath("SearchResponseDetails/LogicalDevice/LogicalPhysicalResource/PhysicalResource[@*[local-name()='type' and contains(.,'icl:Slot')]]/commonName")
private String slot;
@XmlPath("SearchResponseDetails/LogicalDevice/LogicalPhysicalResource/PhysicalResource[@*[local-name()='type' and contains(.,'icl:PhysicalPort')]]/commonName")
private String port;
@XmlPath("SearchResponseDetails/SubNetwork/Pipe/commonName")
private String telephone;
@XmlPath("//SearchResponseDetails/SubNetwork/Pipe/lrStatus")
private String lrStatus;
public String getSlot() {
return slot;
}
public void setSlot(String slot) {
this.slot = slot;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getLrStatus() {
return lrStatus;
}
public void setLrStatus(String lrStatus) {
this.lrStatus = lrStatus;
}
}
私のxmlの一部は次のとおりです。
<tns:SearchResourceResponse xmlns:tns="http://www.ICLNBI.com/ICLNBI.xsd">
<SearchResponseDetails>
<SubNetwork>
<Pipe xsi:type="icl:Trail" xmlns:icl="http://www.ICLNBI.com/ICLNBI.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CommonName>XXXXX</CommonName>
<objectID>1234567890</objectID>
<description>512/2</description>
<SourceSystem>YYYY</SourceSystem>
</Pipe>
</SubNetwork>
</SearchResponseDetails>
</tns:SearchResourceResponse>