
| Key: |
CASTOR-1995
|
| Type: |
Bug
|
| Status: |
Open
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Herman
|
| Votes: |
0
|
| Watchers: |
1
|
|
If you were logged in you would be able to see more operations.
|
|
|
castor
Created: 04/Jun/07 09:44 AM
Updated: 08/Jun/07 04:42 AM
|
|
| Component/s: |
XML code generator
|
| Affects Version/s: |
1.0.5,
1.1.1
|
| Fix Version/s: |
None
|
|
|
File Attachments:
|
1.
BugReportFiles.zip (6 kb)
|
|
Environment:
|
Bug noticed on Windows XP, Eclipse IDE
|
|
|
When using the location attribute in the Castor Mapping XML file, only one element with an attribute can be specified in any class. If another attribute is specified, Castor does not map the attribute and ignores it. If I specify another class, then I can place one more attribute in a element belonging to this class.
|
|
Description
|
When using the location attribute in the Castor Mapping XML file, only one element with an attribute can be specified in any class. If another attribute is specified, Castor does not map the attribute and ignores it. If I specify another class, then I can place one more attribute in a element belonging to this class. |
Show » |
|
I had a similar issue and the following worked for me, assuming your multiple xml elements have the same mapping (XML Field) to (Java Field) , i.e. You have a book object that can accommodate xml elements MysteryBook, ReferenceBook:
Create the class with the mappings but no bind-xml element.
For example:
<class name="mypackage.Book"
<field name="ISBN" type="java.lang.String">
<bind-xml name="ISBNNUMBER" />
</field>
...
Then, have a single object that holds all of your Book objects under a collection (setMysteryBookList(Collection<Book> my books):
<class name="mypackage.BookShelf"
<field name="MysteryBookList" type="mypackage.Book" collection="collection">
<bind-xml name="MysteryBook" />
</field>
<field name="ReferenceBookList" type="mypackage.Book" collection="collection">
<bind-xml name="ReferenceBook" />
</field>
</class>
Your Book class would look like:
public class Book {
private String ISBN = null;
public void setISBN (String isbn) { this.ISBN = isbn; }
public String getISBN () { return this.ISBN; }
...
}
Your BookShelf class would look like:
public class BookShelf {
private Collection<Book> mysteryBooks = null;
private Collection<Book> referenceBooks = null;
public void setMysteryBooks (Collection<Book> books) { this.mysteryBooks = books; }
public void setReferenceBooks (Collection<Book> books { this.referenceBooks = books; }
}
Hope this helps. Good luck!!