I'm running into some oddities with mapping files and the use of the
"location" attribute on the "bind-xml" element.
Given this XML:
<?xml version="1.0"?>
<book>
<book-info isbn="9780446618502" />
<title>The Book of the Dead</title>
</book>
--And a class like this for Book.java:
public class Book {
/** The book's ISBN */
private String isbn;
/** The book's title */
private String title;
public Book() { }
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getIsbn() {
return isbn;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}
I have this mapping file:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//
EN" "http://castor.org/mapping.dtd">
<mapping>
<class name="ibm.xml.castor.Book">
<map-to xml="book" />
<field name="Title" type="java.lang.String">
<bind-xml name="title" />
</field>
<field name="Isbn" type="java.lang.String">
<bind-xml name="isbn" node="attribute" location="book-info" />
</field>
</class>
</mapping>
As far as I can see, this should work; but it doesn't. I get output
similar to this:
Jan 15, 2008 8:07:46 AM org.exolab.castor.mapping.Mapping setBaseURL
INFO: book-mapping.xml is not a URL, trying to convert it to a file URL
Jan 15, 2008 8:07:46 AM org.exolab.castor.mapping.Mapping loadMapping
INFO: Loading mapping descriptors from book-mapping.xml
Jan 15, 2008 8:07:47 AM org.exolab.castor.xml.UnmarshalHandler
startElement
WARNING: unable to find FieldDescriptor for 'book-info' in
ClassDescriptor of book
Jan 15, 2008 8:07:47 AM org.exolab.castor.xml.UnmarshalHandler
endElement
INFO: Ignoring book-info no descriptor was found
Further, the title is correctly assigned to an instance of Book, but
the ISBN is not. Any ideas? I've tried several variations, and was
unable to find anything obviously wrong.
Help is greatly appreciated! I've been banging against this one for a
solid day now :-(
Thanks
---
Brett McLaughlin
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email