M***@innovations.de
2010-04-27 15:31:35 UTC
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
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