<?xml version='1.0' encoding=“UTF-8”?> <xsl:stylesheet xmlns:xsl=“www.w3.org/1999/XSL/Transform”
xmlns:m="http://www.w3.org/1998/Math/MathML" version='1.0'> <xsl:template name="color"> <!-- NB: Variables colora and valueColor{n} only for Sablotron --> <xsl:param name="color"/> <xsl:variable name="colora" select="translate($color,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/> <xsl:choose> <xsl:when test="starts-with($colora,'#') and string-length($colora)=4"> <xsl:variable name="valueColor"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,2,1)"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$valueColor div 15"/><xsl:text>,</xsl:text> <xsl:variable name="valueColor1"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,3,1)"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$valueColor1 div 15"/><xsl:text>,</xsl:text> <xsl:variable name="valueColor2"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,4,1)"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$valueColor2 div 15"/> </xsl:when> <xsl:when test="starts-with($colora,'#') and string-length($colora)=7"> <xsl:variable name="valueColor1"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,2,1)"/> </xsl:call-template> </xsl:variable> <xsl:variable name="valueColor2"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,3,1)"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="($valueColor1*16 + $valueColor2) div 255"/><xsl:text>,</xsl:text> <xsl:variable name="valueColor1a"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,4,1)"/> </xsl:call-template> </xsl:variable> <xsl:variable name="valueColor2a"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,5,1)"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="($valueColor1a*16 + $valueColor2a) div 255"/><xsl:text>,</xsl:text> <xsl:variable name="valueColor1b"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,6,1)"/> </xsl:call-template> </xsl:variable> <xsl:variable name="valueColor2b"> <xsl:call-template name="Hex2Decimal"> <xsl:with-param name="arg" select="substring($colora,7,1)"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="($valueColor1b*16 + $valueColor2b) div 255"/> </xsl:when> <!-- ====== if color specifed as an html-color-name ============= --> <xsl:when test="$colora='aqua'"><xsl:text>0,1,1</xsl:text></xsl:when> <xsl:when test="$colora='black'"><xsl:text>0,0,0</xsl:text></xsl:when> <xsl:when test="$colora='blue'"><xsl:text>0,0,1</xsl:text></xsl:when> <xsl:when test="$colora='fuchsia'"><xsl:text>1,0,1</xsl:text></xsl:when> <xsl:when test="$colora='gray'"><xsl:text>.5,.5,.5</xsl:text></xsl:when> <xsl:when test="$colora='green'"><xsl:text>0,.5,0</xsl:text></xsl:when> <xsl:when test="$colora='lime'"><xsl:text>0,1,0</xsl:text></xsl:when> <xsl:when test="$colora='maroon'"><xsl:text>.5,0,0</xsl:text></xsl:when> <xsl:when test="$colora='navy'"><xsl:text>0,0,.5</xsl:text></xsl:when> <xsl:when test="$colora='olive'"><xsl:text>.5,.5,0</xsl:text></xsl:when> <xsl:when test="$colora='purple'"><xsl:text>.5,0,.5</xsl:text></xsl:when> <xsl:when test="$colora='red'"><xsl:text>1,0,0</xsl:text></xsl:when> <xsl:when test="$colora='silver'"><xsl:text>.75,.75,.75</xsl:text></xsl:when> <xsl:when test="$colora='teal'"><xsl:text>0,.5,.5</xsl:text></xsl:when> <xsl:when test="$colora='white'"><xsl:text>1,1,1</xsl:text></xsl:when> <xsl:when test="$colora='yellow'"><xsl:text>1,1,0</xsl:text></xsl:when> <xsl:otherwise> <xsl:message>Exception at color template</xsl:message> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="Hex2Decimal"> <xsl:param name="arg"/> <xsl:choose> <xsl:when test="$arg='f'"> <xsl:value-of select="15"/> </xsl:when> <xsl:when test="$arg='e'"> <xsl:value-of select="14"/> </xsl:when> <xsl:when test="$arg='d'"> <xsl:value-of select="13"/> </xsl:when> <xsl:when test="$arg='c'"> <xsl:value-of select="12"/> </xsl:when> <xsl:when test="$arg='b'"> <xsl:value-of select="11"/> </xsl:when> <xsl:when test="$arg='a'"> <xsl:value-of select="10"/> </xsl:when> <xsl:when test="translate($arg, '0123456789', '9999999999')='9'"> <!-- if $arg is number --> <xsl:value-of select="$arg"/> </xsl:when> <xsl:otherwise> <xsl:message>Exception at Hex2Decimal template</xsl:message> </xsl:otherwise> </xsl:choose> </xsl:template>
</xsl:stylesheet>