Lists Home |
Date Index |
From: "Ian Graham" <firstname.lastname@example.org>
> Of course you're right that XPAth's won't work if the document is not well
> formed: but I'm more interested in the case where it is well formed, and
> where I want the error report to be somehow positioned in the 'business
> layer' of the application as defined by the messages, rather than at the
> mid-level layer of schema validation. That is, I'd like the XML error
> report to make sense from the application's business context -- and
> hopefully be understandable to a business analyst reading response
> messages, and potentially the business developer writing code.
This is pretty much where Schematron can fit in. Here is a (complete but
untested) schema for your example.
<title>Example for Ian</title>
<assert test="string-length(normalize-space(substring-after(., '-'))) = 5
and number(substring-after( ., '-' ))"
The piece of a partType after the - is should be 5 digits.
<assert test="number(.) > number(document('http://dateserver.eg.com/getCurrentDate')/date/.)"
The deliverBy date should be greater than the current date.
In Schematron you can associate any assertion with a diagnostics section.
This can contain additional information for an application to use. In this
case it is just your error type.
The current date could come from some function, but instead here we
let it come from some web server which returns an xml file
This will only work on the ISO 8601 date format with no decorations,
treated just as a number.
> I admit this is a lot of half-baked thoughts in one letter, but there
> seems to be something interesting in here ....
In order to generate the error format you want, you only need to customize
the schematron 1.5 skeleton program: this already provides a template
to generate the Xpath for a particular error, etc (thanks to Francis Norton
and others), so you are 90% there. If you are using Windows, my company provides
a free drag-and-drop shell (Topologi Schematron Validator), which will make
development and testing easier. http://www.topologi.com/