[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Reasons for using XSLT to validate XML instances?

Subject: Re: [xsl] Reasons for using XSLT to validate XML instances?
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jun 2015 16:39:26 -0000

I'm not sure it helps to call the validation operation a
"transformation"--it's clearly a more general data processing activity
that can be implemented using transformation technology (that is, systems
optimized for doing transformation). But complete validation, including
checking of population constraints, could involve very deep heuristics
that go beyond what languages like XSLT or XQuery or SPARQL are intended
to support effectively.

I think it's useful to see that transformers can be used for validation
but I'm not sure it's useful to say that validation is transformation. My
fear is that that might limit the types of processing people consider to
be validation.

There are basically three levels of validation in the context of XML or
similar complex structured data:

1. Validation against declarative constraints that can be checked with a
minimum of lookahead, e.g., DTD, RELAXNG, XSD without assertions, etc.
This type of validation is fast and the grammars used are relatively easy
to define (mostly because they purposely omit expressive features that
would make writing them much harder).

2. Validation against patterns that can be easily checked with something
like XPath expressions but cannot be easily expressed in purely
declarative constraint languages, e.g., simple Schematron and XSD 1.1
assertions. Transformation languages like XSLT and XQuery are optimized
for the implementation of this type of validation.

3. Validation against arbitrary business rules of any sort, including
complex population constraint checking, consideration of transient system
states ("must be a full moon day and not the 2nd full moon in the month"),
etc. This type of validation can only be done using crafted procedural
processing and, I think, falls outside the scope of what we normally think
of as "transformation" (although, of course, it can always be implemented
using complete languages like XSLT or XQuery if you want to, but it might
always be easy, efficient, or maintainable).


Eliot Kimber, Owner
Contrext, LLC

On 6/24/15, 11:22 AM, "Wendell Piez wapiez@xxxxxxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

>Hi again,
>On Wed, Jun 24, 2015 at 11:27 AM, G. Ken Holman g.ken.holman@xxxxxxxxx
><xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>> Could you add the observation that validation (in general) is simply a
>> transformation of an XML document into a "pass/fail against constraints"
>> result?  For XSD, validation is also a transformation of an XML document
>> into a PSVI, though one doesn't see that if they are just looking for
>> pass/fail.
>Indeed, this is an important point, as I also tried to imply by
>stressing the "what do *you* mean by validation" question.
>I can't remember who observed it first in public but it might have
>been Ken or Eric van der Vlist? validation is just a query returning a
>Boolean result. Of course processing pipelines such as XSD
>implementations do more than this (with their partial validations,
>PSVIs and so forth).
>As to Roger's examples:
>>> There are validation problems that are more easily solved using XSLT.
>>> Whether one validation approach is easier or harder is subjective.
>>> Nonetheless, here are a couple validation problems that are arguably
>>> easily solved using XSLT:
>>> 1. In a collection of XML documents, validate that the value of each
>>> <name> element is unique.
>Well XSLT and XQuery are perfectly equivalent, I'd say, for these
>purposes, but it can be done with no more difficulty, really, in
>Schematron, which as has been noted, is also just an XSLT wrapper for
>these purposes.
>>> 2. Consider a test suite consisting of a collection of XML Schemas and
>>> collection of XML instance documents. Each instance document contains
>>> metadata to indicate which XML Schema should be used to validate it.
>>> can be used to consult the metadata and then launch the appropriate XML
>>> Schema.
>That's not a validation, that's a transformation in service of
>Why would I use XSLT for validation? In practice, I think the reasons
>are more around the edges (that is, having to do with operational
>context, not validation per se) than they are the functional
>Plus they work great in combination, so why choose?
>Cheers, Wendell
>Wendell Piez | http://www.wendellpiez.com
>XML | XSLT | electronic publishing
>Eat Your Vegetables

Current Thread