I need to implement JAXB for the following XML model
<OrderItemList>
<ItemCount>2</ItemCount>
<OrderItem Sequence="1">
<ItemId>12345</ItemId>
<Quantity>1</Quantity>
<DiscountId>prm</DiscountId>
<DiscountPercent>3.5</DiscountPercent>
</OrderItem>
<OrderItem Sequence="1">
<ItemId>44523</ItemId>
<Quantity>3</Quantity>
<DiscountId>nil</DiscountId>
<DiscountPercent>0</DiscountPercent>
</OrderItem>
</OrderItemList>
I'm getting the following errors:
16:15:28,564 WARN [OrderItemValidate] [error] null : cvc-complex-type.3.2.2: Attribute 'Sequence' is not allowed to appear in element 'OrderItem'.
16:15:28,565 ERROR [OrderItemValidate] org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 24; cvc-complex-type.3.2.2: Attribute 'Sequence' is not allowed to appear in element 'OrderItem'.
org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 24; cvc-complex-type.3.2.2: Attribute 'Sequence' is not allowed to appear in element 'OrderItem'.
22:05:09,966 WARN [OrderItemValidate] [error] null : cvc-complex-type.2.4.a: Invalid content was found starting with element 'TotalCount'. One of '{"www.myapp.com":OrderItem}' is expected.
22:05:09,967 ERROR [OrderItemValidate] org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 17; cvc-complex-type.2.4.a: Invalid content was found starting with element 'TotalCount'. One of '{"www.myapp.com":OrderItem}' is expected.
org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 17; cvc-complex-type.2.4.a: Invalid content was found starting with element 'TotalCount'. One of '{"www.myapp.com":OrderItem}' is expected.
I tried the following ways,
* <complexType name="OrderItem"> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <all> * <attribute name="Sequence" type="{www.myapp.com}Integer" use="required"/> * <element name="ItemId" type="{www.myapp.com}String" minOccurs="0"/> * <element name="Quantity" type="{www.myapp.com}Integer" minOccurs="0"/> * <element name="DiscountId" type="{www.myapp.com}Number" minOccurs="0"/> * <element name="DiscountPercent" type="{www.myapp.com}Number" minOccurs="0"/> * </all> * </restriction> * </complexContent> * </complexType> *
<ItemId>12345</ItemId> <Quantity>1</Quantity> <DiscountId>prm</DiscountId> <DiscountPercent>3.5</DiscountPercent>