locked
XML schema validation issue RRS feed

  • Question

  • In case a particular node is mandatory, the error described is for the next sibling. In case there exists a error for the next sibling as well. That error message is supressed. On resolving the first issue, and running the validation again, the second error is thrown. Is there a way we can set options on the schema validation, so that we can receive both errors at the same time.

    For example we have a xml with the following nodes

    <NM101></NM101>

    <NM102></NM102>

    <NM103></NM103>

    Here NM101 is a mandatory node and NM102 has type as integer. In case we receivethe below xml

    <NM102>ABC</NM102>

    <NM103>DEF</NM103>

    Error: The element 'NM1' has invalid child element 'NM102'. List of possible elements expected: 'NM101'

    But the error for NM102 is now supressed and can be retrieved only when NM101 is present. Is there a way that all errors can be reported at the same time ?


    Swapnil Kasodekar
    • Moved by SamAgain Friday, September 3, 2010 3:15 AM better fit (From:.NET Base Class Library)
    Wednesday, September 1, 2010 10:05 AM

Answers

  • Hi, Swapnil:


    There is a reason for the behavior you observed above. There are different types of validation failures, one is for structure validation and one of the other ones is data validations. Structure validation failures will stop firing subsequent validation errors while data type validation will allow subsequent errors.

    In the XML schema validation state machine, it is difficult to continue providing validations after a structure validation failure has occured. It may be obvious in the above example to human eyes, but for the state machine, it cannot easily guess/match the subsequent segment. So it would only repeat the exact error message for all subsequent nodes (expecting NM101) and generate massive useless errors.

    Conceivably an “smart” state machine could be built with the help of some level of fuzzy logic/human intelligence to provide human mind level interpretation and pattern matching so that the best possible accurate errors can be all pinpointed. But the complexity AND potential hit on performance (may require multi-pass for pattern matching) would make it prohibitive to implement and use.

    I hope this answers it. Please let me know if you have any other questions.

    Friday, September 10, 2010 12:08 AM
    Moderator

All replies

  • Hi,

    Thanks for your post. Please consider XML and .NET forum as a better option.


    Please mark the right answer at right time.
    Thanks,
    Sam
    Friday, September 3, 2010 3:14 AM
  • Was your issue solved? If not, can you please show me your schema and xml file? 

    Monday, September 6, 2010 3:32 AM
    Moderator
  • Hi, Swapnil:


    There is a reason for the behavior you observed above. There are different types of validation failures, one is for structure validation and one of the other ones is data validations. Structure validation failures will stop firing subsequent validation errors while data type validation will allow subsequent errors.

    In the XML schema validation state machine, it is difficult to continue providing validations after a structure validation failure has occured. It may be obvious in the above example to human eyes, but for the state machine, it cannot easily guess/match the subsequent segment. So it would only repeat the exact error message for all subsequent nodes (expecting NM101) and generate massive useless errors.

    Conceivably an “smart” state machine could be built with the help of some level of fuzzy logic/human intelligence to provide human mind level interpretation and pattern matching so that the best possible accurate errors can be all pinpointed. But the complexity AND potential hit on performance (may require multi-pass for pattern matching) would make it prohibitive to implement and use.

    I hope this answers it. Please let me know if you have any other questions.

    Friday, September 10, 2010 12:08 AM
    Moderator