Keith,

I downloaded the daily snapshot version and compiled it and ran the same
test.  I now get the following error.

ShipTo is of type Address
UKAddress is an extension(Inheritance) of Address
USAddress is an extension(Inheritance) of Address

But the unmarshall fails saying unable to instantiate UKAddress as it is not
a subclass of ShipTo.

Let me know if you could help me on this.

Thanks,
Bharath

---
ERROR MESSAGE:

Unmarshalling TPFS
org.xml.sax.SAXException: unable to instantiate test.UKAddress;
org.xml.sax.SAXE
xception: class test.UKAddress is not a subclass of class test.ShipTo
        at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.
java:970)
        at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1340)

        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XML
Validator.java:1284)
        at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumen
tScanner.java:1806)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
atch(XMLDocumentScanner.java:1182)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
canner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:338)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:270)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:391)
        at RunTest.main(RunTest.java:32)

-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 5:31 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Unmarshal exception while using inheritance



Did you try using the latest CVS version?

Thanks,

--Keith

"Nedunchelian, Bharath" wrote:
> 
> I used sourcegenerator for generating java source code.  I compiled the
> generated code and when I try to unmarshal an example xml which conforms
to
> the schema,  I am having problems.  There is inheritance in the example.
I
> think the use of inheritance is causing the problem.  The error I get when
I
> try to unmarshal is "org.xml.sax.SAXException: unable to find
> FieldDescriptor for 'postcode' in Class Descriptor of shipTo".  Any help I
> could get on this will be appreciated.
> 
> <?xml version = "1.0" encoding = "UTF-8"?>
> <purchaseOrder xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance";
> orderDate = "1999-12-01" xsi:noNamespaceSchemaLocation =
> "file:///C:/castor-0.9.3.9/examples/SourceGenerator/purchaseorder.xsd">
>         <shipTo exportCode = "1" xsi:type = "UKAddress">
>                 <name>Helen Zoe</name>
>                 <street>47 Eden Street</street>
>                 <city>Cambridge</city>
>                 <postcode>CB1 1JR</postcode>
>         </shipTo>
>         <billTo xsi:type = "USAddress">
>                 <name>Robert Smith</name>
>                 <street>8 Oak Avenue</street>
>                 <city>Old Town</city>
>                 <state>AL</state>
>                 <zip>95819</zip>
>         </billTo>
>         <items>
>                 <item partNum = "833-AA">
>                         <productName>Lapis necklace</productName>
> 
>                         <quantity>1</quantity>
>                         <USPrice>99.95</USPrice>
>                         <comment>Want this for the holidays!</comment>
> 
>                         <shipDate>1999-12-05</shipDate>
>                 </item>
>         </items>
> </purchaseOrder>
> 
> The schema for the above example is
> 
> <?xml version = "1.0" encoding = "UTF-8"?>
> <!--Generated by XML Authority. Conforms to w3c
> http://www.w3.org/2001/XMLSchema-->
> <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema";
>          elementFormDefault = "qualified">
>         <xsd:element name = "purchaseOrder" type = "PurchaseOrderType"/>
>         <xsd:element name = "comment" type = "xsd:string"/>
>         <xsd:complexType name = "PurchaseOrderType">
>                 <xsd:sequence>
>                         <xsd:element name = "shipTo" type = "Address"/>
>                         <xsd:element name = "billTo" type = "Address"/>
>                         <xsd:element ref = "comment" minOccurs = "0"/>
>                         <xsd:element name = "items" type = "Itemstype"/>
>                 </xsd:sequence>
>                 <xsd:attribute name = "orderDate" type = "xsd:date"/>
>         </xsd:complexType>
>         <xsd:complexType name = "Itemstype">
>                 <xsd:sequence>
>                         <xsd:element name = "item" minOccurs = "0"
maxOccurs
> = "unbounded">
>                                 <xsd:complexType>
>                                         <xsd:sequence>
>                                                 <xsd:element name =
> "productName" type = "xsd:string"/>
>                                                 <xsd:element name =
> "quantity">
>                                                         <xsd:simpleType>
> 
> <xsd:restriction base = "xsd:positiveInteger">
> 
> <xsd:maxExclusive value = "100"/>
> 
> </xsd:restriction>
>                                                         </xsd:simpleType>
>                                                 </xsd:element>
>                                                 <xsd:element name =
> "USPrice" type = "xsd:decimal"/>
>                                                 <xsd:element ref =
"comment"
> minOccurs = "0"/>
>                                                 <xsd:element name =
> "shipDate" type = "xsd:date" minOccurs = "0"/>
>                                         </xsd:sequence>
>                                         <xsd:attribute name = "partNum"
use
> = "required" type = "SKU"/>
>                                 </xsd:complexType>
>                         </xsd:element>
>                 </xsd:sequence>
>         </xsd:complexType>
>         <xsd:simpleType name = "SKU">
>                 <xsd:restriction base = "xsd:string">
>                         <xsd:pattern value = "\d{3}-[A-Z]{2}"/>
>                 </xsd:restriction>
>         </xsd:simpleType>
>         <xsd:simpleType name = "USState">
>                 <!-- and so on ... -->
>                 <xsd:restriction base = "xsd:string">
>                         <xsd:enumeration value = "AK"/>
>                         <xsd:enumeration value = "AL"/>
>                         <xsd:enumeration value = "AR"/>
>                 </xsd:restriction>
>         </xsd:simpleType>
>         <xsd:complexType name = "Address">
>                 <xsd:sequence>
>                         <xsd:element name = "name" type = "xsd:string"/>
>                         <xsd:element name = "street" type = "xsd:string"/>
>                         <xsd:element name = "city" type = "xsd:string"/>
>                 </xsd:sequence>
>         </xsd:complexType>
>         <xsd:complexType name = "USAddress">
>                 <xsd:complexContent>
>                         <xsd:extension base = "Address">
>                                 <xsd:sequence>
>                                         <xsd:element name = "state" type =
> "USState"/>
>                                         <xsd:element name = "zip" type =
> "xsd:positiveInteger"/>
>                                 </xsd:sequence>
>                         </xsd:extension>
>                 </xsd:complexContent>
>         </xsd:complexType>
>         <xsd:complexType name = "UKAddress">
>                 <xsd:complexContent>
>                         <xsd:extension base = "Address">
>                                 <xsd:sequence>
>                                         <xsd:element name = "postcode"
type
> = "xsd:string"/>
>                                 </xsd:sequence>
>                                 <xsd:attribute name = "exportCode" fixed =
> "1" type = "xsd:positiveInteger"/>
>                         </xsd:extension>
>                 </xsd:complexContent>
>         </xsd:complexType>
> 
>         <!-- other Address derivations for more countries -->
> 
> </xsd:schema>
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

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

Reply via email to