Castor XML users and developers,
I've recently committed in the CVS the initial (first cut) support for
handling nested/wrapper elements via the mapping file. Wrapper elements
are simply elements which appear in the XML instance, but do not have a
direct mapping to an object or field within the object model.
For example to map an instance of the following class:
public class Foo {
private Bar bar = null;
public Foo();
public getBar() {
return bar;
}
public void setBar(Bar bar) {
this.bar = bar;
}
}
into the following XML instance:
<?xml version="1.0"?>
<foo>
<abc>
<bar>...</bar>
</abc>
</foo>
(notice that an 'abc' field doesn't exist in the Bar class)
One would use the following mapping:
<?xml version="1.0"?>
<mapping>
...
<class name="Foo">
<field name="bar" type="Bar">
<bind-xml name="bar" location="abc"/>
</field>
</class>
...
</mapping>
Note the "location" attribute. The value of this attribute is the name
of the wrapper element. To use more than one wrapper element, the name
is separated by a forward-slash as such:
<bind-xml name="bar" location="abc/xyz"/>
Note that the name of the element is not part of the location itself and
that the location is always relative to the class in which the field is
being defined.
This works for attributes also:
<bind-xml name="bar" location="abc" node="attribute"/>
will produce the following:
<?xml version="1.0"?>
<foo>
<abc bar="..."/>
</foo>
The code is still "under-development" and this is my first attempt at
supporting this, so there may be issues. Please let me know if you run
across any problems.
Thanks,
--Keith
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev