Hi everyone,
If you need sprintf()-like functionality in XSLT, one approach is to use the
arrow (=>) operator to apply a series of replace() operations:
<xsl:if test="$word-count > 0">
<xsl:variable name="minutes" select="xs:integer(ceiling($word-count div
$words-per-minute))" as="xs:integer"/>
<div>
<strong>Estimated reading time:</strong>
<xsl:value-of select="' %d %s'
=> replace('%d', string($minutes))
=> replace('%s', if ($minutes = 1) then 'minute' else 'minutes')"/>
</div>
</xsl:if>
Just wanted to share. Thanks!
-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell
|