xsl-list
[Top] [All Lists]

[xsl] Perfomance: 'conditional instruction' vs. 'multi template'

2012-11-03 10:24:20
Hi everybody,

if a node is to be processed differently, depending on a certain 
condition, there are two approaches.

Let's say, the condition is "existance of child x".


Approach 1: two templates with different matching XPaths

<template match="thenode[child::x]">
  … do_this …
</template>

<template match="thenode[not(child::x)]">
   … do_that …
</template>


Approach 2: one template with a conditional instruction

<template match="thenode">
  <xsl:choose>
  <xsl:when test="x">
    … do_this …
  </xsl:when>
  <xsl:otherwise>
    … do_that …
  </xsl:otherwise>
</xsl:choose>
</template>


I wonder, if one of these approaches is to be favoured?
Are there any severe implications on performance?
Any other advantages / disadvantages that speak in favour of approach 1 
or approach 2?

I am curious to read your estimations,
Norbert

--~------------------------------------------------------------------
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>
--~--