Re: xsl self-documentation - trace

Subject: Re: xsl self-documentation - trace
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Thu, 29 Jun 2000 09:43:43 -0400
Randall Parker wrote:
> 1) A listing file.
>    The listing file would be the XSLT document that it processed but with a twist: Every line (or maybe every test) would be numbered.
> 2) A numbered match history.

Just ignoring the numbers for a moment.

I was thinking last night that it would be possible to write a
stylesheet that when applied to a stylesheet, generates a "debug"
version of that stylesheet which contains <xsl:message> elements
which print out things like template calls and parameters
received. I'm sure it can be done but I'd hate to have to deal with
all of the namespace bollox.

Here's the kind of code that you might use for named templates -
definitely not tested. Let's say that we use oxsl as the output
XSL namespace, and use namespace-alias for the switch.

<xsl:template match="xsl:template[@name]">
    <xsl:copy-of select="@*" />
    <xsl:copy-of select="xsl:param" />

      <oxsl:value-of select="'Entering template [{@name}]&#xA;'" />
      <oxsl:value-of select="concat('  current node = [', name(), ']&#xA;')" />
      <xsl:for-each select="xsl:param">
        <oxsl:value-of select="concat('  parameter [{@name}]=[',
            ${@name}, ']&#xA;')" />

    <xsl:copy-of select="*[not(self::xsl:param)]" />

Warren Hedley
Department of Engineering Science
Auckland University
New Zealand

 XSL-List info and archive:

Current Thread