Is there a way to pass in parent data to a child class? It seems like
it would be possible if the <field> mapping element could hold the class
that is was mapped to instead of the bind-xml. Sorta letting you say
this field equals this class and that class has the fields from its
parent node set on it.
This doesn't work, but is there a clever way of accomplishing something
like this?
<class name="TestSuite">
<map-to xml="testSuite"/>
<field name="tests" collection="arraylist">
<class name="Test">
<field name="status" type="string">
<bind-xml name="status"
node="attribute"/>
</field>
</class>
</field>
</class>
<class name="Test">
<map-to xml="test"/>
<field name="name" type="string">
<bind-xml node="text"/>
</field>
</class
________________________________
From: Bret Gregory [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 11, 2007 12:43 PM
To: [email protected]
Subject: [castor-user] Referencing Parent Node's Data
Is there a way to map a parent node's data on a child nodes element?
I have found where other people have asked a similar question, but no
answers were given. I also looked to see if there were an Jira requests
for this, and I found one from 2004 (CASTOR-856) that wasn't
implemented, but I wasn't sure if this is because there is a work
around.
Below is an example:
TestSuite holds tests. And I want to map the test's status to the
"tests" element.
This seems like it would be a pretty common request as the XML hierarchy
often is a parent-child relationship where the children can inherit from
their parent nodes.
XML:
<testsuite>
<tests status="FAILED">
<test>test1</test>
<test>test2</test
<test>test3</test
<test>test4</test
</ tests>
<tests status="PASSED">
<test>test1</test>
<test>test2</test
<test>test3</test
<test>test4</test
</tests>
</testsuite>
Objects:
TestSuite (contains a List of Test Objects)
Test (contains a string with its status)
Can anyone show me how this would/could be mapped?