1
是否可能在smooks(版本1.5.1)中只映射一個從兩個選擇元素生成的元素到java字段?Smooks - 如何將選擇元素從xml映射到java
實施例:
XSD文件:
<complexType name="timeType">
<sequence>
<choice minOccurs="1" maxOccurs="1">
<element name="time" minOccurs="0" maxOccurs="1">
<complexType>
<attribute name="v" type="dateTime"/>
</complexType>
</element>
<element name="time2" minOccurs="0" maxOccurs="1">
<complexType>
<attribute name="v" type="dateTime"/>
</complexType>
</element>
</choice>
</complexType>
一個)的xml文件1:
<parent>
<time v="2001-12-31T12:00:00"/>
</parent>
b)中的XML文件2:
<parent>
<time2 v="2002-12-31T12:00:00"/>
</parent>
的Smooks映射
<jb:bean beanId="timeRef" class="someClass" createOnElement="parent">
<!-- only if is generated (present) time element map this time element-->
<jb:value property="fromHour" data="time/@v" decoder="DateTime" />
<!-- only if is generated (present) time2 element map time2 element -->
<jb:value property="fromHour" data="time2/@v" decoder="DateTime" />
</jb:bean>
我該如何告訴smooks,我想只保存一個生成的元素?由於