Hi Stephen,
just followed your link and wrote a test program after reading the
content. It worked! Cool! Now I'm made my decision of using Castor!
There was one thing worth noticing in my test. Say I have four classes
Document, Content (abstract), TextParagraph extends Content, Table
extends Content. In the base class Content there is a member field
called "id". There is a List<Content> in the Document class as a member.
In my first mapping file, I said
<class name="TextParagraph" identity="id">
<class name="Table" identity="id">
Test failed, Castor complained that she could not find the id
descriptor. Then I moved the identity="id" to the Content class. Then
everything was okay. Ideally Castor should try to find the descriptor of
a field in the base class automatically.
And I found an attribute "container = true | false" of the <field>
element (not documented in the online tutorial yet). My IDE popped this
up in the selection list while I was typing. Out of curiosity I checked
out the mapping.dtd and found the explaination. This attribute is very
handy for my project, many thanks to the Castor team for offering it!
Best Regards,
Ellen N. Zhao
Stephen Bash schrieb:
Ellen-
Have you seen:
http://castor.org/how-to-use-references-in-xml.html
I think that's basically what you're looking for, but feel free to
elaborate if it doesn't quite fit your needs.
Thanks,
Stephen
On Thu, Jun 12, 2008 at 2:24 PM, Ning Zhao <[EMAIL PROTECTED]> wrote:
Dear all!
I'm evaluating object2xml tools for using in a project with very complex
object relationships. Now the finalists are Castor and JiBX. Basically I
like Castor's simple and clean mapping syntax very much. JiBX can do more in
term of decoupling the xml representation and their model objects but the
mapping synatx is wordier. Things like performance do not really matter in
my case. Ease of use does count (a big plus for Castor). The crucial thing
is, I must map nested objects (very complex objects, by the way) using
their ids, otherwise the output xml will be bloated with repeated
representation of huge objects.
To be concrete, please have a look here:
http://jibx.sourceforge.net/tutorial/binding-collects.html#collects
The feature in the section "Working with IDs" is exactly what I want. I read
the Castor tutorial again ( http://castor.org/xml-mapping.html ) and did
not see similar feature. Of course I can tweak my model object classe to
have the id of the member object as a member field and only map that id
field. But that's not really an elegant solution. Did I miss anything in the
Castor tutorial? Any hint or how-to advice would be highly appreciated!
Best Regards,
Ellen N. Zhao
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email