Discussion:
[castor-dev] Castor-JAXB Interoperability
M***@innovations.de
2010-04-27 15:31:35 UTC
Permalink
Hello everyone,



I would like to extend / modify Castor to be enable it to unmarhal XML
that has been created by a JAXB reference implementation

but don't know where to start. I would be grateful if anyone could
provide an idea. Thanks in advance.



Motivation:

I'm currently facing a problem in unmarshalling XML that has been
created by a JAXB implementation with Castor.

I'm wondering if it is possible to do that without specifying any
Castor-Mapping information.

Basically with simple properties it works
(org.exolab.castor.xml.naming=mixed) but the problems arise when
collection types

are involved as the way collections are marshalled/unmarshalled in JAXB
and Castor are slightly different.



Demonstration:



JavaSrc:

...

private Map<Integer, Drink> drinkList;

...



public class Drink {

private String drinkName;

private Float price;

private int alcoholByVolume;

}



JAXB marshalling of JavaSrc:

...

<drinkList>

<entry>

<key>1</key>

<value>

<alcoholByVolume>0</alcoholByVolume>

<drinkName>Soda</drinkName>

<price>0.99</price>

</value>

</entry>

<entry>

<entry>

<key>2</key>

<value>

<alcoholByVolume>0</alcoholByVolume>

<drinkName>Tonic</drinkName>

<price>1.99</price>

</value>

</entry>

<entry>

</drinkList>

...



Castor produces something like this when marshalling in reflection-mode:

...

<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">

<key xsi:type="java:java.lang.Integer">1</key>

<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">

<drinkName>Soda</drinkName>

<price>0.99</price>

</value>

</drinkList>

<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">

<key xsi:type="java:java.lang.Integer">2</key>

<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">

<drinkName>Tonic</drinkName>

<price>1.99</price>

</value>

</drinkList>

...



Greetings,



Martin
Ralf Joachim
2010-04-28 21:31:16 UTC
Permalink
Hi Martin,

we appreciate any effort to make Castor more compatible with JAXB.

I suggest you to create a new jira issue for the problem at hand a
attach a minimal test case to replay the problem. I think Werner, who is
the one familiar with that part of Castor, will take it from there.

Regards
Ralf
Post by M***@innovations.de
Hello everyone,
I would like to extend / modify Castor to be enable it to unmarhal XML
that has been created by a JAXB reference implementation
but don’t know where to start. I would be grateful if anyone could
provide an idea. Thanks in advance.
I'm currently facing a problem in unmarshalling XML that has been
created by a JAXB implementation with Castor.
I'm wondering if it is possible to do that without specifying any
Castor-Mapping information.
Basically with simple properties it works
(org.exolab.castor.xml.naming=mixed) but the problems arise when
collection types
are involved as the way collections are marshalled/unmarshalled in
JAXB and Castor are slightly different.
...
private Map<Integer, Drink> drinkList;
...
public class Drink {
private String drinkName;
private Float price;
private int alcoholByVolume;
}
...
<drinkList>
<entry>
<key>1</key>
<value>
<alcoholByVolume>0</alcoholByVolume>
<drinkName>Soda</drinkName>
<price>0.99</price>
</value>
</entry>
<entry>
<entry>
<key>2</key>
<value>
<alcoholByVolume>0</alcoholByVolume>
<drinkName>Tonic</drinkName>
<price>1.99</price>
</value>
</entry>
<entry>
</drinkList>
...
...
<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">
<key xsi:type="java:java.lang.Integer">1</key>
<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">
<drinkName>Soda</drinkName>
<price>0.99</price>
</value>
</drinkList>
<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">
<key xsi:type="java:java.lang.Integer">2</key>
<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">
<drinkName>Tonic</drinkName>
<price>1.99</price>
</value>
</drinkList>
...
Greetings,
Martin
--
Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
72127 Kusterdingen
Germany

Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98

Internet: www.syscon.eu
E-Mail: ***@syscon.eu

Sitz der Gesellschaft: D-72127 Kusterdingen
Registereintrag: Amtsgericht Stuttgart, HRB 382295
Geschäftsleitung: Jens Joachim, Ralf Joachim




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
M***@innovations.de
2010-04-29 16:15:59 UTC
Permalink
Thanks for your early reply Ralf. I've created a new jira issue as you suggested and attached a test case.
For everyone who's interested in the topic of Castor-JAXB Interoperability:

http://jira.codehaus.org/browse/CASTOR-2904


Regards

Martin

-----Ursprüngliche Nachricht-----
Von: Ralf Joachim [mailto:***@syscon.eu]
Gesendet: Mittwoch, 28. April 2010 23:31
An: ***@castor.codehaus.org
Betreff: Re: [castor-dev] Castor-JAXB Interoperability

Hi Martin,

we appreciate any effort to make Castor more compatible with JAXB.

I suggest you to create a new jira issue for the problem at hand a
attach a minimal test case to replay the problem. I think Werner, who is
the one familiar with that part of Castor, will take it from there.

Regards
Ralf
Post by M***@innovations.de
Hello everyone,
I would like to extend / modify Castor to be enable it to unmarhal XML
that has been created by a JAXB reference implementation
but don’t know where to start. I would be grateful if anyone could
provide an idea. Thanks in advance.
I'm currently facing a problem in unmarshalling XML that has been
created by a JAXB implementation with Castor.
I'm wondering if it is possible to do that without specifying any
Castor-Mapping information.
Basically with simple properties it works
(org.exolab.castor.xml.naming=mixed) but the problems arise when
collection types
are involved as the way collections are marshalled/unmarshalled in
JAXB and Castor are slightly different.
...
private Map<Integer, Drink> drinkList;
...
public class Drink {
private String drinkName;
private Float price;
private int alcoholByVolume;
}
...
<drinkList>
<entry>
<key>1</key>
<value>
<alcoholByVolume>0</alcoholByVolume>
<drinkName>Soda</drinkName>
<price>0.99</price>
</value>
</entry>
<entry>
<entry>
<key>2</key>
<value>
<alcoholByVolume>0</alcoholByVolume>
<drinkName>Tonic</drinkName>
<price>1.99</price>
</value>
</entry>
<entry>
</drinkList>
...
...
<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">
<key xsi:type="java:java.lang.Integer">1</key>
<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">
<drinkName>Soda</drinkName>
<price>0.99</price>
</value>
</drinkList>
<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">
<key xsi:type="java:java.lang.Integer">2</key>
<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">
<drinkName>Tonic</drinkName>
<price>1.99</price>
</value>
</drinkList>
...
Greetings,
Martin
--

Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
72127 Kusterdingen
Germany

Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98

Internet: www.syscon.eu
E-Mail: ***@syscon.eu

Sitz der Gesellschaft: D-72127 Kusterdingen
Registereintrag: Amtsgericht Stuttgart, HRB 382295
Geschäftsleitung: Jens Joachim, Ralf Joachim




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_e
Werner Guttmann
2010-05-03 07:52:44 UTC
Permalink
Hi Martin,

a first comment has been posted in the JIRA issue.

Cheers
Werner
Post by M***@innovations.de
Thanks for your early reply Ralf. I've created a new jira issue as you suggested and attached a test case.
http://jira.codehaus.org/browse/CASTOR-2904
Regards
Martin
-----Ursprüngliche Nachricht-----
Gesendet: Mittwoch, 28. April 2010 23:31
Betreff: Re: [castor-dev] Castor-JAXB Interoperability
Hi Martin,
we appreciate any effort to make Castor more compatible with JAXB.
I suggest you to create a new jira issue for the problem at hand a
attach a minimal test case to replay the problem. I think Werner, who is
the one familiar with that part of Castor, will take it from there.
Regards
Ralf
Post by M***@innovations.de
Hello everyone,
I would like to extend / modify Castor to be enable it to unmarhal XML
that has been created by a JAXB reference implementation
but don’t know where to start. I would be grateful if anyone could
provide an idea. Thanks in advance.
I'm currently facing a problem in unmarshalling XML that has been
created by a JAXB implementation with Castor.
I'm wondering if it is possible to do that without specifying any
Castor-Mapping information.
Basically with simple properties it works
(org.exolab.castor.xml.naming=mixed) but the problems arise when
collection types
are involved as the way collections are marshalled/unmarshalled in
JAXB and Castor are slightly different.
...
private Map<Integer, Drink> drinkList;
...
public class Drink {
private String drinkName;
private Float price;
private int alcoholByVolume;
}
...
<drinkList>
<entry>
<key>1</key>
<value>
<alcoholByVolume>0</alcoholByVolume>
<drinkName>Soda</drinkName>
<price>0.99</price>
</value>
</entry>
<entry>
<entry>
<key>2</key>
<value>
<alcoholByVolume>0</alcoholByVolume>
<drinkName>Tonic</drinkName>
<price>1.99</price>
</value>
</entry>
<entry>
</drinkList>
...
...
<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">
<key xsi:type="java:java.lang.Integer">1</key>
<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">
<drinkName>Soda</drinkName>
<price>0.99</price>
</value>
</drinkList>
<drinkList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://java.sun.com"
xsi:type="java:org.exolab.castor.mapping.MapItem">
<key xsi:type="java:java.lang.Integer">2</key>
<value alcoholByVolume="0" xsi:type="java:collectionMapping.Drink">
<drinkName>Tonic</drinkName>
<price>1.99</price>
</value>
</drinkList>
...
Greetings,
Martin
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...