xsl-list
[Top] [All Lists]

Re: Calculations involving measurements with units

2004-01-02 20:20:12
Hello,

On Fri, Jan 02, 2004 at 11:08:38PM +1030, Paul A. Hoadley wrote:

<xsl:variable name="upper-margin"
select="concat(number(translate($page-height, translate($page-height,
'0123456789.', ''), '')) div 3.75, translate($page-height,
'012345679.', ''))"/>

How can I neaten this up?  I've written two templates:

  <xsl:template name="getUnits">
    <xsl:param name="input"/>
    <xsl:value-of select="translate($input, '012345679.', '')"/>
  </xsl:template>

  <xsl:template name="stripUnits">
    <xsl:param name="input"/>
    <xsl:value-of select="translate($input, translate($page-height,
                          '012345679.', ''), '')"/>
  </xsl:template>

This would seem to only _increase_ the verbosity of what I have quoted
above, since now I can't call the templates inside the 'select' of the
variable declaration.  What is the standard idiom here?


-- 
Paul.

mailto:paulh(_at_)logicsquad(_dot_)net
mailto:phoadley(_at_)maths(_dot_)adelaide(_dot_)edu(_dot_)au

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list