Details
Description
Using nested class mappings (see http://castor.codehaus.org/xml-mapping.html#3.5-The-%3Cbind-xml%3E-element) to describe the elements of multiple Java Map objects requires specifying several different mappings for the org.exolab.castor.mapping.MapItem class. In the mapping.dtd file, the class name attribute is an ID, and thus can only occur once in an XML file. This results in a fully functional (from Castor's perspective) mapping file that is invalid XML (see example below).
It appears some form of scoping is required, but it's been too long since I've written DTDs for me to propose a robust solution.
Example:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//CODEHAUS/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.codehaus.org/mapping.dtd">
<mapping>
<class name="Foo">
<map-to xml="foo" />
<field name="catalog" collection="map">
<bind-xml name="catalog">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="integer">
<bind-xml name="itemNumber" node="attribute" />
</field>
<field name="value" type="string">
<bind-xml name="itemName" node="attribute" />
</field>
</class>
</bind-xml>
</field>
<field name="personnel" collection="map">
<bind-xml name="personnel">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="integer">
<bind-xml name="idNumber" node="attribute" />
</field>
<field name="value" type="string">
<bind-xml name="name" node="attribute" />
</field>
</class>
</bind-xml>
</field>
</class>
</mapping>
Attachments
Issue Links
| This issue is related to: | ||||
| CASTOR-1862 | Make validation on unmarshalling a mapping file configurable |
|
|
|
Oops... The hyperlink didn't translate right. Try:
http://castor.codehaus.org/xml-mapping.html#3.5-The-<bind-xml>-element