[ https://issues.apache.org/jira/browse/XERCESJ-1713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16915677#comment-16915677 ]
Mukul Gandhi commented on XERCESJ-1713: --------------------------------------- I agree with you that, there's scope of improvement with the error message as per example you've cited. At this time, I can provide a workaround to your issue, using XSD 1.1. Here's what the relevant portion of your XSD (1.1) document should look like, <xs:complexType> <xs:all> <xs:element type="EMPID" name="emp_id" minOccurs="0"/> <xs:element type="FIRSTNAME" name="first_name" minOccurs="0"/> <xs:element type="MIDDLENAME" name="middle_name" minOccurs="0"/> <xs:element type="LASTNAME" name="last_name" minOccurs="0"/> <xs:element type="ADDRESS1" name="emp_address1" minOccurs="0"/> <xs:element type="ADDRESS2" name="emp_address2" minOccurs="0"/> <xs:element type="FAXES" name="emp_fax" minOccurs="0"/> <xs:element type="PHONE" name="emp_phone" minOccurs="0"/> <xs:element type="CITY" name="emp_city" minOccurs="0"/> <xs:element type="STATE" name="emp_state" minOccurs="0"/> </xs:all> <xs:assert test="emp_id"/> <xs:assert test="middle_name"/> <xs:assert test="emp_phone"/> <xs:assert test="emp_city"/> <xs:assert test="emp_state"/> </xs:complexType> Following is the idea on which above XSD fragment is based on, Within <xs:all>, we need to specify all elements as 'non mandatory'. Then using XSD 1.1 <assert>'s, we need to specify which of the elements are mandatory. The <assert> failures would make it clear, which elements are mandatory. To customize <assert> failure messages, Xerces provides an optional extension, as described here, [http://xerces.apache.org/xerces2-j/faq-xs.html#faq-4.|http://xerces.apache.org/xerces2-j/faq-xs.html#faq-4] > 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