Steve,
What happens if you replace type="strings" with type="string" ?
--Keith
> "Oliver, Steve" wrote:
>
> Hi all,
>
> I just started using castor yesterday. I�ve started with the Person
> example and added an array. When I try to unmarshal I get the
> following error
>
> org.xml.sax.SAXException: Illegal Text data found as child of: Name
>
> value: "Tom"{file: [not available]; line: 3; column: 18}
>
> Here is the source and mapping I am using�
>
> Person.java
>
> public class Person implements java.io.Serializable {
>
> private String[] names = {"Tom", "Dick", "Harry"};
>
> public Person() {
>
> super();
>
> }
>
> public String[] getNames() {
>
> return names;
>
> }
>
> public void setNames(String[] names) {
>
> this.names = names;
>
> }
>
> public static void main(String[] argv) {
>
> Mapping mapping = new Mapping();
>
> // Create a new Person
>
> Person person = new Person();
>
>
>
> try {
>
> // Load the mapping information from the file
>
> mapping.loadMapping("mapping.xml");
>
> // Marshal the data
>
> Marshaller marshaller = new Marshaller(new
> OutputStreamWriter(System.out));
>
> marshaller.setMapping(mapping);
>
> marshaller.marshal(person);
>
>
>
> System.out.println("");
>
>
>
> // Unmarshal the data
>
> Unmarshaller unmarshaller = new
> Unmarshaller(mapping);
>
> person = (Person)unmarshaller.unmarshal(new
> InputSource(new FileReader("person.xml")));
>
> marshaller.marshal(person);
>
> } catch (Exception e) {
>
> System.out.println(e);
>
> }
>
> }
>
> }
>
> <?xml version="1.0"?>
>
> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
> 1.0//EN"
>
> "http://castor.exolab.org/mapping.dtd">
>
> mapping.xml
>
> <mapping>
>
> <class name="Person">
>
> <map-to xml="Person"/>
>
> <field name="names"
>
> type="strings" collection="array">
>
> <bind-xml name="Name" node="element"/>
>
> </field>
>
> </class>
>
> </mapping>
>
> person.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Person>
>
> <Name>Tom</Name>
>
> <Name>Dick</Name>
>
> <Name>Harry</Name>
>
> </Person>
>
>
>
> Marshalling works fine. I can get the unmarshal to work if I change
> the array to a Vector. Why won�t my array work? What am I doing wrong?
>
> Thanks for helping me get started�
>
> Steve
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev