0

I am getting an error when i validate my XML against the XSD and I Cannot figure out the reason.

"The Error is that an element is not allowed under another element as other elements are expected at the location."

The error snapshot is at https://i.stack.imgur.com/nZDMW.jpg

The XML and XSD are at http://dpaste.com/2933QH8 and http://dpaste.com/16QAQ6B respectively.

Interestingly, another XSD works fine.There is not much difference between the two schemas. Here is the schema against which the XML validates fine. http://dpaste.com/233S87T

Its as if the minOccurs directive is ignored but I am not able to figure out why.

Appreciate some guidance.

Guddu
  • 1,588
  • 4
  • 25
  • 53

1 Answers1

1

As the error says DistroSeqNumber is unexpected. That is because DistroSeqNumber must always appear after the OriginalPickticketQty element (it has minOccurs=1). So, the parser it's expecting an OriginalPickticketQty element or one of the optionals elements, but its not expecting a DistroSeqNumber element still.

Notes: (maybe you already know it..) your OriginalPickticketQty has an attribute default=0, have in mind that this means that if no value its provided for a OriginalPickticketQty element (<OriginalPickticketQty></OriginalPickticketQty>), then the value 0 will be automatically assigned, but that doesn't mean that if the element doesn't appears in the XML it's automatically added with a 0 value.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
sergioFC
  • 5,926
  • 3
  • 40
  • 54
  • Thanks SergioFC. That helped a lot. – Guddu Aug 28 '14 at 04:18
  • You're welcome. P.S.: I have noticed that in my answer there are an empty parentheses pair, but if you click the edit button of my answer you'll see that the content inside the parentheses is ** (a *OriginalPickticketQty* element with no value provided). – sergioFC Aug 28 '14 at 06:03
  • SergioFc . . . Is there a way to get directly to the details of the missing mandatory elements instead of the validator indicating dozens of other fields which are optional and thereby confusing the user? – Guddu Aug 28 '14 at 15:25
  • I'm not sure if I understand your question (I'm not a native English speaker). If you're talking about getting a different error messege I don't think it's possible unless the Validator has a specific option for that (which I doubt). We have to think in the validator as a State Machine: when the validator has read a `DistroSeqNumber` element it enters in a State where it's expecting one of the elements being reported. If it had found one of those optional elemnts, the new State would be correct, so if an error occurs it has to indicate which elements it was expecting even they are optionals. – sergioFC Aug 28 '14 at 15:50
  • @Guddu Anyhow, if the list of elements the validator was expecting its too long, looking at the last element reported in the error could be a good practice to found errors. – sergioFC Aug 28 '14 at 15:53
  • Unfortunately, the error shows up without any particular ordering of the list. I am using Altova XML Spy and Notepad++ XML Tools Plugin and both just report something generic and there is no way to get to the real culprit TAG withou going through each one of them one by one. Attached is complete error Text. http://imgur.com/A8KI35U . . . There must be some way or some other tool to get around this problem in error reporting. – Guddu Aug 28 '14 at 17:04
  • Desafortunadamente, el error se muestra sin ningún orden particular de la lista de los Tags. Estoy usando Altova XML Spy y el Bloc de notas ++ con XML Tools Plugin y ambos sólo informan algo genérico y no hay manera de llegar al TAG verdadero con error sin tener que pasar a través de cada uno de ellos uno por uno. Se adjunta texto completo del error. imgur.com/A8KI35U. . . Debe haber alguna manera u otra herramienta para solucionar este problema en el informe de errores. – Guddu Aug 28 '14 at 17:07
  • In windows I usually use Oxygen Validators to validate XML Schema against XML documents, but I tested your XML Schema and XML with this [online validator](http://www.utilities-online.info/xsdvalidation/) because I was in Linux Mint, and the list of elements the validator is expecting seems to be reported in order (meaning order of appearance in the XML Schema). – sergioFC Aug 29 '14 at 08:42
  • And so, in cases like this, the last is *"the real culprit TAG"*. – sergioFC Aug 29 '14 at 08:43