android-jaxb icon indicating copy to clipboard operation
android-jaxb copied to clipboard

Wrong annotation generation

Open dimiii opened this issue 8 years ago • 0 comments

Hi. Seems like generator produces code with incorrect requirement on the presence of element. For schema

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:xlink="http://www.w3.org/1999/xlink" 
           elementFormDefault="qualified" 
           attributeFormDefault="unqualified">

    <xs:group name="refgroup">
        <xs:sequence>
            <xs:element name="whatever" type="xs:string"/>
        </xs:sequence>
    </xs:group>

    <xs:element name="error">
        <xs:complexType>
            <xs:sequence>
                <xs:group ref="refgroup" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

next class is produced:

@Root(name = "error")
@Namespace(reference = "")
public class Error {

    @Element(name = "whatever", required = true)
    private String whatever;
  ....
}

I expect that due to constraint minOccurs="0" element whatever should get an annotation @Element(name = "whatever", required =false).

dimiii avatar Mar 24 '16 16:03 dimiii