OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Reporting XML validation results in XML: is this approach

[ Lists Home | Date Index | Thread Index ]

From: "Ian Graham" <igraham@ic-unix.ic.utoronto.ca>

> 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.

<schema xmlns="http://www.ascc.net/xml/schematron";>
    <title>Example for Ian</title>

    <pattern>

        <rule context="purchaseOrder/partType">
               <assert test="string-length(normalize-space(substring-after(., '-'))) = 5
            and number(substring-after( ., '-' ))"
            diagnostics="d1" >
            The piece of a partType after the - is should be 5 digits.
            </assert>
        </rule>

        <rule context="purchaseOrder/deliverBy">
            <assert test="number(.) &gt;  number(document('http://dateserver.eg.com/getCurrentDate')/date/.)"
            diagnostics="d2">
            The deliverBy date should be greater than the current date.
            </assert>
        </rule>

    </pattern>

    <diagnostics>
        <diagnostic id="d1">InvalidPartNumber</diagnostic>
        <diagnostic id="d2">dateInPast</diagnostic>
    </diagnostics>

</schema>

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
    <date>20030101</date>
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/

Cheers
Rick Jelliffe




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS