So for this very simple union:
<simpleType name="volumeControl">
<union>
<simpleType>
<restriction base="int">
<minInclusive value="0"/>
<maxInclusive value="10"/>
</restriction>
</simpleType>
<simpleType>
<restriction base="token">
<enumeration value="quiet"/>
<enumeration value="loud"/>
<enumeration value="really loud"/>
</restriction>
</simpleType>
</union>
</simpleType>you'd need a structure like:
public class VolumeControlType
{
private int m_type; // 0 for int, 1 for token
private int m_intValue;
private String m_tokenValue;
public static VolumeControlType deserialize(String value) {
if (value.size() == 0 || !Character.isDigit(value.charAt(0))) {
m_type = 1;
m_tokenValue = value; // except really should check the actual values
} else {
m_type = 0;
m_intValue = ...deserializerInt(value);
}
}
// plus getter/setters, etc.
}
Generating this would be a mess, especially if you try to do it with the existing Xsd2Jibx code. My current plans with Xsd2Jibx are to release the current CVS version as beta 1 along with JiBX RC0 next week, then ignore it. It'd be great if someone could come up with a better alternative; I've discussed some options with Cameron, the original author of the current code, and have also suggested on this list the possibility of taking Castor's code generation and modifying it to leave out the Castor-specific stuff while also generating JiBX bindings.
- Dennis
Dave Lucek wrote:
Hi,
Does anyone know where in the Xsd2Jibx source code where I should look in order to add support for
XML unions? Or, how can I get this tool to work with XML unions?
Thanks
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
