[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: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 19 Jun 2015 16:05:20 -0000

On Fri, Jun 19, 2015 at 03:49:50PM -0000, Costello, Roger L. costello@xxxxxxxxx scripsit:
> Hi Folks,
> 
> XML Schema can validate XML instances.
> 
> Schematron can validate XML instances.
> 
> Is there ever a situation where it would be preferable to use XSLT to validate XML instances? 

Schematron _is_ XSLT, in the sense that what Schematron generates and
runs is an XSLT stylesheet.

If you have to validate the whole structure, you want a schema; XSD,
RelaxNG, or other.

If you're trying to check for specific things like date ranges or how
many paragraphs are in a section, Schematron works much better.
Hand-coded XSLT could also work.

(Though I personally prefer XQuery for that purpose.)

It's important to remember that you don't need to do, and maybe
shouldn't do, all your validation in one pass; a "well-formed?", "valid
by the DTD?", "valid by our style rules?" succession of independent
checks can work much better when you're, for instance, checking
externally produced content you're importing.

-- Graydon


Current Thread