Title: Nachricht
Hello, 
I have done some experimenting and have found the cause of the trouble but not yet a solution.
The cause seems to be that I use a special mapping to unmarshal the document:
  <class name="com.bmw.gst.tpeg.primitives.Tpeg_document">
     <field name="generation_time" type="java.util.Date" handler="com.bmw.gst.tpeg.DateFieldHandler">
        <bind-xml node="text"/>
     </field>
  </class>
I did this because the date format in the document does not agree to the castor unmarshaller. If I correct the date in the xml document and do not use a modified mapping, unmarshalling works. Can it be that the unmarshaller "forgets" how to handle  the other fields if a specific mapping is made?
Regards
Harald Brennich
I have a problem unmarshalling XML documents with castor.
 
 Castor version  is  0.9.7
 
 The schema  is  (excerpt):
...
 <xs:element name='tpeg_document'>
  <xs:complexType>
   <xs:choice minOccurs='0' maxOccurs='unbounded'>
    <xs:element ref='tpeg_message_set'/>
    <xs:element ref='tpeg_message'/>
    <xs:element ref='road_traffic_message'/>
    <xs:element ref='public_transport_information'/>
   </xs:choice>
   <xs:attribute name='generation_time' type='time' use='optional'/>
  </xs:complexType>
 </xs:element>
...
 
The  Xml document  is: 
<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href=''?>
<!DOCTYPE tpeg_document PUBLIC '-//EBU/tpegML/EN' "tpegML.dtd">
<tpeg_document generation_time='2004-01-04T22:00:2+1'>
<tpeg_message>
...
Unmarshalling stops at element <tpeg_message>.
 
 The error message is:
unable to find FieldDescriptor for 'tpeg_message' in ClassDescriptor of tpeg_document{file: [not available]; line: 5; column
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:671)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:565)
        at com.bmw.gst.tpeg.TpegReader.scanInput(Unknown Source)
        at com.bmw.gst.tpeg.TpegReader.main(Unknown Source)
Caused by: org.xml.sax.SAXException: unable to find FieldDescriptor for 'tpeg_message' in ClassDescriptor of tpeg_document
        at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1940)
        at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1388)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:657)
        ... 3 more
Caused by: org.xml.sax.SAXException: unable to find FieldDescriptor for 'tpeg_message' in ClassDescriptor of tpeg_document
        at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1940)
        at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1388)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:657)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:565)
        at com.bmw.gst.tpeg.TpegReader.scanInput(Unknown Source)
        at com.bmw.gst.tpeg.TpegReader.main(Unknown Source)
Caused by: org.xml.sax.SAXException: unable to find FieldDescriptor for 'tpeg_message' in ClassDescriptor of tpeg_document
        at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1940)
        at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1388)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:657)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:565)
        at com.bmw.gst.tpeg.TpegReader.scanInput(Unknown Source)
        at com.bmw.gst.tpeg.TpegReader.main(Unknown Source)
MarshalException: unable to find FieldDescriptor for 'tpeg_message' in ClassDescriptor of tpeg_document
 
Comment:
 As the class Tpeg_document generated by castor only has a list of Tpeg_documentItem, Tpeg_documentDescriptor only has _item .  The class Tpeg_documentItemDescriptor knows tpeg_message , but the Unmarshaller tries  Tpeg_documentDescriptor  for 'tpeg_message'  and not Tpeg_documentItemDescriptor.
 
How  can this be avoided?
Regards
Harald Brennich 

Reply via email to