Recursion among top-level elements

The XSLT specification (section 12.4) discusses the possibility of cycles
existing among global variable declarations, but it does not seem to deal
with other possibilities for circular definitions.

Example1: there is nothing to stop a global variable definition calling
xsl:apply-templates; and there is nothing to stop the match pattern in
xsl:template referencing a global variable. In general therefore, when
xsl:apply-templates is called within a global variable definition it will be
impossible to determine which template to invoke.

Example2: there is nothing to stop a global variable definition referencing
a key, and there is nothing to stop any of the patterns in a key definition
from referencing a global variable.

I don't think it will be possible to fix these problems without some fairly
severe limiting of the current freedom to define things in any order.

Many of the problems could be solved by a ban on forwards references, e.g. a
global variable definition can only refer to a global variable, named
template, attribute set, or key that has been previously declared in the
stylesheet.

The problem with xsl:apply-templates remains: I think it is necessary either
to stop template match patterns referring to global variables, or to stop
global variable definitions invoking xsl:apply-templates.

Mike Kay

Received on Tuesday, 3 August 1999 08:49:21 UTC