users@jaxb.java.net

Re: mixed content

From: Magnus Bergman <magnus.bergman_at_voiceprovider.com>
Date: Thu, 12 Dec 2002 17:30:20 +0100

Thanks!
I understand.
>There should be a getter/setter for the attribute.
Yes there is, I ment the elements, no bug in the beta.
/magnus

Joe Fialli wrote:

> Magnus Bergman wrote:
>
>> Hi, I have some questions about mixed content:
>>
>> I have a schema that looks like this:
>> ...
>> <xsd:complexType name="Cd" mixed="true">
>> <xsd:sequence>
>> <xsd:element name="artist" type="xsd:string"/>
>> <xsd:element name="title" type="xsd:string"/>
>> </xsd:sequence>
>> <xsd:attribute name="model" type="xsd:string"/>
>> </xsd:complexType>
>> ...
>>
>> the corresponding xml-content would look lik this:
>> ...
>> <cd model="double">this is my favourite
>> <artist>Red hot chili peppers</artist>
>> <title>by the way</title>
>> </cd>
>> ...
>>
>> this will result in an interface whith no getters/setters for the
>> attributes artist and title??.
>
> There should be a getter/setter for the attribute.
> If there is not one, this is a bug in the beta. Attributes are
> not part of the content model represented by the
> content list.
>
>> Instead, there is a getContent()-method that returns a java.util.List?
>>
>> Am I supposed to iterate through the list and test what kind of object
>> it is with instanceof
>> and than call the getValue() on that object??
>
> Yes. Since text information can occur before and after element
> information
> in mixed content, the best that JAXB could do by default is represent
> the content as a list of text and element instances. The specification
> states that the text is represented as instances of java.lang.String and
> that element content is represented as instances of
> javax.xml.bind.Element.
>
> The reality is that mixed content is more document-centric than it
> is data centric. Data maps well to JavaBean instances; however,
> marked up text does not since it is well-ordered. JAXB
> can do no better than DOM does in this case. The content
> list represents the content as an ordered list of text
> information (java.lang.String) and element children.
>
> -Joe Fialli, Sun Microsystems
>
>
>>
>> How do I get hold of the character-data in the cd-element, in the
>> example "this is my favourite"?
>
> The java.util.List is an ordered list of elements and tex
>
>
>
>>
>> Perhaps I have missunderstood some vital part, but I'm a bit confused...
>> Any help would be great!
>> Thanks
>> Magnus
>
>
>
> --