left up right
fs.xsl Define States
<xsl:for-each select="fs/state"> 
 <xslt:template><xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>      
  <xslt:param name="str"/><xslt:param name="max"/>
  <xslt:param name="pos"/><xslt:param name="sofar"/>
   <xslt:variable name="char" select="substring($str,1,1)"/>
   <xslt:variable name="dig" select="translate($char,'0123456789','dddddddddd')"/>
   <xslt:choose>    
    <xsl:for-each select="entry">  
    <xslt:when>
     <xsl:attribute name="test">
      <xsl:for-each select="matches/match">
       <xsl:choose>
        <xsl:when test=". = 'digit'">$dig = $<xsl:value-of select="."/></xsl:when>
        <xsl:otherwise>$char = $<xsl:value-of select="."/></xsl:otherwise>
       </xsl:choose><xsl:if test="position() != last()"><xsl:text> or </xsl:text></xsl:if>
      </xsl:for-each></xsl:attribute> 
      <xslt:call-template>
       <xsl:attribute name="name"><xsl:value-of select="newstate"/></xsl:attribute> 
       <xslt:with-param name="str" >
        <xsl:attribute name="select">
         <xsl:choose>
          <xsl:when test="action = 'keep'">substring($str,1)</xsl:when>
          <xsl:otherwise>substring($str,2)</xsl:otherwise>
         </xsl:choose>
        </xsl:attribute> 
       </xslt:with-param>
       <xslt:with-param name="max" select="$max"/>
       <xslt:with-param name="pos" select="$pos"/>
       <xslt:with-param name="sofar" select="concat($sofar,$char)"/>
      </xslt:call-template>
     </xslt:when></xsl:for-each> </xslt:choose></xslt:template></xsl:for-each>