Guy,

can you please create a new Jira issue at
http://jira.codehaus.org/browse/CASTOR, and attach all relevant files,
incl. your mapping, domain objects used and a JUnit test case (if possible).

Now if you took care to follow the guidelines available at

http://castor.org/how-to-submit-an-xml-bug.htm

that would make life considerably easier for us.

Regards
Werner

Guy Coleman wrote:
> Hi,
> 
> I'm mapping XML to Java objects using a custom mapping.xml with 1.0.5. I
> have some fields marked as required="true", but the required checks
> don't look like they're happening even with Unmarshaller.setValidate(true).
> 
> I've had a dig through the UnmarshalHandler code and think I have found
> why. In processAttributes(AttributeSet, XMLClassDescriptor) there is
> this code:
> 
>    for (int i = 0; i < descriptors.length; i++) {
> 
>       XMLFieldDescriptor descriptor = descriptors[i];
> 
>       String name      = descriptor.getXMLName();
>       String namespace = descriptor.getNameSpaceURI();
> 
>       int index = atts.getIndex(name, namespace);
> 
> 
>       if (index >= 0) {
>          processedAtts[index] = true;
>       }
>       //-- otherwise...for now just continue, this code needs to
>       //-- change when we upgrade to new event API
>       else continue;
> 
>       try {
>          processAttribute(.....);
>       }
> ...
> 
> If an attribute is missing then index will be -1 and the continue will
> be hit. The call to processAttribute will never happen and this appears
> to be where the required flag is checked.
> 
> I'm not very familiar with the castor code, so it's possible that I'm
> just talking rubbish. I don't have an easily submittable test case for
> this, though I could knock one up if need be.
> 
> Thanks,
> -Guy Coleman
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to