Hmm. I am so good :-) last night I was working hard to understand the
abstract mapping as I thought it could be a solution.
Hmm. I am so bad :-( I was not able to understand it enought to solve my
problem.
Mocky! Thanks a lot!
Hopefully works. It seems I can try out only on the weekend.
At this moment I do not plan to marshal any time, so duplication it is
not a problem in the near future.
Tamas
Mocky Habeeb wrote:
I forgot to mention that this binding is suitable for input only, you'll
get duplicate data in your XML if you marshal your objects out using
this approach.
Mocky
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mocky
Habeeb
Sent: Thursday, September 22, 2005 2:01 PM
To: [email protected]
Subject: RE: [jibx-users] collections=>SameClass
If you define an abstract mapping for your type "Source" that defines a
choice between either your "spec" structure or your "str" structure,
then you can use that one type as the type to put into your collection.
And that will do what I think you are asking for.
<binding>
<mapping name="source" class="A">
<collection field="sourceList" item-type="Source">
<structure type="Source"/>
</collection>
</mapping>
<mapping class="Source" abstract="true">
<structure choice="true" ordered="false">
<structure name="spec" usage="optional">
<value field="base" style="text"/>
<value name="tag" field="tag" default="spec"
usage="optional"/>
<value name="ev" field="attr" usage="optional"
style="attribute"/>
</structure>
<structure name="str" usage="optional">
<value field="base" style="text"/>
<value name="tag" field="tag" default="str"
usage="optional"/>
<value name="ref" field="attr" usage="optional"
style="attribute"/>
</structure>
</structure>
</mapping>
</binding>
I also put in a new value named "tag" that is optional with a default.
Since this is never actually present in your XML you'll always get the
default which will let you distinguish between the different types.
There may be a better way to accomplish that.
Mocky
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tamas
Hegedus
Sent: Thursday, September 22, 2005 9:56 AM
To: [email protected]
Subject: [jibx-users] collections=>SameClass
Hi,
I can not deal with the following situation:
I have several 'collections' in my xml document with the same data
structure, so I would like to map them to the same ArrayList and class.
It seems that I would like to make a duplicate conversion. (???; see the
binding defintion at the bottom of the email)
==================================
<source> #ArrayList
#collection_1
<spec ev="ev1">sp_1</spec>
<spec>sp_2</spec>
<str>st_1</str>
<str ref="ref2">st_2</str>
<plasm>plasm</plasm>
</source>
==================================
ArrayList SourceList
SourceList[1]
tag = "spec"
base = "sp_1"
attr = "ev1"
SourceList[2]
tag = "spec"
base = "sp_2"
2.attr = ""
SourceList[3]
tag = "str"
base = "st_1"
attr = ""
etc...
================
I can not change the the structure of the xml file.
In the worst case I can loose the 'tag' information.
I appreciate your help,
Tamas
=============================================
<mapping...
<structure name="source" usage="optional">
<collection name="scpec" field="sourceList" ordered="false"
item-type="org.biohegedus.biodb.bindings.Source"/>
<collection name="str" field="sourceList" ordered="false"
item-type="org.biohegedus.biodb.bindings.Source"/>
</structure>
</mapping>
<mapping name="spec"
class="org.biohegedus.biodb.bindings.Source">
<namespace uri="http://biohegedus.org/biodb/bindings"
default="elements"/>
<value field="base" usage="required" style="text"/>
<value name="ev" field="attr" usage="optional"
style="attribute"/>
</mapping>
<mapping name="str"
class="org.biohegedus.biodb.bindings.Source">
<namespace uri="http://biohegedus.org/biodb/bindings"
default="elements"/>
<value field="base" usage="required" style="text"/>
<value name="ref" field="attr" usage="optional"
style="attribute"/>
</mapping>
--
Tamas Hegedus, PhD | phone: (1) 919-966 0329
UNC - Biochem & Biophys | fax: (1) 919-966 5178
5007A Thurston-Bowles Bldg | mailto:[EMAIL PROTECTED]
Chapel Hill, NC, 27599-7248 | http://biohegedus.org
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users