You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Bob Caverly <bc...@hns.com> on 2004/12/21 21:30:52 UTC

How to mimic Castor functions setIgnoreExtraAttributes and setIgnoreExtraElements

I am working on a project currently using Castor to provide the XML 
handling.  The Castor objects are used in the context of a framework which 
provides various marshal and unmarshal methods.  These methods take 
advantage the following castor functions to provide a limited degree of 
backward version compatibility (i.e. new/extra non-mandatory elements and 
attributes in a schema will be ignored if parsed by an older version of 
the receiving application)


 void
setIgnoreExtraAttributes(boolean ignoreExtraAtts) 
          Sets whether or not attributes that do not match a specific 
field should simply be ignored or reported as an error.
 void
setIgnoreExtraElements(boolean ignoreExtraElems) 
          Sets whether or not elements that do not match a specific field 
should simply be ignored or reported as an error.

I want to provide a new implementation of this framework which is based on 
XmlBeans but I need to modify the "unmarshal" methods in such a way as to 
preserve this functionality.  Castor (in our usage) always validates upon 
marshaling or unmarshaling so my intent was to call the validate() after 
unmarshaling an XML source and then step through any errors received to 
determine whether they are 'real' problems or just 'extra' stuff.

I have coded the unmarshal method to get an ArrayList of errors but I can 
not figure out how to discern (easily and reliably) whether a given error 
represents a real validation problem I need to handle or an "extra" 
element/attribute I can ignore.

Any help, pointers to documentation, etc. will be much appreciated.

Thanks,
Bob

_______________________
Bob Caverly
Principal Internet Architect
Hughes Network Systems
301-428-2797
bcaverly@hns.com