[ https://issues.apache.org/jira/browse/XERCESJ-1713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16918521#comment-16918521 ]
Mukul Gandhi commented on XERCESJ-1713: --------------------------------------- I've been thinking about this bug report, and following are my thoughts as of now. As per your use case, lets say that, we have following (reduced version of yours) XSD document fragment, <xs:element name="testemployee"> <xs:complexType> <xs:all> <xs:element type="EMPID" name="emp_id" minOccurs="1"/> <xs:element type="FIRSTNAME" name="first_name" minOccurs="0"/> <xs:element type="LASTNAME" name="last_name" minOccurs="0"/> </xs:all> </xs:complexType> </xs:element> And the XML document that's validated is following, <testemployee> <first_name>mukul</first_name> </testemployee> For the above mentioned example, Xerces produces following XSD validation outcome, cvc-complex-type.2.4.b: The content of element 'testemployee' is not complete. One of '{emp_id, last_name}' is expected. You're saying that, the error message should only mention mandatory elements. I don't think that, this is necessarily a good idea every time. Following are my thoughts, If you only trust the error message, and have no knowledge about the XSD schema that you used, I think this is not good. Lets say that, for above validation scenario, instead of the error message "One of '{emp_id, last_name}' is expected", the error message said, "One of '{emp_id}' is expected" (the fix you desire), then the user would be taught that, only mandatory elements make sense for the user, and optional elements are not important (but I think, optional elements are important as well and its ok if the error message mentions them as well). Upon above mentioned XSD validation failure, other than the error message (to learn what is missing), the user should also consult the XSD schema document to learn what is wrong with the XML document that was validated. You wrote that, the Xerces error message is less useful when the number of elements in <xs:all> are large and many of them are optional. But Xerces has to serve the opposite case as well, i.e when number of elements in <xs:all> are less (as in the XSD example I've cited above). For this, I think Xerces does fine, as I've tried to explain above. As of now, I'm of the opinion that, your arguments for fixes as per this Jira issue doesn't generalize well. i.e we shouldn't go for the fix. > Displaying the One of Error message with Mondatory and NonMandatory Fileds > With Java xercesImpl-2.8.1 Jar File > -------------------------------------------------------------------------------------------------------------- > > Key: XERCESJ-1713 > URL: https://issues.apache.org/jira/browse/XERCESJ-1713 > Project: Xerces2-J > Issue Type: Bug > Reporter: Gayithri Rachepalli > Priority: Major > Attachments: TestEmployeeXSD.xml > > > We are using XxercesImpl-2.8.1 jar file to validate the XML payload against > defined XSD. > Whenever the schema validation is failed we are not getting proper exception. > Below is the examples for the same. > Consider the scenarios we are passing 10 fields in XML payload where we have > 5 fields are mandatory and other 5 fields are non-mandatory. We are only 3 > mandatory fields in XML payload. > 1. We are using <all> its validated and throws the message for all the files > including mandatory and non-mandatory. As shown below > *<rsp:DESCRIPTION>Payload validation error. Cannot process request - > SpecValidationError: Failed to pass spec validation: InvalidDataError: for > record\ncvc-complex-type.2.4.b: The content of element 'EMPLOYEE' is not > complete. One of ' > {EMPID, FIRSTNAME, MIDDLENAME, LASTNAME, ADDRESS1, ADDRESS2, FAXES, PHONE, > CITY, STATE} > ' is expected. </rsp:DESCRIPTION>* > But here only first 5 fields are mandatory and we are passing first 3 values > but it is showing all fields > 3. Is there any way to display only missing fields in the exception message? -- This message was sent by Atlassian Jira (v8.3.2#803003) --------------------------------------------------------------------- To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: j-dev-h...@xerces.apache.org