KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This question has been asked in various guises - but I feel there is still room to catalogue this further. I have an xsd with two element definitions <xs:complexType name="elementA"> <xs:sequence> <xs:element name="date" type="xs:string" minOccurs="0"/> <xs:element name="lastXdigits" type="xs:string" nillable="true" minOccurs="0"/> </xs:sequence> </xs:complexType> This generates: protected String date; @XmlElementRef(name = "lastXdigits", namespace = "http://xxxxxxx", type = JAXBElement.class) protected JAXBElement<String> lastXDigits; Changing the xsd to: <xs:element name="lastXdigits" type="xs:string" nillable="true" minOccurs="1"/> results in: protected String date; @XmlElement(name = "lastXdigits", required = true, nillable = true) protected String lastXDigits; and using: <xs:element name="lastXdigits" type="xs:string" minOccurs="0"/> results in: protected String date; @XmlElement(name = "lastXdigits") protected String lastXDigits; This seems extremely odd to me. Why is lastXDigits generated as a JAXBElement type in the first case and why does a String type not suffice in all cases? Also, why should jaxb treat these two elements differently when their definition apart from name are identical? I'm using a jaxb-xjc ant task from jaxb 2.0.5. Does this look suspicious or is there good justification for these differences?
Tags (comma-separated)
Save Edits
Cancel