Subject: [xsl] When to use conditional constructions?|
From: David Rudel <fwqhgads@xxxxxxxxx>
Date: Sun, 30 Mar 2014 14:25:58 +0200
On Sun, Mar 30, 2014 at 1:07 AM, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote: > 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 > Dimitre, as typical, your posts are very insightful. I'm now wondering how much I should consider avoiding conditionals in my own work. This provoked a general question I have for experiences XSLT programmers who frequently use <xsl:apply-templates> or some other method to avoid what would normally (in a more imperative regime) be done using conditional constructions. Have you found that, in general, it is best to avoid conditional constructs? If so, could you share what advantages you have found by doing so? Does this behavior extend to XPath's "if" statement as well, or do you see that as a different beast? (In other words, do you find that the advantages you obtain by avoiding XSL's conditionals do not apply as much when considering cases that can be addressed using XPath instead?) Are there specific cases where conditional constructs should be favored? (E.g., in <xsl:iterate> to allow Tail Call optimization?) As I have confessed in the past, for my work the thing I value most about XSLT is its support of XPath. I still tend to use imperative programming, so my scripts tend to look like the XSLT equivalent of a Java program that uses a single class. -David -- "A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.