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

Subject: Re: [xsl] Reasons for using XSLT to validate XML instances?
From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jun 2015 15:26:53 -0000
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.

That way both XSD and XSLT can be viewed as transformation technologies, perhaps making it easier to comprehend your reasonings for those who think XSLT isn't appropriate for validation.

. . . . . . . Ken

At 2015-06-24 14:20 +0000, Costello, Roger L. costello@xxxxxxxxx wrote:
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.



--
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Free 5-hour lecture:  http://www.CraneSoftwrights.com/links/video.htm |
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/x/ |
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile:       http://plus.google.com/+GKenHolman-Crane/about |
Legal business disclaimers:     http://www.CraneSoftwrights.com/legal |


--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Current Thread