[Design of JBossXB] - Re: How to force strict validation?
by rob.stryker@jboss.com
Hey Alexey:
I'm looking at the absolute latest JBoss XB (now, at least), specifically MarshallerImpl vs XercesXSMarshaller.
It is plain to see (IMO) that MarshallerImpl does *not* throw any exceptions if a required attribute is missing. I just ran a test to verify.
I did manage to get one marshaller to throw such an exception (after slight modification). I took the XercesXSMarshaller's and added the following code starting at 695:
| } // end if attrValue != null
| else if( currentAttribute.getRequired()){
| // its required and is not present. Must throw exception
| String name = currentAttribute.getAttrDeclaration().getName();
| throw new JBossXBRuntimeException("Required Attribute " + name + " is not present");
| }
|
Once I made this modification to XercesXSMarshaller, my test passed successfully. After reading your suggestion about MarshallerImpl, I switched to that marshaller, and the exact same test failed to throw any sort of JBossXBRuntimeExcepton of any sort for missing a required attribute.
The test, plainly, is that my schema REQUIRES an attribute (such as "name") and I am trying to marshall an object lacking this attribute.
Since I've found a workaround in my edits to XercesXSMarshaller, I can move forward with my project; but I think some similar functionality needs to be added to MarshallerImpl if you intend for it to replace XercesXSMarshaller.
Hope all's well! Thanks for your help!
- Rob Stryker
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133725#4133725
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133725
16 years, 2 months