Re: [xsl] Managing debug logging in complex transforms: what do people do?

Subject: Re: [xsl] Managing debug logging in complex transforms: what do people do?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 24 Mar 2014 18:42:24 +0000
On 24 Mar 2014, at 17:31, Eliot Kimber <ekimber@xxxxxxxxxxxx> wrote:

> For whatever reason I find using interactive debugging unhelpful for
> debugging XSLT processing (but I couldn't code a line of Java without it).

That's my experience too, I have never been sure why the difference.
> Thus I depend very heavily on debug messages in my XSLTs. I used to just
> emit messages and then comment them out or delete them when I was done,
> but then I found myself recreating those messages when I had to return to
> that bit of code.
> Then I started using a runtime parameter to turn debugging on or off
> globally and using IF checks to output my messages. But that results in a
> lot of messages when you've got a lot of debug messages, most of which are
> not relevant to your current problem, so back to commenting things out or
> disabling the IF check (e.g., test="false() and $doDebug").

There are two things in XSLT 3.0 designed to make this easier: xsl:assert, and
static variables/parameters

xsl:assert is like xsl:message wrapped in an xsl;If.

Static variables can be used in conjunction with xsl:use-when effectively as
an "ifdef", that is a compile-time conditional. So rather than commenting code
out, you tag it with use-when="$DEBUG".

Michael Kay

Current Thread