I support some complex Java code, and Castor (v1.2) parsing is very slow due to the many βmissingβ Java objects. See, XML contains more fields than I need, but Castor repeatedly tries to instantiate Java objects, causing a lot of ClassNotFound errors.
Castor Map 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 there is no Java equivalent in the color
field, and I don't want it to be unmarshaled. I tried to set org.exolab.castor.xml.strictelements=false
in the castor.properties file, but that does not stop him from walking the class path and throwing ClassNotFound errors.
How can I make Castor skip unnecessary XML elements?
source share