W3C home > Mailing lists > Public > xsl-editors@w3.org > April to June 2001

XSLT 1.0 clarification request: xsl:apply-imports in an included template

From: Michael Kay <mhkay@iclway.co.uk>
Date: Thu, 10 May 2001 14:07:21 +0100
To: <xsl-editors@w3.org>
Message-ID: <006f01c0d952$2721b500$ab393c3e@PCUKMKA>
By coincidence, two people (one of them Norman Walsh) have today raised the
same issue, quarrelling with Saxon's reading of the specification of

The problem is illustrated as follows:

<xsl:import href="third.xsl">
<xsl:include href="second.xsl">

<template match="book">

<template match="book">

With Saxon, the xsl:apply-imports does not invoke the template rule in
third.xsl. With MSXML3, apparently, it does.

What the spec actually says is that "xsl:apply-imports processes the current
node using only template rules that were imported into the stylesheet
element containing the current template rule".

The term "current template rule" is well-defined, but "stylesheet element"
and "imported into" are open to interpretation. I interpret "stylesheet
element" to mean "an xsl:stylesheet element", or what in my book I call a
stylesheet module. I interpret "imported into" to mean that the template
rule must be in a stylesheet module that was either imported directly into
this module using an <xsl:import> element in this module, or that was
"imported into" a stylesheet module that was "directly imported" or
"directly included" into this module. In other words, a module in the
include/import subtree rooted at the current module, that has lower import
precedence than the current module.

In this situation, on my reading of the spec, the template rule in
"third.xsl" is not "imported into" the stylesheet module containing the
template rule in "second.xsl".

But Norm points out that the description of xsl:include says:

  ...and the children of the xsl:stylesheet element in this document
  replace the xsl:include element in the including document. The fact
  that template rules or definitions are included does not affect the
  way they are processed.

Which could be read as overriding the rules given under xsl:apply-imports,
to say that a template rule that is included into a stylesheet module
behaves exactly the same as if the template rule were part of that
stylesheet module.

My own view is that the specific rule for xsl:apply-imports, which says it
depends on which module it's in, takes precedence over the general rule
under xsl:include, which says it doesn't.

(This is one of a number of cases where rules given in one part of the
document can be read as contradicting an explicit statement made elsewhere,
without saying which takes precedence. We must try to avoid this practice!)

A ruling please!

Mike Kay
Received on Thursday, 10 May 2001 09:04:55 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:44:21 UTC