users@jaxb.java.net

Re: ComplexContent Extensions

From: Malachi de AElfweald <malachi_at_EOTI.ORG>
Date: Fri, 28 Mar 2003 15:06:16 -0700

On Fri, 28 Mar 2003 16:08:48 -0500, Joe Fialli <Joseph.Fialli_at_Sun.COM> wrote:
>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
>

Yeah, I figured that part out earlier today. The problem that I was really trying to solve there is to have the element contain data, with an attribute that specifies how the content is encoded: text, base64 encoded, or hex encoded. The idea there was to read the attribute, then pass getValue() to a different routine based off the encoding.

The only way I have been able to do that was to extend xsd:string and put restrictions on the attributes. It does not let me (xsd, not jaxb) put multiple versions with the same element name (and different type) inside a choice... Thinking about it, I guess base64 and hex are both strings, so that is OK, but not as restrictive as I would like. I created 3 seperate types, and put them in a choice -- then I get the restrictions, but I have 3 seperate get/set methods... I guess what I would really like would be a way for them to all share an interface, but since they are all extending a different XSD type, I didn't see any way to do that.

Malachi