Consider the XHTML document (attached) with an upper-case (thus invalid in XHTML) A element, itself with attributes.
Running it through onsgmls' validation will report:
% onsgmls -s -wxml -wnon-sgml-char-ref -wvalid -c /path/to/xml.soc < uppercase_element.xhtml
onsgmls:<OSFD>0:13:11:E: there is no attribute "href"
onsgmls:<OSFD>0:13:42:E: there is no attribute "title"
onsgmls:<OSFD>0:13:56:E: element "A" undefined
The errors about href and title attribute are actually cascading errors from the fact that their element was not recognized.
I am not entirely familiar with opensp's parsing model, but I suspect it knows which element has just started before starting to parse its attributes. Would it therefore be possible to have the error about undefined element thrown before errors about the attributes?