xsl-list
[Top] [All Lists]

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

2014-03-29 19:08:19
On Sat, Mar 29, 2014 at 4:13 PM, Abel Braaksma (Exselt) 
<abel(_at_)exselt(_dot_)net> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>