+ <xsl:apply-templates select="actions/reductions">
+ <xsl:with-param name="staten">
+ <xsl:value-of select="@number"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="actions/reductions">
+ <xsl:param name="staten"/>
+ <xsl:for-each select='reduction'>
+ <!-- These variables are needed because the current context can't be
+ refered to directly in XPath expressions. -->
+ <xsl:variable name="rul">
+ <xsl:value-of select="@rule"/>
+ </xsl:variable>
+ <xsl:variable name="ena">
+ <xsl:value-of select="@enabled"/>
+ </xsl:variable>
+ <!-- The foreach's body is protected by this, so that we are actually
+ going to iterate once per reduction rule, and not per lookahead. -->
+ <xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
+ <xsl:variable name="rule">
+ <xsl:choose>
+ <!-- The acceptation state is refered to as 'accept' in the XML, but
+ just as '0' in the DOT. -->
+ <xsl:when test="@rule='accept'">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@rule"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- The edge's beginning -->
+ <xsl:call-template name="reduction-edge-start">
+ <xsl:with-param name="state" select="$staten"/>
+ <xsl:with-param name="rule" select="$rule"/>
+ <xsl:with-param name="enabled" select="@enabled"/>
+ </xsl:call-template>
+
+ <!-- The edge's tokens -->
+ <!-- Don't show labels for the default action. In other cases, there will
+ always be at least one token, so 'label="[]"' will not occur. -->
+ <xsl:if test='$rule!=0 and not(../reduction[@enabled=$ena and @rule=$rule and @symbol="$default"])'>
+ <xsl:text>label="[</xsl:text>
+ <xsl:for-each select='../reduction[@enabled=$ena and @rule=$rule]'>
+ <xsl:call-template name="escape">
+ <xsl:with-param name="subject" select="@symbol"/>
+ </xsl:call-template>
+ <xsl:if test="position() != last ()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>]", </xsl:text>
+ </xsl:if>
+
+ <!-- The edge's end -->
+ <xsl:text>style=solid] </xsl:text>
+
+ <!-- The diamond representing the reduction -->
+ <xsl:call-template name="reduction-node">
+ <xsl:with-param name="state" select="$staten"/>
+ <xsl:with-param name="rule" select="$rule"/>
+ <xsl:with-param name="color">
+ <xsl:choose>
+ <xsl:when test='@enabled="true"'>
+ <xsl:text>3</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>5</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>