[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] What is the Core of XSLT?


Subject: Re: [xsl] What is the Core of XSLT?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 29 Mar 2014 17:07:42 -0700

On Sat, Mar 29, 2014 at 4:13 PM, Abel Braaksma (Exselt) <abel@xxxxxxxxxx> wrote:
> I don't think you can do everything
> with XSLT 1.0 that you can do now with a subset that does not include
> xsl:if (xsl:choose can be implemented in xsl:ifs).

If I understand this correctly, it says that <xsl:choose> cannot be
implemented if there is no <xsl:if> instruction available.

But it can.

An <xsl:choose> with N outcomes can be expressed in XSLT 2 as a single:

  <xsl:apply-templates select="my:special-node"/>

and N templates of the form:

 <xsl:template match="my:special-node[condition]">

   <!-- The wanted code here -->
 <xsl:template>


In XSLT 1.0 we sometimes can only specify the condition within a
predicate in the "select" attribute of the <xsl:apply-templates>
instruction.

Thus, an <xsl:choose> with N outcomes can be implemented using N
<xsl:apply-templates> instructions of the form:

   <xsl:apply-templates select="my:special-node[conditionK]"/>

and N templates -- exactly as in the case for XSLT 2.0  above.

This is the full proof that XSLT conditional instructions can be
eliminated in any version of XSLT.

BTW, I have quite a lot of experience writing complex transformations
without any XSLT conditional instructions. :)

Cheers,
Dimitre Novatchev


Current Thread
Keywords