2017-01-09 106 views
0

我有一个XML文档,其结构如下。 ReportRaw表示ReportConverted的十六进制值。当我将JAXB绑定应用于此时,我将得到一个表示ReportId的自定义复杂对象,其中包含ReportRaw和ReportConverted的两个子对象。自定义JAXB绑定

<Report> 
    <ReportId> 
     <ReportRaw>FA3</ReportRaw> 
     <ReportConverted>4003</ReportConverted> 
    </ReportId> 
</Report> 

我的应用程序不使用ReportedRaw值,所以我想简化我生成的对象模型,并生成ReportId作为报告对象的整数。我怎么能用jaxb自定义绑定来做这件事?

感谢

回答

0

如果你不想要的元素ReportRaw元帅期间或解组,那么你可以用@XmlTransient注释。

要使用jaxb绑定来执行此操作,您需要使用jaxb2-annotate-plugin。以下是用法。

<jaxb:bindings node=".//xs:element[@name='ReportRaw']" >    
     <annox:annotate target="field">@javax.xml.bind.annotation.XmlTransient</annox:annotate> 
    </jaxb:bindings>