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

Subject: Re: [xsl] Reasons for using XSLT to validate XML instances?
From: "Costello, Roger L. costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jun 2015 14:20:12 -0000
Hi Folks,

Thank you very much for your excellent responses!

Below is a summary of your responses. I welcome further additions and edits.

-----------------------------------------------
      Niche for XSLT Validation
-----------------------------------------------
XSLT can be used to validate XML instance documents. However, there already
exists standards-supported XML validation technologies: XML Schema and
Schematron (and others). Whenever possible, XML Schema and Schematron should
be used for validation.

Is there a niche for XSLT validation? Are there validation problems that only
XSLT can solve?

XML Schemas can validate only one XML document, it cannot validate across XML
documents. XSLT can operate on multiple XML documents, so perhaps
cross-document validation is a niche that only XSLT can fill? Not so, as
Schematron can validate across documents.

Here are two validation problems that can only be solved using XSLT
validation:

1. Customized validation report: XSLT can validate and generate a customized
validation report.

2. Filtered result: As XSLT performs validation on an XML instance document it
can eliminate the parts that are invalid.

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.

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.

Current Thread