-<!-- Returns a test on apply node children number-->
-<xsl:template name="out_match_child">
- <xsl:param name="not" select="'false'"/>
- <xsl:param name="cook" select="'false'"/>
- <xsl:param name="hide" select="0"/>
- <xsl:param name="arity" select="0"/>
-
- <!--
- Test on children number only if the operator is concatenated with not of
- if it is not constant and it has not to be cooked.
- It is not possible to concatenate a constant operator with not.
- -->
- <xsl:if test="$not = 'true' or (($arity != 0 or $hide != 0) and $cook = 'false')">
- <xsl:choose>
- <!-- if the operator has been concatenated with not, the root apply node must have only two child -->
- <xsl:when test="$not = 'true'">
- <xsl:variable name="test_apply_children">
- <xsl:if test="$cook = 'false'">
- <xsl:value-of select="concat(' and count(*[2]/*) = ',$arity + $hide + 1)"/>
- </xsl:if>
- </xsl:variable>
-
- <xsl:value-of select="concat('count(*) = 2',$test_apply_children)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('count(*) = ',$arity + $hide + 1)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-</xsl:template>
-
-<xsl:template name="out_match">
- <xsl:param name="not" select="'false'"/>
- <xsl:param name="uri"/>
- <xsl:param name="cook" select="'false'"/>
- <xsl:param name="hide" select="0"/>
- <xsl:param name="arity" select="0"/>
- <xsl:param name="c-tag"/>
-
- <!-- TEST ON OPERATOR(S) TYPE -->
- <xsl:variable name="match_op">
- <xsl:call-template name="out_match_op">
- <xsl:with-param name="not" select="$not"/>
- <xsl:with-param name="uri" select="$uri"/>
- <xsl:with-param name="hide" select="$hide"/>
- <xsl:with-param name="c-tag" select="$c-tag"/>
- </xsl:call-template>
- </xsl:variable>
-
- <!-- TEST ON CHILD(REN) NUMBER -->
- <xsl:variable name="match_child">
- <xsl:call-template name="out_match_child">
- <xsl:with-param name="not" select="$not"/>
- <xsl:with-param name="cook" select="$cook"/>
- <xsl:with-param name="hide" select="$hide"/>
- <xsl:with-param name="arity" select="$arity"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <!-- not a constant operator -->
- <xsl:when test="$arity != 0 or $hide != 0">
- <xsl:choose>
- <xsl:when test="$match_child != ''">
- <xsl:value-of select="concat('APPLY[',$match_op,' and ',$match_child,']')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('APPLY[',$match_op,']')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$match_child != ''">
- <xsl:value-of select="concat($match_op,' and ',$match_child)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$match_op"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-