length-units — Return the units from a length specification
The length-units
template returns the
units ("pt" for "20pt") from a length. If no units are supplied on the
length, the defauilt.units
are returned.
<xsl:template name="length-units"> <xsl:param name="length" select="'0pt'"></xsl:param> <xsl:param name="default.units" select="'px'"></xsl:param> <xsl:variable name="magnitude"> <xsl:call-template name="length-magnitude"> <xsl:with-param name="length" select="$length"></xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="units"> <xsl:value-of select="substring($length, string-length($magnitude)+1)"></xsl:value-of> </xsl:variable> <xsl:choose> <xsl:when test="$units = ''"> <xsl:value-of select="$default.units"></xsl:value-of> </xsl:when> <xsl:otherwise> <xsl:value-of select="$units"></xsl:value-of> </xsl:otherwise> </xsl:choose> </xsl:template>