|
Hi, first I was loading the XML
data directly into castor from a FileReader Objekt which worked fine. Now I
want to load the same file into DOM and then take that DOM as input for castor.
But now it doesn’t work anymore. I get the error message: unable to find
FieldDexcriptor for ‘lastname’ in ClassDescriptor of Person. I didn’t
make any changes to the mapping file, so whats wrong? Mapping mapping = new
Mapping(); mapping.loadMapping(
"bindtest/testMapping.xml" ); DOMParser parser = new
DOMParser(); parser.parse(new
InputSource(new FileInputStream("persondata.xml"))); Document document =
parser.getDocument(); Unmarshaller unmar = new
Unmarshaller(mapping); Person person =
(Person)unmar.unmarshal(document); The errorr occurs in the last
line of the code.This is my xml file and my mapping file: <?xml
version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href=""> <Person
xmlns="http://www.iese.fhg.de/Person"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.iese.fhg.de/Person Person.xsd"> <lastname>Mustermann</lastname> <firstname>Karl</firstname> <author type="association" href=""> <employee type="association" href=""> </Person> <?xml
version="1.0" encoding="UTF-8"?> <!DOCTYPE databases PUBLIC
"-//EXOLAB/Castor Mapping DTD
Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd"> <mapping> <class
name="bindtest.Person">
<map-to xml="Person"/> <field
name="lastname" type="string">
<bind-xml name="lastname"/>
</field>
<field name="firstname" type="string">
<bind-xml name="firstname"/> </field>
<field collection="array" name="author"
type="bindtest.Author">
<bind-xml name="author"/>
</field>
<field collection="array" name="employee"
type="bindtest.Employee">
<bind-xml name="employee"/>
</field> </class> <class
name="bindtest.Author">
<field name="type" type="string">
<bind-xml name="type" node="attribute"/>
</field>
<field name="href" type="string">
<bind-xml name="href" node="attribute"/>
</field> </class> <class
name="bindtest.Employee">
<field name="type" type="string">
<bind-xml name="type" node="attribute"/>
</field>
<field name="href" type="string">
<bind-xml name="href" node="attribute"/>
</field> </class> </mapping> Are there any suggestions? Best regards, Nick |
