i'm "happy" to tell you: this solution is crap.
i ended up with the data of the last element from the XML data
contained in all objects of my list. so there's something wrong.
so if anybody has a solution for the inital request i had, i would
appreciate that very much.
br,
günther
Am 25.07.2007 um 13:28 schrieb Günther Wieser:
hi,
now i found my solution:
<?xml version="1.0" encoding="ISO-8859-2"?>
<binding>
<mapping name="customer" class="data.Customer" flexible="true"
ordered="false" allow-repeats="true">
<value name="id" set-method="setJiXBId" get-method="getJiXBId"
/>
<value name="first" set-method="setJiXBFirstName"
get-method="getJiXBFirstName" />
<value name="last" set-method="setJiXBLastName"
get-method="getJiXBLastName" />
<!-- ################# -->
<!-- replaces the collection -->
<!-- ################# -->
<structure allow-repeats="true"
ordered="false" set-method="addAddress"
get-method="getAddress" />
</mapping>
<mapping name="address" class="data.Address" flexible="true"
ordered="false">
<value name="id" set-method="setJiXBId" get-method="getJiXBId"
/>
<value name="street" set-method="setJiXBStreet"
get-method="getJiXBStreet" usage="required" />
<value name="city" set-method="setJiXBCity"
get-method="getJiXBCity" usage="optional" nillable="false"
/>
</mapping>
</binding>
using this i can add "unexpected" elements whereever i want in my
XML data.
br,
guenther
Am 25.07.2007 um 12:47 schrieb venkateswarlu a:
hi gunther,
Flexibel will ot work for collections if you wnat to use
collection chaild elements you can use abstarct mapping.and you
need not use that flexible attribute for structure element inside
mapping .
If you use flexible attribute for mapping it will take care of all
child elements in side that parent element
Regards,
venkat annangi
On 7/25/07, Günther Wieser <[EMAIL PROTECTED]> wrote:
hi,
i'm a total newbie to jixb so this might be more a question of
understanding than of a problem. i went through the mailing list
archive, found some interresting things but nothing solved my
problems, so i'm ending up here ;-)
think about the following binding:
<?xml version="1.0" encoding="ISO-8859-2"?>
<binding>
<mapping name="customer" class="data.Customer" flexible="true"
ordered="false" allow-repeats="true">
<value name="id" set-method="setJiXBId" get-method="getJiXBId"/>
<value name="first" set-method="setJiXBFirstName" get-
method="getJiXBFirstName"/>
<value name="last" set-method="setJiXBLastName" get-
method="getJiXBLastName"/>
<collection field="addresses" flexible="true" ordered="false">
<structure name="address" type="data.Address" flexible="true"
ordered="false">
<value name="id" set-method="setJiXBId" get-method="getJiXBId"/>
<value name="street" set-method="setJiXBStreet" get-
method="getJiXBStreet" usage="optional"/>
<value name="city" set-method="setJiXBCity" get-
method="getJiXBCity" usage="optional"/>
</structure>
</collection>
</mapping>
</binding>
this does not compile, jixb complains about the following:
[bind] Error: All child components must define element names
for flexible='true'; on collection element at (line 7, col 66, in
C:/JavaDev322/JiXB Test/src/customer_binding.xml)
[bind] Error running binding compiler
[bind] org.jibx.runtime.JiBXException: Binding C:/JavaDev322/
JiXB Test/src/customer_binding.xml is unusable because of
validation errors
problem is: we get XML data that could have more elements than we
expect, but we simply do not need to take care of this. but of
course we must get jixb to ignore these during runtime.
i've tried several other ways to solve this:
i removed the collection element and added getters and setters to
the structure (the setter simply adds an "address" to the list)
and set "allow-repeats" to true.
with this approach i ended up with a very strange situation.
giving the following input, i received a strange result.
input:
<?xml version="1.0" encoding="ISO-8859-2"?>
<customer>
<id>1234</id>
<first>Heinz</first>
<last>Prueller</last>
<asdasd>asasd</asdasd>
<address>
<id>111</id>
<street>Daham 1</street>
<city>1110 Wien</city>
</address>
<address>
<id>222</id>
<street>Daham 2</street>
<city>2220 Wien</city>
<kasperl>asdasd</kasperl>
</address>
<address>
<id>333</id>
<street>Daham 3</street>
<city>3330 Wien</city>
</address>
</customer>
outcome:
Adding [EMAIL PROTECTED] 1]
[city=1110 Wien]]
Adding [EMAIL PROTECTED] 2]
[city=2220 Wien]]
Adding [EMAIL PROTECTED] 3]
[city=3330 Wien]]
Result: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[[id=333][street=Daham 3][city=3330 Wien]]]
[EMAIL PROTECTED] 3][city=3330
Wien]]][address= [EMAIL PROTECTED] 3]
[city=3330 Wien]]]]]
as you can see, the three address object were passed to my
addAddress() method with the correct values, but the final
collection holds three address objects which all hold the same
data!!!! weird!
so my question is:
how can i define a binding that either uses collections or can
deal with collections, but allows "unknown" XML elements to exist
in the data coming in without getting exceptions during runtime?
br,
guenther
--
Günther Wieser
---------------------------------------------------------------------
----
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
---------------------------------------------------------------------
----
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
--
Günther Wieser
openForce Information Technology GesmbH
Plenergasse 1
A-1180 Wien
[EMAIL PROTECTED]
http://www.openforce.com
--
Günther Wieser
creative-it
Guglgasse 6/1/11/1
A-1110 Wien
[EMAIL PROTECTED]
http://www.creative-it.com
----------------------------------------------------------------------
---
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
--
Günther Wieser
creative-it
Guglgasse 6/1/11/1
A-1110 Wien
[EMAIL PROTECTED]
http://www.creative-it.com
-------------------------------------------------------------------------
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