java - xjc and XSD choice -
when run xjc generate java type representing xsd snippet:
<xs:complextype name="fileuploadrequest"> <xs:choice> <xs:element name="path" type="xs:string"/> <xs:element name="file" type="xs:base64binary"/> </xs:choice> </xs:complextype> i class that's indistinguishable have been if i'd specified sequence optional elements instead.
i want type little bit of intelligence, that'll let me have @ 1 element of choice @ time. if invoke generated setfile method example, should make path null. there plugin can use seems obvious requirement of code generator?
binding.xml
you can use following external binding file generate type of property looking for:
<?xml version="1.0" encoding="utf-8"?> <bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.1"> <globalbindings choicecontentproperty="true"/> </bindings> xjc call
the binding file referenced using -b flag.
xjc -b binding.xml schema.xsd generated property
now following property generated:
@xmlelements({ @xmlelement(name = "path", type = string.class), @xmlelement(name = "file", type = byte[].class) }) protected object pathorfile; for more information
Comments
Post a Comment