Re: [xsl] How do you prove that your XSLT programs are correct?

Subject: Re: [xsl] How do you prove that your XSLT programs are correct?
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Apr 2022 13:46:41 -0000
Hi,

What's more, Mike doesn't even touch on the question of defining what is
correct, or for that matter how one of XSLT's great strengths is in its
capability to handle things that are incorrect by one definition while
correct by another.

But yes, unit testing. It is not only the only way to know, it is the only
way to know you really know.

Cheers, Wendell

On Thu, Apr 14, 2022 at 12:52 PM Michael Kay mike@xxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> You're not talking about proving correctness here, you're talking about
> testing.
>
> If you want to prove properties of the stylesheet statically, for example
> that the output will conform to a particular schema, then consider writing
> schema-aware XSLT code. (However, I'm very reluctant to talk about proviing
> "correctness". You can prove a hypothesis about the behaviour, but you
> can't prove that such behaviour will be considered "correct" in the real
> world.)
>
> For testing, XSpec is a popular framework, which roughly does what you
> describe in (2). This is also how the W3C XSLT test suite at
> https://github.com/w3c/xslt30-test works. (That test suite, of course, is
> geared more to coverage of constructs in the XSLT language, so the details
> will be rather different from tests of a user stylesheet, but the principle
> is much the same.)
>
> The biggest weakness I see in the way most users test their stylesheets is
> that they use far too few different source documents to achieve good
> coverage of the logic, especially the error cases.
>
> Michael Kay
> Saxonica
>
> > On 14 Apr 2022, at 17:08, Roger L Costello costello@xxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > Hi Folks,
> >
> > Scenario: You write an XSLT program that takes some input and outputs
> XML. You want to be sure that your XSLT program is correct.
> >
> > As I see it, there are two ways to help ensure the correctness of an
> XSLT program :
> >
> > 1. Pepper the XSLT program with assert statements, using xsl:assert.
> >
> > 2. Create a second XSLT program that queries the XML that was generated
> by the first XSLT program. This second XSLT program contains a series of
> XPath expressions to check various parts of the XML.
> >
> > Which of those do you use? Or do you use both? Or do you use something
> else?
> >
> > How do you ensure the correctness of your XSLT programs?
> >
> > /Roger
> >
> >
> 
>
>

-- 
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...

Current Thread