2011-07-04 25 views
1

我有一個模式聲明如下從第三方提供商。自定義綁定強制內部類創建或xs:元素的getters/setters

<xs:complexType name="GroupParameterType"> 
     <xs:sequence minOccurs="0" maxOccurs="4"> 
      <xs:element name="name" type="xs:string"> 
       <xs:annotation> 
        <xs:documentation>The name of the parameter.</xs:documentation> 
       </xs:annotation> 
      </xs:element> 
      <xs:element name="value" type="xs:string"> 
       <xs:annotation> 
        <xs:documentation>The value of the parameter.</xs:documentation> 
       </xs:annotation> 
      </xs:element> 
     </xs:sequence> 
    </xs:complexType> 

以上是我無法更改的模式。我正在嘗試爲jaxb 2.0編寫一個自定義綁定,以便我可以在java代碼中將名稱引用爲GroupParameterType.Name或GroupParameterType.Value。

當前的默認綁定爲我生成列表,即getNameandValueList,但我想單獨獲取名稱和值的getter和setter。

我試圖把在自定義類似下面的結合:

<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[@name='name']"> 
    <jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/> 
</jxb:bindings> 
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[@name='value']"> 
    <jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/> 
</jxb:bindings> 

,並沒有做任何更改默認類生成。任何人都可以給我一些指點,我還有什麼可以嘗試下一步?我正在尋找具有默認的列表代ALONG與名稱和值的getters/setters或具有名稱和值作爲內部類。如果我刪除了maxOccurs = 4選項,我可以生成getters/setters,但由於我無法修改架構,我試圖使用外部綁定文件來獲取該行爲。

感謝 與Shon

回答

0

除非您修改方案不能得到這個行爲。您確實有一個映射到異構元素屬性的架構模型,並且您無法使用自定義對其進行更改。

您可以嘗試code injection plugin作爲最後一次撤退。

相關問題