2
您好我有定義爲這樣一個模式:JAXB的EclipseLink問題與的nillable元素編組CHOICE
<complexType name="x">
<sequence>
<element name="year" type="date"/>
<choice>
<element name="comuneNascita" type="string" nillable="true"/>
<element name="statoNascita" type="string" nillable="true"/>
</choice>
</sequence>
</complexType>
當我嘗試馬歇爾與XJC(與XJC:簡單的選項)生成的類,我得到這樣的結果:
[...]
<statoNascita xsi:nil="true"/>
<comuneNascita>xxx</comuneNascita>
[...]
這是錯的!
刪除nillable =「true」解決了這個問題,但後來我必須指定一個有效的元素(未被刪除)。 任何解決方法?
只有當您不使用選項 來避免某些屬性的JaxElement類型生成時,纔會出現這種情況。在這種情況下,選項choiceContentProperty =「true」將被忽略。 爲了避免這個問題,我不得不改變的模式,因爲這: <選擇的minOccurs = 「0」> \t <元素名稱= 「comuneNascita」 類型= 「字符串」/> \t <元素名稱= 「statoNascita」 類型= 「string」/> 所以元素null時不用xsi:nil編組。但有時候改變架構不是一種選擇。 –
Massimo
2011-05-12 07:17:49