This is a bit long, but I wanted to be fairly complete. Sorry if it's a repeat, but I didn't see anything obvious in Bugzilla or in the list archives.

I've run into an issue in an application where I'm using XML marshalling/demarshalling in version 0.9.5. I'm trying to use pure introspection with no predefined mapping file

One of my objects has a field (call it 'messageDetail', xml name 'message-detail') of type Object. The introspection code in Introspector.java causes this fields XMLFieldDescriptorImpl to include the wildcard in its match list:

        if (type == java.lang.Object.class) {
            fieldDesc.setMatches(xmlName + " *");
        }


Naturally, I have a number of other fields in this object. I've run into an issue where one of these other fields (call it 'eventTime', xml name 'event-time', type Date) gets matched to the descriptor for 'message-detail'. This causes a few problems, the first symptom being that Castor reports that event-time has been seen multiple times.


Tracking through the code, I found this snip in XMLClassDescriptorImpl's getFieldDescriptor method (edited/elided to minimum for discussion):


for (int i = 0; i < elements.length; i++) { XMLFieldDescriptor desc = elements[i];

                if (desc.matches(name)) {
                      if (!desc.matches(WILDCARD)) return desc;
                      result = desc;
                      break;// <-----
                }

                //'handle container' if statement snipped...
            }

            if (result != null)
                return result;
        }

Basically, this is causing the first 'match' field descriptor to always be returned, even if it is a wildcard and there is a later exact match. Simply commenting out the 'break' pointed to by my lovely little arrow enabled my system to function properly. I don't know the castor code well enough to say that that's the real fix, however.

Thanks,
danch

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




Reply via email to