I am
encountering a problem when unmarshalling a collection. Specifically I get
a collection object populated with one(1) not null, but otherwise
empty object/element instead of a fully populated collection with objects
set with their associated attribute/properties.
I am using
Castor XML v.0.9.5.3 and JDK v.1.4.2_03.
The
following are the relevant pieces (I think):
Here is the
marshalled xml that I am now trying to umarshal:
-------------------------------------------------------------------
<YMIA:Product
Id="999" GroupId="17" xmlns:YMIA="http://www.example.com/YMIA"><YMIA:Name>CVP-309GP</YMIA:Name>
<YMIA:FilesystemName>cvp-309gp</YMIA:FilesystemName>
<YMIA:DisplayName>CVP-309GP</YMIA:DisplayName>
<YMIA:Descriptions>
<YMIA:Description Id="983" DescriptionTypeId="4" ProductId="999">
<YMIA:DescriptionText>An advanced full-sized...</YMIA:DescriptionText>
</YMIA:Description>
<YMIA:Description Id="982" DescriptionTypeId="3" ProductId="999">
<YMIA:DescriptionText>The CVP-309GP is an...</YMIA:DescriptionText>
</YMIA:Description>
<YMIA:Description Id="981" DescriptionTypeId="2" ProductId="999">
<YMIA:DescriptionText>The CVP-309GP is...</YMIA:DescriptionText>
</YMIA:Description>
</YMIA:Descriptions>
</YMIA:Product>
-------------------------------------------------------------------
Here is
Castor mapping xml:
<?xml
version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">
<mapping>
<description>Product mapping</description>
<description>Product mapping</description>
<class
name="com.my.pkg.Product">
<map-to xml="Product" ns-prefix="YMIA" ns-uri="http://www.example.com/YMIA"/>
<map-to xml="Product" ns-prefix="YMIA" ns-uri="http://www.example.com/YMIA"/>
<field
name="id"
type="java.lang.Integer">
<bind-xml name="Id" node="attribute"/>
</field>
<bind-xml name="Id" node="attribute"/>
</field>
<field
name="name"
type="java.lang.String">
<bind-xml name="Name" node="element"/>
</field>
<bind-xml name="Name" node="element"/>
</field>
<field
name="filesystemName"
type="java.lang.String">
<bind-xml name="FilesystemName" node="element"/>
</field>
<bind-xml name="FilesystemName" node="element"/>
</field>
<field
name="descriptions" type="com.my.pkg.Description"
collection="array">
<bind-xml name="Description" location="Descriptions" node="element"/>
</field>
<bind-xml name="Description" location="Descriptions" node="element"/>
</field>
</class>
<class
name="com.my.pkg.Description">
<map-to xml="Descriptions" ns-prefix="YMIA" ns-uri="http://www.example.com/YMIA"/>
<map-to xml="Descriptions" ns-prefix="YMIA" ns-uri="http://www.example.com/YMIA"/>
<field
name="id"
type="java.lang.Integer">
<bind-xml name="Id" node="attribute"/>
</field>
<bind-xml name="Id" node="attribute"/>
</field>
<field
name="descriptionTypeId"
type="java.lang.Integer">
<bind-xml name="DescriptionTypeId" node="attribute"/>
</field>
<bind-xml name="DescriptionTypeId" node="attribute"/>
</field>
<field
name="productId"
type="java.lang.Integer">
<bind-xml name="ProductId" node="attribute"/>
</field>
<bind-xml name="ProductId" node="attribute"/>
</field>
<field
name="descriptionText"
type="java.lang.String">
<bind-xml name="DescriptionText" node="element"/>
</field>
</class>
<bind-xml name="DescriptionText" node="element"/>
</field>
</class>
</mapping>
-------------------------------------------------------------------
The
output:
product=
id=999
name=CVP-309GP
fileSystemName=cvp-309gp
displayName=CVP-309GP
descriptions=[Lcom.my.pkg.Description;@e61a35
description=
id=null
productId=null
descriptionTypeId=null
descriptionText=
id=999
name=CVP-309GP
fileSystemName=cvp-309gp
displayName=CVP-309GP
descriptions=[Lcom.my.pkg.Description;@e61a35
description=
id=null
productId=null
descriptionTypeId=null
descriptionText=
-------------------------------------------------------------------
Additionally I have set the following umarshalling
instructions:
Unmarshaller unmar = new
Unmarshaller(mapping);
unmar.setIgnoreExtraElements(true);
unmar.setIgnoreExtraAttributes(true);
unmar.setIgnoreExtraElements(true);
unmar.setIgnoreExtraAttributes(true);
I think the
problem is in the mapping configuration, but I have not been able to figure
it out.
Any help
would be appreciated. Thanks.
-Anand
Krishnan
===
Java
Developer
Yamaha Music
Interactive Inc
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev