On 16/06/2014 13:19, Kerry, Richard richard(_dot_)kerry(_at_)atos(_dot_)net
wrote:
And just to be clear, I am asking about XSLT1.
(I am doing DocBook transformations and am trying to parse dates as strings)
......
<xsl:template name="test.1">
<xsl:param name="string" select="''"/>
<xsl:if test="$check.1 = 0">
<xsl:value-of select="$value.1" />
</xsl:if>
<xsl:if test="$check.2 = 0">
<xsl:value-of select="$value.2" />
</xsl:if>
<xsl:if test="$check.3 = 0">
<xsl:value-of select="$value.3" />
</xsl:if>
<xsl:value-of select="$value.4" />
</xsl:template>
The <xsl:choose><xsl:when><xsl:otherwise> construct is probably most
appropriate for cases where the scope of the conditionality is very
localised (and would involve not just patterns on the context item, as
in this case where you have variables). It also has the benefit of a
strict and explicit test-precedence order.
In cases where the conditionality is much more based on conditions
pertaining to the context item (i.e. predicates on the node/subtree) and
certainly where such possibilities are shared between different
situations, then pattern-matching <xsl:template> declarations invoked
through <xsl:apply-templates> may be more suitable and extensible.
Be warned however that this issue of whether conditionality is
explicitly controlled within result trees or attached as predicates to
templates can raise semi-religious fervour amongst some parts of the
community!
--
*John Lumley* MA PhD CEng FIEE
john(_at_)saxonica(_dot_)com <mailto:john(_at_)saxonica(_dot_)com>
on behalf of Saxonica Ltd
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--