I came across this error when validating XML files against an XSD in Nokogiri.
When validating a complexType XML element, if a node fails validation due to a Occurence restriction, and it is the last node in the complex element, the validation error will not raise, and will pass as a valid document. If there is another node in the sequence that _is_ allowed, then at that point the document will fail validation. However, the error that is thrown is misleading, because it will say that the *second* element is the one that is out of place, rather than the one that is _actually_ out of place.
The easiest way to reproduce this is with xmllint: