RE: conditionals not allowed at top-level

> Conditional XSLT elements like <choose> and <if> are not currently
> allowed as direct children of <stylesheet>.  I'm writing to request
> that this restriction be relaxed.
>
> I wonder if there is any particular reason for this restriction.  It
> seems to me that there are several top-level elements which one might
> like to conditionalize, though there are others which the processor
> might find difficult to treat conditionally (e.g. <template>).

A personal response: I think it would be very hard to define consistent and
predictable semantics for this. <xsl:if> can invoke general XPath
expressions and XSLT templates, which can make arbitrary access to variables
and to the source document and can generate nodes on the result tree; it's
not possible to do this earlier than resolving xsl:include and xsl:import,
computing global variables, or assembling the full list of template rule
match patterns.

The specific requirement to parameterize the attributes of xsl:output is
addressed by allowing these values in the XSLT 1.1 working draft to be
attribute value templates.

There is a valid requirement, I think, for "compile time parameterization"
of stylesheets. Some projects solve this by generating stylesheets from some
higher-level representation: the fact that XSLT is encoded in XML makes it
straightforward to do this. Perhaps someone could standardize this approach,
creating in effect a set of preprocessor instructions rather like ifdef's in
C. I don't think this is a priority for the XSL WG, though.

Mike Kay

Received on Saturday, 28 April 2001 07:21:28 UTC