[
https://issues.apache.org/jira/browse/XERCESJ-1713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16915589#comment-16915589
]
Gayithri Rachepalli commented on XERCESJ-1713:
----------------------------------------------
[~mukul_gandhi],
Thanks a lot for your reply.
Yes, we are using XSD 1.0.
I am attaching the sample XML and XSD documents. And the XML looks like this.
<testemployee><middle_name>K</middle_name><last_name>Sharma</last_name><emp_address1>!st
street</emp_address1><emp_address2>3rd
Lane</emp_address2><emp_fax>Faxes</emp_fax><emp_phone>123456</emp_phone><emp_city>LA</emp_city><emp_state>US</emp_state></testemployee>
This is the XML input what we have provided input to the XSD. In this we have
not provided emp_id and first_name.(please look the XSD what i have
attached).This is error we got.
cvc-complex-type.2.4.b: The content of element 'testemployee' is not complete.
One of '\{emp_id, first_name}' is expected.
In this *emp_id* is Mandatory and *first_name* is Non Mandatory fields. But in
the error message both are displaying.
Why non Mandatory fields are displaying in the error message?
It is becoming difficult for our clients if we miss one mandatory field in the
input and if we miss 100 Non mandatory fields(optional fields) in the input,
For the end user to figure out which is mandatory filed out of 101 fields in
the error message.
As we took source code of the XercesJ 2.8.1 of jar and we did analysis on this.
In XMLSchemaValidator.java class is throwing this error,
cvc-complex-type.2.4.b: The content of element ''\{0}'' is not complete. One of
''\{1}'' is expected by calling this whatCanGoHere().
And we saw the implementation of this method in XSALLCM.java class like below.
public Vector whatCanGoHere(int[] state)
{
Vector ret = new Vector();
for (int i = 0; i < this.fNumElements; i++) {
if (state[(i + 1)] == 0) {
ret.addElement(this.fAllElements[i]);
}
}
return ret;
}
So here fAllElements contains Mandatory and Non Mandatory fields. And both are
adding to the Vector. That is reason we are getting both. But we want only
mandatory fields in the error message.
So please help us in this.
And i modified the above method that Not to add Non Mandatory fields to the
Vector. Then we are able to see only Mandatory fields in the error message.,
public Vector whatCanGoHere(int[] state)
{
Vector ret = new Vector();
for (int i = 0; i < this.fNumElements; i++) {
if ((state[(i + 1)] == 0) && (this.fIsOptionalElement[i] == 0)) {
ret.addElement(this.fAllElements[i]);
}
}
return ret;
}
}
But the above is working for if we use <xs:all> in XSD. And we want another
scenario also that , if we use Choice and sequence we are getting Non mandatory
fields error message.
And we understand XSDFACM.java has the implementation for whatCanGoHere()
method like below.
public Vector whatCanGoHere(int[] state)
{
int curState = state[0];
if (curState < 0) {
curState = state[1];
}
Vector ret = new Vector();
for (int elemIndex = 0; elemIndex < this.fElemMapSize; elemIndex++) {
if (this.fTransTable[curState][elemIndex] != -1) {
ret.addElement(this.fElemMap[elemIndex]);
}
}
return ret;
}
Here we are not able to not identify to filter non mandatory fileds in case of
sequence.
Please help with this we want to filter Non mandatory fields in case of
sequence also. We hava many clients waiting for this.
Regards,
Gayithri R
> 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
>
> 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: [email protected]
For additional commands, e-mail: [email protected]