ok, i tried some things out using the following code and binding:

<?xml version="1.0" encoding="ISO-8859-2"?>
<binding>
        <mapping name="customer" class="simpledata.Customer"
                ordered="false" flexible="true" allow-repeats="true" >
                <value name="id" field="id" />
                <value name="first" field="firstName" />
                <value name="last" field="lastName" />
<structure name="address" ordered="false" type="simpledata.Address" set-method="addAddress"
                        get-method="getAddress" 
factory="simpledata.Address.newInstance"/>
        </mapping>
        <mapping class="simpledata.Address" abstract="true" flexible="true"
                ordered="false">
                <value name="id" field="id"/>
                <value name="street" field="street" usage="required" 
nillable="true"/>
                <value name="city" field="city" usage="required" nillable="true" 
/>
                
        </mapping>
</binding>

code:
public class Address {
        
        
        private static Address newInstance() {
                Address address = new Address();
                System.out.println("Created: " + address);
                return address;
        }

        // #################################################################
// I even use cloning when one address is added to the list of addresses in Customer!!
        // #################################################################
        public Address clone() {
                Address clone = new Address();
                clone.id = new Long(this.id.longValue());
                clone.street = this.street;
                clone.city = this.city;
                return clone;
        }
        
}

XML data:
<?xml version="1.0" encoding="ISO-8859-2"?>
<customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
        <id>1234</id>
        <first>Heinz</first>
        <last>Prueller</last>
        <!-- unused element
        <asdasd>asasd</asdasd>-->
        <address>
                <id>111</id>
                <street>Daham 1</street>
                <city xsi:nil="true" />
                <!-- unused element
                <kasperl>sdasdasd</kasperl>-->
        </address>
 <address>
                <id>222</id>
                <street>Daham 2</street>
                <city>2220 Wien</city>

        </address>
</customer>


this is the result i get when running the example:
1: Created: [EMAIL PROTECTED]
2: -----------------
3: address was: [EMAIL PROTECTED] 1] [city=null]] 4: clone is : [EMAIL PROTECTED] 1] [city=null]]
5: -----------------
6: address was: [EMAIL PROTECTED] 2] [city=2220 Wien]] 7: clone is : [EMAIL PROTECTED] 2] [city=2220 Wien]] 8: Result: [EMAIL PROTECTED] [lastName=Prueller][addresses.size=2 [EMAIL PROTECTED] 2] [city=2220 [EMAIL PROTECTED] [street=Daham 2][city=2220 Wien]]]]]

in 1) the instance of Address is created. Why only once? I thought this will happen with each "address" element?
in 3) you can see what my code receives from JiXB
in 4) you could see the clone I made out of the Address I received from JiXB (note the different Java IDs after the @ sign) in 6) you can see that the next Address object I receive from JiXB is the same object that I cloned, but with different/new values!!! How come?

just to mention: when my XML data would contain even more address elements, all items of Address objects would have the values from the last address element.

I'm honestly totally confused. Hope someone can help....

yours desperately,
günther

--
Günther Wieser
creative-it

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to