Re: [xsl] Why should I put code in XSLT to check the input data or the output data?

Subject: Re: [xsl] Why should I put code in XSLT to check the input data or the output data?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 20 May 2010 23:06:00 +0100
On 20/05/2010 21:59, Costello, Roger L. wrote:
Hi Folks,

My thinking is that the input data should be checked using XML Schema and Schematron. Ditto for the data that is output by XSLT.

I see no reason to include in an XSLT program any code to check data. It just makes the program bigger, harder to understand, harder to maintain, and harder to debug.

Do you agree?

No, not at all!



/Roger

If by XML Schema you mean XSD, then most of the time I'd rather not use it at all, ever. But even if you include Relax NG or DTD in "XML Schema" it's often preferable to not validate at run time.


A grammar validator (not schematron) is usually just a binary pass/fail.
That's fine if you want to reject invalid documents, but if you test for things in XSLT you can do different code paths and often make correct output out of less than perfect input.


Checking the output makes sense of course, just to check the output, although it depends on the transform, some transforms are guaranteed to produce valid documents, just because the output is sufficiently regular that unless it stops due to some fatal error the result will be valid.

David

Current Thread