Hi Keith,

I tried adding the collection="array" array, but it didn't seem to make
any difference.

Here is the error I received.  It seems like in the 2D case, it's having
a hard time determining what sub_product should map to.

--------------------ERROR
wrapper-element: data_array
#startElement: row
unable to find or create a ClassDescriptor for class:
[Lcom.fmr.cfit.matt.castor.SubProduct;

#startElement: sub_product unable to find FieldDescriptor for
'sub_product' in ClassDescriptor of sub_product
org.xml.sax.SAXException: unable to find FieldDescriptor for
'sub_product' in ClassDescriptor of sub_product
        void
org.exolab.castor.xml.UnmarshalHandler.startElement(java.lang.String,
java.lang.String, org.exolab.castor.xml.AttributeSet)
UnmarshalHandler.java:1791      void
org.exolab.castor.xml.UnmarshalHandler.startElement(java.lang.String,
java.lang.String, java.lang.String, org.xml.sax.Attributes)
UnmarshalHandler.java:1292
---------------

I have attached my complete mapping file as well as the output of my
Marshalling process.

Do you have any other ideas?

------------------------
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN"
                                 "http://castor.exolab.org/mapping.dtd";>
<mapping>
        <description>Description of the mapping for the Product
Class</description>
        <class name="com.fmr.cfit.matt.castor.Product">
                <map-to xml="WrapperProductClass"></map-to>
                <field name="array" collection="array"
type="com.fmr.cfit.matt.castor.SubProduct">
                        <bind-xml name="row" location="data_array"/>

                </field>        
        </class>
        <class name="com.fmr.cfit.matt.castor.SubProduct">
                <map-to xml="sub_product"></map-to>
                <field name="name" type="java.lang.String">
                        <bind-xml name="name" node="attribute"/>
                </field>
                <field name="value" type="java.lang.String">
                        <bind-xml name="value" node="element"/>
                </field>
        </class>
</mapping>


<?xml version="1.0" encoding="UTF-8"?>
<WrapperProductClass>
        <data_array>
                <row
xsi:type="java:[Lcom.fmr.cfit.matt.castor.SubProduct;"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
                        <sub_product name="oneone">
                                <value>oneonevalue</value>
                        </sub_product>
                        <sub_product name="onetwo">
                                <value>onetwovalue</value>
                        </sub_product>
                </row>
                <row
xsi:type="java:[Lcom.fmr.cfit.matt.castor.SubProduct;"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
                        <sub_product name="twoone">
                                <value>twoonevalue</value>
                        </sub_product>
                        <sub_product name="twotwo">
                                <value>twotwovalue</value>
                        </sub_product>
                </row>
        </data_array>
</WrapperProductClass>



-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 11, 2005 11:59 PM
To: [email protected]
Subject: Re: [castor-user] Marshalling/Unmarshalling 2-D Arrays



Matt,

Did you try adding collection="array" to your mapping?

--Keith

Emerson, Matt wrote:
> I have created two classes: Product and SubProduct.  The product is 
> designed to hold a two-dimensional array of SubProducts. 
> 
>  Public class Product
> { 
>         private SubProduct[][] array;
> 
>         public Product()  
> 
>         public List setArray(SubProduct[][] data) { this.array = data;
}  
> 
>         public SubProduct[][] getArray() { return this.array; }
> }
> 
> Public class SubProduct
> {
>         private String name;
>         private String value;
> 
>         public void setName(String data) { this.name = data; }
>         publci void sety Value(String data) { this.value = data; }
> }
> 
> My mapping is as follows:
> <mapping>
>         <description>Description of the mapping for the Product 
> Class</description>
>         <class name="com.fmr.cfit.matt.castor.Product">
>                 <map-to xml="WrapperProductClass"></map-to>

>                
>                 <field name="array" 
> type="com.fmr.cfit.matt.castor.SubProduct">
>                         <bind-xml name="row" location="data_array"/>

>                
>                 </field>                    
>         </class>
>         <class name="com.fmr.cfit.matt.castor.SubProduct">
>                 <map-to xml="sub_product"></map-to>
>                 <field name="name" type="java.lang.String">
>                         <bind-xml name="name" node="attribute"/>
>                 </field>
>                 <field name="value" type="java.lang.String">
>                         <bind-xml name="value" node="element"/>
>                 </field>
>         </class>
> </mapping>
> 
> When I marshal, a class of type Product, everything works fine.
> 
> However, when I try to unmarshall the results back into an object, I
get 
> the following error.    Does anyone know why this would be occurring?
> 
> #startElement: data_array
> 
> wrapper-element: data_array
> 
> #startElement: row
> 
> unable to find or create a ClassDescriptor for class: 
> [Lcom.fmr.cfit.matt.castor.SubProduct;
> 
> unable to instantiate [Lcom.fmr.cfit.matt.castor.SubProduct;; 
> org.xml.sax.SAXException: [Lcom.fmr.cfit.matt.castor.SubProduct; is
not 
> a subclass of com.fmr.cfit.matt.castor.SubProduct
> 
> org.xml.sax.SAXException: unable to instantiate 
> [Lcom.fmr.cfit.matt.castor.SubProduct;; org.xml.sax.SAXException: 
> [Lcom.fmr.cfit.matt.castor.SubProduct; is not a subclass of 
> com.fmr.cfit.matt.castor.SubProduct
> 
>  void 
> org.exolab.castor.xml.UnmarshalHandler.startElement(java.lang.String, 
> java.lang.String, org.exolab.castor.xml.AttributeSet)
> 
>   UnmarshalHandler.java:1959
> 
>  void 
> org.exolab.castor.xml.UnmarshalHandler.startElement(java.lang.String, 
> java.lang.String, java.lang.String, org.xml.sax.Attributes)
> 
>   UnmarshalHandler.java:1292
> 
>  void 
>
org.apache.xerces.parsers.SAXParser.startElement(org.apache.xerces.utils
.QName, 
> org.apache.xerces.framework.XMLAttrList, int)
> 
>   SAXParser.java:1371
> 
>  void 
>
org.apache.xerces.validators.common.XMLValidator.callStartElement(org.ap
ache.xerces.utils.QName)
> 
>   XMLValidator.java:840
> 
>  boolean 
>
org.apache.xerces.framework.XMLDocumentScanner.scanElement(org.apache.xe
rces.utils.QName)
> 
>   XMLDocumentScanner.java:1852
> 
>  boolean 
>
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatc
h(boolean)
> 
>   XMLDocumentScanner.java:1233
> 
>  boolean
org.apache.xerces.framework.XMLDocumentScanner.parseSome(boolean)
> 
>   XMLDocumentScanner.java:380
> 
>  void
org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource)
> 
>   XMLParser.java:908
> 
>  java.lang.Object 
> org.exolab.castor.xml.Unmarshaller.unmarshal(org.xml.sax.InputSource) 
> Unmarshaller.java:605
> 
>  java.lang.Object 
> org.exolab.castor.xml.Unmarshaller.unmarshal(java.io.Reader) 
> Unmarshaller.java:513
> 
>  void com.fmr.cfit.matt.castor.TestCastor.runTest2()
> 
>   TestCastor.java:77
> 
>  void com.fmr.cfit.matt.castor.TestCastor.main(java.lang.String[])
> 
>   TestCastor.java:36
>  
> 
>  Thanks for the help,
> 
> Matt
> 
> 
>
------------------------------------------------------------------------
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to