Ben,
When using generated sources, you should not need a mapping file, just compile the generated class descriptors (*Descriptor.java). --Keith Ben John wrote: > > Hi Keith, > Thanks for your response. I am trying to understand the way mapping file is > created based on the schema. When I use the following mapping, the XML do not > contain "items" element. That's the reason the error occurs. Correct? How do I > resolve this? > <class cst:name="JasperScore"> > <description>Default mapping for class JasperScore</description> > <map-to cst:xml="jasperScore"/> > <field cst:name="items" cst:type="CourseAccess" > get-method="enumerateJasperScoreItem" cst:collection="enumerate"> > <bind-xml name="jasperScoreItem" node="element"/> > </field> > </class> > <class cst:name="JasperScoreItem"> > <map-to cst:xml="jasperScoreItem"/> > <field cst:name="courseAccess" cst:type="CourseAccess"> > <bind-xml name="courseAccess" node="element"/> > </field> > </class> > > XML would be like this, > > <jasperScore> > <courseAccess> </courseAccess> > <courseAccess> </courseAccess> > </jasperScore> > > >From the following examples, If I use foo_version_1.xml, I get the "unable to find > >FieldDescriptor error". But If I change to foo_version_2.xml structure, default > >source generator and mapping file works fine. Please let me know how can I resolve > >the issue with foo_version_1.xml. > > Thanks for your time & help. > > foo_version_1.xml > ------------------------ > <?xml version="1.0" encoding="UTF-8"?> > <foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="C:\ben\foo\foo_version1.xsd"> > <fooChild id="1"> > <fooChildElement fooValue="A"> > <key name="abc" value="111"/> > <key name="def" value="222"/> > <key name="ghi" value="333"/> > </fooChildElement> > <fooChildElement fooValue="B"> > <key name="abc" value="111"/> > <key name="def" value="222"/> > <key name="ghi" value="333"/> > </fooChildElement> > </fooChild> > <fooChild id="2"> > <fooChildElement fooValue="C"> > <key name="jkl" value="444"/> > <key name="mno" value="555"/> > <key name="pqr" value="666"/> > </fooChildElement> > <fooChildElement fooValue="D"> > <key name="abc" value="111"/> > <key name="def" value="222"/> > <key name="ghi" value="333"/> > </fooChildElement> > </fooChild> > </foo> > > foo_version_2.xml > ------------------------ > > <?xml version="1.0" encoding="UTF-8"?> > <foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="C:\ben\foo\foo_version2.xsd"> > <fooChildren> > <fooChild id="1"> > <fooChildElements> > <fooChildElement fooValue="A"> > <key name="abc" value="111"/> > <key name="def" value="222"/> > <key name="ghi" value="333"/> > </fooChildElement> > <fooChildElement fooValue="B"> > <key name="abc" value="111"/> > <key name="def" value="222"/> > <key name="ghi" value="333"/> > </fooChildElement> > </fooChildElements> > </fooChild> > <fooChild id="2"> > <fooChildElements> > <fooChildElement fooValue="C"> > <key name="jkl" value="444"/> > <key name="mno" value="555"/> > <key name="pqr" value="666"/> > </fooChildElement> > <fooChildElement fooValue="D"> > <key name="abc" value="111"/> > <key name="def" value="222"/> > <key name="ghi" value="333"/> > </fooChildElement> > </fooChildElements> > </fooChild> > </fooChildren> > </foo> > > -----Original Message----- > From: Keith Visco [mailto:[EMAIL PROTECTED] > Sent: Friday, February 27, 2004 2:35 PM > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] unable to find FieldDescriptor error > > The source generator binding files, used to help control the source > generation, are not the same as the runtime mapping files that are used > in the marshalling/unmarshalling framework. > > Please see here for more details: > > http://castor.exolab.org/sourcegen.html#Binding-File > > --Keith > > bjsp wrote: > > > > Additional Information: > > This time I tried to generate Java source using the mapping xml. The > > same error appears here too. I suspect there is something wrong in the > > mapping file. Please help. Thanks... > > > > C:\ben\jasper>java org.exolab.castor.builder.SourceGenerator -i > > jasper.xsd -binding-file jasperMapp > > ing.xml > > --Unable to load a binding file due to the following Exception: > > -------------------------------- > > Stack Trace for :org.xml.sax.SAXException: unable to find > > FieldDescriptor for 'class' in ClassDescr > > iptor of binding{file: file:///C:/ben/jasper/jasperMapping.xml; line: 2; > > column: 32} > > org.xml.sax.SAXException: unable to find FieldDescriptor for 'class' in > > ClassDescriptor of binding > > at > > org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1127) > > at > > org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1340) > > at > > org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284 > > ) > > at > > org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1812) > > > > at > > org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentSca > > nner.java:1188) > > at > > org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:387) > > at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1099) > > at > > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555) > > at > > org.exolab.castor.builder.binding.BindingLoader.loadBinding(BindingLoader.java:130) > > at > > org.exolab.castor.builder.binding.BindingLoader.createBinding(BindingLoader.java:250) > > at > > org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:1121) > > -------------------------------- > > org.xml.sax.SAXException: unable to find FieldDescriptor for 'class' in > > ClassDescriptor of binding{ > > file: file:///C:/ben/jasper/jasperMapping.xml; line: 2; column: 32} > > at > > org.exolab.castor.builder.binding.BindingLoader.loadBinding(BindingLoader.java:196) > > at > > org.exolab.castor.builder.binding.BindingLoader.createBinding(BindingLoader.java:250) > > at > > org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:1121) > > -- No binding file will be used > > > > -----Original Message----- > > From: bjsp [mailto:[EMAIL PROTECTED] > > Sent: Friday, February 27, 2004 10:52 AM > > To: [EMAIL PROTECTED] > > Subject: [castor-dev] unable to find FieldDescriptor error > > > > Hi, > > I am getting unable to find FieldDescriptor error. I am using > > castor-0.9.4.3-xml.jar. Attached is the error and the mapping file. This > > mapping file is autogenerated using Castor source code generator and > > mapping tool. Any help would be highly appreciated. Thanks in advance. > > > > Mapping [EMAIL PROTECTED] > > unmarClass [EMAIL PROTECTED] > > org.xml.sax.SAXException: unable to find FieldDescriptor for > > 'courseAccess' in ClassDescriptor of jasperScore > > at > > org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1127) > > at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1340) > > at > > org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284) > > at > > org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1812) > > at > > org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1188) > > at > > org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:387) > > at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1099) > > at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555) > > at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:487) > > at com.intellij.rt.execution.application.AppMain.main(Unknown Source) > > Process terminated with exit code 0 > > > > Mapping File: > > ------------------- > > <mapping xmlns="http://castor.exolab.org/" > > xmlns:cst="http://castor.exolab.org/"> > > <description>Castor generated mapping file</description> > > <class cst:name="JasperScore"> > > <description>Default mapping for class JasperScore</description> > > <map-to cst:xml="jasperScore"/> > > <field cst:name="items" cst:type="JasperScoreItem" > > cst:collection="enumerate" get-method="enumerateJasperScoreItem"> > > <bind-xml node="element"/> > > </field> > > </class> > > <class cst:name="JasperScoreItem"> > > <description>Default mapping for class > > JasperScoreItem</description> > > <map-to cst:xml="jasperScore"/> > > <field cst:name="courseAccess" cst:type="CourseAccess"> > > <bind-xml name="courseAccess" node="element"/> > > </field> > > </class> > > <class cst:name="CourseAccess"> > > <description>Default mapping for class CourseAccess</description> > > <map-to cst:xml="courseAccess"/> > > <field cst:name="id" cst:type="java.lang.String" > > cst:required="true"> > > <bind-xml name="id" node="attribute"/> > > </field> > > <field cst:name="status" cst:type="java.lang.String" > > cst:required="true"> > > <bind-xml name="status" node="attribute"/> > > </field> > > <field cst:name="items" cst:type="CourseAccessItem" > > cst:collection="enumerate" get-method="enumerateCourseAccessItem"> > > <bind-xml node="element"/> > > </field> > > </class> > > <class cst:name="CourseAccessItem"> > > <description>Default mapping for class > > CourseAccessItem</description> > > <map-to cst:xml="courseAccess"/> > > <field cst:name="test" cst:type="Test"> > > <bind-xml name="test" node="element"/> > > </field> > > </class> > > <class cst:name="Test"> > > <description>Default mapping for class Test</description> > > <map-to cst:xml="test"/> > > <field cst:name="assetCode" cst:type="java.lang.String" > > cst:required="true"> > > <bind-xml name="assetCode" node="attribute"/> > > </field> > > <field cst:name="scores" cst:type="Scores" cst:collection="array"> > > <bind-xml name="scores" node="element"/> > > </field> > > <field cst:name="status" cst:type="java.lang.String"> > > <bind-xml name="status" node="element"/> > > </field> > > <field cst:name="dateCreated" cst:type="java.lang.String"> > > <bind-xml name="dateCreated" node="element"/> > > </field> > > <field cst:name="dateCompleted" cst:type="java.lang.String"> > > <bind-xml name="dateCompleted" node="element"/> > > </field> > > </class> > > <class cst:name="Scores"> > > <description>Default mapping for class Scores</description> > > <map-to cst:xml="scores"/> > > <field cst:name="items" cst:type="ScoresItem" > > cst:collection="enumerate" get-method="enumerateScoresItem"> > > <bind-xml node="element"/> > > </field> > > </class> > > <class cst:name="ScoresItem"> > > <description>Default mapping for class ScoresItem</description> > > <map-to cst:xml="scores"/> > > <field cst:name="score" cst:type="Score"> > > <bind-xml name="score" node="element"/> > > </field> > > </class> > > <class cst:name="Score"> > > <description>Default mapping for class Score</description> > > <map-to cst:xml="score"/> > > <field cst:name="name" cst:type="java.lang.String" > > cst:required="true"> > > <bind-xml name="name" node="attribute"/> > > </field> > > <field cst:name="value" cst:type="java.lang.String" > > cst:required="true"> > > <bind-xml name="value" node="attribute"/> > > </field> > > </class> > > </mapping> > > > > ----------------------------------------------------------- > > 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 > > ----------------------------------------------------------- > 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
