users@jaxb.java.net

Re: ComplexContent Extensions

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Fri, 28 Mar 2003 16:08:48 -0500

Malachi de AElfweald wrote:

>On Thu, 27 Mar 2003 10:51:47 -0700, Malachi de AElfweald <malachi_at_EOTI.ORG> wrote:
>
>
>>And what does this actually do (changed 'content' to 'data' due to the other change I made):
>>
>> <jaxb:bindings schemaLocation="dynarray.xsd" node="/xsd:schema">
>> <jaxb:bindings node="./xsd:complexType[@name='data']">
>> <jaxb:property name="base"/>
>> </jaxb:bindings>
>> </jaxb:bindings>
>>
>>
>>I thought it changed all references from 'data' to 'base', but the javadocs don't appear to reflect that kind of change.
>>
>>
>
>Ok, with a little more playing, I think I am starting to understand.
>I moved the bindings inline:
> <xsd:complexType name="data" mixed="true">
> <xsd:annotation>
> <xsd:appinfo>
> <jaxb:property name="data"/>
> </xsd:appinfo>
> </xsd:annotation>
> <xsd:choice>
> <xsd:element name="text" type="xsd:string"/>
> <xsd:element name="hex" type="xsd:hexBinary"/>
> <xsd:element name="base64" type="xsd:base64Binary"/>
> </xsd:choice>
> </xsd:complexType>
>
>and it now has the getData() method... which returns a List... which is because of the choice... Since we only allow it to contain one element, how do I have it return a single element, instead of a List?
>
It returns a list because the complex type definition has a mixed
content model.
Mixed content means that
there is "character" data interspersed with children elements. (Marked
up text like
html) The order of the elements and text is significant, thus, the only
way to represent
this sequencing is a list of the choice of javax.xml.bind.Element and
java.lang.String (for text).

If you remove mixed="true" from above, the schema-derived interface
would have one property per element within the choice.

See Section 5.9.4 "Bind mixed content" in the JAXB 1.0 specification
for detailed explanation and an example.

-Joe

>I think that is the reason removing the jaxb:property line causes the Content errors -- it is trying to remove two different lists, which automatically get the getContent() name... I think I could get rid of the property name if I managed to not return a list.
>
>Malachi
>
>