[dsdl-discuss] Possible Schematron extension: traverse links and validate document at other end

From: Rick Jelliffe <rjelliffe@allette.com.au>
Date: Wed Apr 04 2007 - 11:40:47 UTC

Here is an idea for an extension to Schematron that fills a current gap.
Has anyone had a need for this, or would it allow people to do things
they would have liked to have been able to do (phew)?

The idea is to have a kind of assert that instead of @test has @traverse
(or some better name) which takes an XPath what returns a URL (with
fragment indicator?) and then starts to validate that URL's document (or
fragment) using the same schema.

So if we have a document with

  <people>
        <personref xlink:href="http://blahbah"/>
           ...
  </people>

we can have a schema with

  <rule context="personref">
        <assert traverse="@xlink:href" phase="validatePerson">A
personRef is an XLink</assert>
 </rule>

Now to implement the traversal is trivial, I think. Just generate
something like
    <axsl:apply-templates select="{concat('document(', @xlink:href,')'
)}" />
If we allowed fragment indicators ( http://blahblah#blah ), it would not
be particularly more difficult.

But if we want to select a phase as well then the skeleton algorithm has
to be changed a little: at the moment unused patterns are stripped out
from the generated stylesheet. We would just have to something a little
smarter with modes I guess so that phase selection was a runtime thing.

This would give use the ability to validate hub documents, and tie in
with XLinks better. Also, the current trouble with using document()
inside assertions is that there is no HTTP fail handling. An actual
element to do this might be useful too.

==================== Further use====================
An extension of this might be that if the traverse is empty (and if the
phase allowed other patterns except the current one to prevent
circularity) then the same mechanism could allow context-keyed phase
invocation. This is what an empty @traverse would allow.

This could even be used to tailor the phase from an outside document.
  <rule context="/[document('nextPhase.xml')/phase = 'person' ]">
        <assert traverse="" phase="validatePerson">The selected phase is
validate person.</assert>
 </rule>
That is not so interesting, but I guess you could have more complicated
rules where you query the web based on values in the document to see
which kind of validation to be performed. Such as

  <rule context="person[document(concat('security.xml?name=',
@name)/risk = 'high' ]">
        <assert traverse="" phase="validateHighRiskPerson">Validate high
risk people in high risk mode .</assert>
 </rule>

This allows the separation of data (e.g. the person) from metadata (e.g.
their risk).
========================================

Reaction?

Cheers
Rick

--
DSDL members discussion list
To unsubscribe, please send a message with the
command  "unsubscribe" to dsdl-discuss-request@dsdl.org
(mailto:dsdl-discuss-request@dsdl.org?Subject=unsubscribe)
Received on Wed Apr 4 13:41:24 2007

This archive was generated by hypermail 2.1.8 : Wed Apr 04 2007 - 13:03:02 UTC