users@jaxb.java.net

Re: mixed content

From: Ed Mooney <Ed.Mooney_at_sun.com>
Date: Thu, 12 Dec 2002 09:47:08 -0500

Hi Magnus,

Artist and Title are members of the Cd content interface. I actually
think it's better than getters and setters.

Unzip the enclosure in a temporary directory. Then, you should be able
to do this (adapt as necessary for your environment):

     xjc.sh -p cd magnus.xsd
     parsing a schema...
     compiling a schema...
     cd\Cd.java
     cd\CdType.java
     cd\ObjectFactory.java
     cd\jaxb.properties
     cd\bgm.ser
     cd\impl\CdImpl.java
     cd\impl\CdTypeImpl.java
     javac Main.java `find cd -name \*.java`
     java Main
     PCData = this is my favourite

     Artist = Red hot chili peppers
     Title = by the way
     PCData =

I cobbled together Main.java in a hurry, but it should give you the idea.

Regards,
--
Ed Mooney         |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201            |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive       |fruit flies like
781-442-0459      |Burlington, MA  01803 |a banana. Groucho
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??.
> 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??
>
> How do I get hold of the character-data in the cd-element, in the
> example "this is my favourite"??
>
> Perhaps I have missunderstood some vital part, but I'm a bit confused...
> Any help would be great!
> Thanks
> Magnus