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

Subject: Re: [xsl] Reasons for using XSLT to validate XML instances?
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jun 2015 16:22:35 -0000
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 more
>> 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 a
>> collection of XML instance documents. Each instance document contains
>> metadata to indicate which XML Schema should be used to validate it. XSLT
>> 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 choreography.

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

Plus they work great in combination, so why choose?

Cheers, Wendell


-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^

Current Thread