length-magnitude

length-magnitude — Return the unqualified dimension from a length specification

Description

The length-magnitude template returns the unqualified length ("20" for "20pt") from a dimension.

<xsl:template name="length-magnitude">
  <xsl:param name="length" select="'0pt'"></xsl:param>

  <xsl:choose>
    <xsl:when test="string-length($length) = 0"></xsl:when>
    <xsl:when test="substring($length,1,1) = '0'                     or substring($length,1,1) = '1'                     or substring($length,1,1) = '2'                     or substring($length,1,1) = '3'                     or substring($length,1,1) = '4'                     or substring($length,1,1) = '5'                     or substring($length,1,1) = '6'                     or substring($length,1,1) = '7'                     or substring($length,1,1) = '8'                     or substring($length,1,1) = '9'                     or substring($length,1,1) = '.'">
      <xsl:value-of select="substring($length,1,1)"></xsl:value-of>
      <xsl:call-template name="length-magnitude">
        <xsl:with-param name="length" select="substring($length,2)"></xsl:with-param>
      </xsl:call-template>
    </xsl:when>
  </xsl:choose>
</xsl:template>