The mapping of an xml document to a java object model does not seem very
difficult, although I have run into some issues. The problem is setting up
castor so that it will ignore unused xml elements when it tries to map to
the object. One could create mappings of all unwanted elements to a dummy
object, but that seems rather inefficient. There is a workaround for
ignoring single elements that can be placed in the mapping descriptor file:
        <!-- workaround to ignore unmatched elements -->
        <field name="anything"
               type="string"
               get-method="toString"
               transient="true">
            <bind-xml node="element" matches="*"/>
        </field>
Unfortunately, this does not work for ignoring repeating elements. This
manifests as a problem with the accessor methods because repeating elements
need to be mapped to a collection type while single elements use a string in
the workaround. The workaround works because it uses the regular expression
* to match all elements that are not mapped, but how would you specify a
different mapping field for repeating elements?

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to