I am maintaining some complex Java code and the Castor (v1.2) unmarshaling is very slow due to quite a few "missing" Java objects. See, the XML contains more fields than I require but Castor repeatedly tries to instantiate the Java objects, causing lots of ClassNotFound errors.
Castor Mapping File:
<mapping>
<class name="com.example.imaging.product.Product">
<map-to xml="product"/>
<field name="productId" type="long">
<bind-xml name="id" node="attribute"/>
</field>
</class>
<class name="com.example.imaging.product.RegionConfiguration">
<map-to xml="mediaConfiguration"/>
<field name="name" type="string">
<bind-xml name="name" node="attribute"/>
</field>
<field name="design" type="int">
<bind-xml name="designId" node="attribute"/>
</field>
</class>
</mapping>
XML Source:
<?xml version="1.0"?>
<product id="1234">
<productImage colorId="1"/>
<mediaConfiguration name="Front" designId="98765" />
<color id="1" name="Red" default="true"/>
</product>
My problem is that the color
field doesn't have a Java equivalent and I don't want it unmarshaled. I tried setting org.exolab.castor.xml.strictelements=false
in the castor.properties file but that doesn't keep it from walking the classload path and throwing ClassNotFound errors.
How can I make Castor skip over non-needed XML elements?