Re: [xsl] Strict sequential identity rule?

Subject: Re: [xsl] Strict sequential identity rule?
From: Evan Lenz <evan@xxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 15:00:43 -0700
Hi Dimitre,

As a consequence, I think that it would be very helpful to have in
XSLT facilities, which provide warning diagnostics whenever a built-in
template rule is invoked, or to turn off built-in template rules at
all. There is something like this in XSelerator.

I'm addressing questions like these in my own independent research project in software visualization for XSLT. I am (naturally) using XSLT to implement as much of this as it makes sense to.

So far, I am working with the underlying data model: an XML format for the entire execution profile of a stylesheet and a particular input document.

Once the idea gelled for me, it was pretty quick and easy (and fun!) to implement. I just pre-process the stylesheet, adding a bunch of instructions to output trace information into the result tree. When you run the pre-processed stylesheet against some input document, the result is a complete report of every rule that was invoked in the stylesheet, in the hierarchy in which it was executed. I think this could be a lightweight but tremendously handy debugging tool in and of itself. But I resisted the temptation to get too distracted by the immediate convenience of the format. My goal is to create data to visualize, not data to view directly as XML.

Anyway, the question arose of how to add trace info for the built-in template rules. It's pretty easy actually.

Just add an import at the top of the stylesheet:

<xsl:stylesheet ...>

   <xsl:import href="built-in.xsl"/>
   <!-- of imports... -->


The built-in rules are always overridden by any explicit template rules in the original stylesheet. Thus, I add them explicitly but as the first import, before anything else, so that they have the lowest import precedence. The resulting behavior of the stylesheet (apart from the additional trace info) is the same as if I didn't add this import.

And since there are an infinite number of built-in template rules (for as many modes as you have), I also need to autogenerate the built-in.xsl stylesheet too, adding explicit rules for each mode that is used in the stylesheet.

Evan Lenz

Current Thread