users@jaxb.java.net

URGENT: List not serializing correctly

From: Malachi de Aelfweald <malachid_at_temporal-wave.com>
Date: Thu, 21 Aug 2003 11:38:19 -0700

I have a client/server project due next week. I started writing the
server side today, to handle the requests from the GUI client. I am
using JAXB for the data format over a basic socket.

 

My XSD contains:

 

            <xsd:element name="taskman" type="taskList"/>

            

            <xsd:complexType name="taskList">

                        <xsd:choice minOccurs="1" maxOccurs="unbounded">

                                    <xsd:annotation>

                                                <xsd:appinfo>

 
<jaxb:property name="tasks"/>

                                                </xsd:appinfo>

                                    </xsd:annotation>

                                    <xsd:element name="new"
type="newTask"/>

                                    <xsd:element name="cancel"
type="cancelTask"/>

                                    <xsd:element name="modify"
type="modifyTask"/>

                                    <xsd:element name="query"
type="queryTask"/>

                                    <xsd:element name="results"
type="resultList"/>

                        </xsd:choice>

            </xsd:complexType>

 

A valid XML snippet, according to the XSD is:

<taskman

   xsi:schemaLocation="http://www.temporal-wave.com/spec/taskman
taskman.xsd"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xmlns="http://www.temporal-wave.com/spec/taskman">

            <new name="TestTask1" priority="1" active="true">

                        <action>

                                    <exec cmd="/usr/local/bin/runTest">

 
<cwd>/home/malachid</cwd>

                                                <env
name="JBCRELEASEDIR" value="/home/malachid/jbase4"/>

                                                <arg>Malachi</arg>

                                                <arg>jBASE 4.1</arg>

                                    </exec>

                        </action>

                        <schedule>

                                    <start>2002-05-30T09:00:00</start>

                                    <repeat>

                                                <end>

 
<by>2002-06-30T09:00:00</by>

                                                </end>

 
<interval>PT15H</interval>

                                    </repeat>

                        </schedule>

            </new>

</taskman>

 

I create a Taskman object, and add a NewTask to it (I tried to add two,
to test whether it was only a problem when I had a single child, no
diff):

                                                ObjectFactory factory =
ObjectFactory();

                                                Taskman request =
factory.createTaskman();

 
((TaskList)request).getTasks().add(task);

 

I then create the JAXBContext and marshall it to the socket.

To verify, I also tried marshalling it to System.out with the same
behavior.

 

Below is what it incorrectly marshals. You will notice that all of the
attributes of the NewTask are on the "Taskman" tag, and all the children
of the NewTask are directly under the "Taskman" tag. This is not even
valid according to the XSD -- <taskman/> contains <new/> not <action/>
and <schedule/>.

 

Any ideas?

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<tm:taskman name="TaskOne" priority="7" active="true"
xsi:schemaLocation="http://www.temporal-wave.com/spec/taskman
taskman.xsd" xmlns:tm="http://www.temporal-wave.com/spec/taskman"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <tm:action>

        <tm:exec cmd="sockTest.exe">

            <tm:cwd>c:\jbase4home</tm:cwd>

            <tm:env value="C:\JBASE4" name="JBCRELEASEDIR"/>

            <tm:env value="C:\jbase4home" name="HOME"/>

            <tm:arg>arg1</tm:arg>

            <tm:arg>arg2</tm:arg>

        </tm:exec>

    </tm:action>

    <tm:schedule>

        <tm:start>2003-08-22T22:44:04.081-08:00</tm:start>

        <tm:repeat>

            <tm:end>

                <tm:by>2003-08-31T10:44:57.596-08:00</tm:by>

            </tm:end>

            <tm:fixed type="WEEKLY" days="MWF"/>

        </tm:repeat>

    </tm:schedule>

    <tm:description>first task</tm:description>

</tm:taskman>