The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

User friendly xsd validation messages possible?

My (Java) application validates an .xml document against a schema.  Any errors are passed back to the user in the body of an e-mail.  This works great, except the error messages are just a tad cryptic.  Here is a sample of an error message:

src-element.2.2: The content must match (annotation?) for the element reference 'prefix="",localpart="BarcodeId",rawname="BarcodeId"'. Line(2)

That's not too bad... the user can see it has something to do with the BarcodeId node, but it doesn't say exactly what.  (This particular validation error occurs because the value of the node violates the minLength restriction  facet.) Taking a clue from the (annotation?) thingy, I played around with schema annotations and documentation nodes but (annotation?) still appears in the message.  I searched for a clue on how to handle this, but I found many developers with the same question.

I have control of the schema, if that makes any difference. 

Thanks in advance!
OneMist8k
Monday, February 05, 2007
 
 
btw - the question is, how to get user friendly .xsd/.xml validation messages?
OneMist8k
Monday, February 05, 2007
 
 
Sorry, but that is the problem with XML validation -- it is useless as far as user interface. You should scrap the XSD and just do all the checking yourself in java (which is sometimes more straightforward anyway), and generate user friendly descriptions of the problems.
onanon
Monday, February 05, 2007
 
 
We have this problem and it sucks. In our case the XSD is controlled by an outside vendor. We don't want to rely on the XSD validation because (a) the messages suck and more to the point (b) we dont find out about basic errors until they run it thru their system. So, we end up recreating their entire set of edits in our own code (of which there are dozens, some quite complicated), and hoping we get all the ins and outs exactly right (which we never do).
Greg Send private email
Monday, February 05, 2007
 
 
XML Spy gives very user friendly validation messages
with line numbers and hyperlink to exact position of error in the xml, hyperlink to exact position of the definition in xsd and even a hyperlink to XML Schema rule at w3c.org that was invalidated.
nullptr
Monday, February 05, 2007
 
 
It seems that there are several user friendly desktop applications out there that can provide better messages than what I get out of the box with Java.

For now, I'll have to content myself with the user using one of these applications to get more friendly information about the error.  It would have saved a step to provide it in the rejecting e-mail, but I suppose this is just gold plating the application.  Errors aren't all that common, so it isn't a terrible burden for them to use something like XML Spy once in a blue moon.

Thanks for the feedback.  At least I don't feel alone in this problem!
OneMist8k
Tuesday, February 06, 2007
 
 
I don't know about Java, but in C#, whenever the schema validator throws an exception, the XmlSchemaException object contains everything you'd need to formulate your own error message:  the LineNumber and LinePosition where the error occurred, the SourceSchemaObject containing the rule that got violated, etc.  I'd be surprised if that information weren't available programmatically in Java too.

Sez Greg:

"We have this problem and it sucks. In our case the XSD is controlled by an outside vendor. We don't want to rely on the XSD validation because (a) the messages suck and more to the point (b) we dont find out about basic errors until they run it thru their system."

Why on earth don't you want to rely on the XSD validation?  Granted, the messages may not be especially user-friendly:  they are written with the expectation that the person reading them understands schema validation. 

Operationally, if you have people creating XML documents that have to conform to a schema, and those people don't understand schema validation, you have a problem, and the problem isn't unfriendly error messages.

Sure, it's not going to find every conceivable problem in an XML message.  Schema validation is strictly about message semantics, not business rules.  Even so, validating every XML document you emit through its expected schema before you send it is a basic data-quality test.
Robert Rossney Send private email
Wednesday, February 14, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz