Hi,
I'm having a problem using lists of derived types under Xmlbeans 2.4.0.
Basically, I'm trying to define a list of base type and populate that list
with instances of derived types. For example, given a schema that
contains complex types of Parent, Child1, and Child2, where Parent is
abstract and extended by Child1 and Child2, I define a list of child
elements using the Parent type as follows:
<xs:complexType name="Children">
<xs:sequence>
<xs:element name="item" type="Parent"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
I then create a Child1 instance, set its required content, validate it,
and add it to an Xmlbeans-generated ListChildren instance without error.
The ListChildren instance, however, fails validation because the required
Child1 attributes and subelements are not found, even though I set them
and the Child1 instance's validate method returned true. Moreover, when I
save the whole document, the output looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<cfn:DOC xmlns:cfn="http://cfnxml" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<items>
<item xsi:type="cfn:Child1"/>
</items>
</cfn:DOC>
I don't know why content from the Child1 instance is missing from the
output. To recap, my two questions are (1) Why does validation fail in
the Children list even though the Child1 instance validation independently
succeeds, and (2) Why does save() not output all assigned Child1 content
as part of item element?
Any help is appreciated,
Rich