--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:helm="http://www.cs.unibo.it/helm"
+ xmlns:oxsl="http://www.w3.org/1999/XSL/TransformAlias">
+
+<xsl:output method="xml"/>
+
+<xsl:namespace-alias stylesheet-prefix="oxsl" result-prefix="xsl"/>
+
+<xsl:template match="OpList">
+ <xsl:comment> Copyright (C) 2000, HELM Team </xsl:comment>
+ <xsl:comment> </xsl:comment>
+ <xsl:comment> This file is part of HELM, an Hypertextual, Electronic </xsl:comment>
+ <xsl:comment> Library of Mathematics, developed at the Computer Science </xsl:comment>
+ <xsl:comment> Department, University of Bologna, Italy. </xsl:comment>
+ <xsl:comment> </xsl:comment>
+ <xsl:comment> HELM is free software; you can redistribute it and/or </xsl:comment>
+ <xsl:comment> modify it under the terms of the GNU General Public License </xsl:comment>
+ <xsl:comment> as published by the Free Software Foundation; either version 2 </xsl:comment>
+ <xsl:comment> of the License, or (at your option) any later version. </xsl:comment>
+ <xsl:comment> </xsl:comment>
+ <xsl:comment> HELM is distributed in the hope that it will be useful, </xsl:comment>
+ <xsl:comment> but WITHOUT ANY WARRANTY; without even the implied warranty of </xsl:comment>
+ <xsl:comment> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the </xsl:comment>
+ <xsl:comment> GNU General Public License for more details. </xsl:comment>
+ <xsl:comment> </xsl:comment>
+ <xsl:comment> You should have received a copy of the GNU General Public License </xsl:comment>
+ <xsl:comment> along with HELM; if not, write to the Free Software </xsl:comment>
+ <xsl:comment> Foundation, Inc., 59 Temple Place - Suite 330, Boston, </xsl:comment>
+ <xsl:comment> MA 02111-1307, USA. </xsl:comment>
+ <xsl:comment> </xsl:comment>
+ <xsl:comment> For details, see the HELM World-Wide-Web page, </xsl:comment>
+ <xsl:comment> http://cs.unibo.it/helm/. </xsl:comment>
+
+ <oxsl:stylesheet version="1.0">
+ <xsl:apply-templates/>
+ </oxsl:stylesheet>
+</xsl:template>
+
+<xsl:template match="import">
+ <oxsl:import href="{@href}"/>
+</xsl:template>
+
+<xsl:template match="include">
+ <oxsl:include href="{@href}"/>
+</xsl:template>
+
+<xsl:template match="Operator|NotOperator">
+ <xsl:variable name="uri">
+ <xsl:call-template name="remove_white_spaces">
+ <xsl:with-param name="uri" select="@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="not">
+ <xsl:choose>
+ <xsl:when test="name() = 'Operator'">false</xsl:when>
+ <xsl:otherwise>true</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="@arity = 0 and @hide = 0 and $not = 'true'">
+ <xsl:call-template name="out_comment">
+ <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="@arity = 0 and @hide = 0 and @cook = 'true'">
+ <xsl:call-template name="out_comment">
+ <xsl:with-param name="name" select="concat($uri,': a constant operator cannot be cooked')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- All uris in uri1 list (if not empty) have CONST c-tag -->
+ <xsl:variable name="uri1">
+ <xsl:call-template name="select_uris">
+ <xsl:with-param name="uris" select="$uri"/>
+ <xsl:with-param name="c-tag" select="'CONST'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!-- All uris in uri2 list (if not empty) have MUTIND c-tag -->
+ <xsl:variable name="uri2">
+ <xsl:call-template name="select_uris">
+ <xsl:with-param name="uris" select="$uri"/>
+ <xsl:with-param name="c-tag" select="'MUTIND'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:if test="$uri1 != ''">
+ <xsl:call-template name="out_template">
+ <xsl:with-param name="name" select="@name"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="uri" select="$uri1"/>
+ <xsl:with-param name="cook" select="@cook"/>
+ <xsl:with-param name="hide" select="@hide"/>
+ <xsl:with-param name="arity" select="@arity"/>
+ <xsl:with-param name="m-tag" select="@m-tag"/>
+ <xsl:with-param name="c-tag" select="'CONST'"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:if test="$uri2 != ''">
+ <xsl:call-template name="out_template">
+ <xsl:with-param name="name" select="@name"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="uri" select="$uri2"/>
+ <xsl:with-param name="cook" select="@cook"/>
+ <xsl:with-param name="hide" select="@hide"/>
+ <xsl:with-param name="arity" select="@arity"/>
+ <xsl:with-param name="m-tag" select="@m-tag"/>
+ <xsl:with-param name="c-tag" select="'MUTIND'"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="OpSet|NotOpSet">
+ <xsl:variable name="uri">
+ <xsl:call-template name="remove_white_spaces">
+ <xsl:with-param name="uri" select="@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="not">
+ <xsl:choose>
+ <xsl:when test="name() = 'OpSet'">false</xsl:when>
+ <xsl:otherwise>true</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="*[name() = 'Case']/@arity = 0 and @hide = 0 and $not = 'true'">
+ <xsl:call-template name="out_comment">
+ <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="*[name() = 'Case']/@arity = 0 and @hide = 0 and @cook = 'true'">
+ <xsl:call-template name="out_comment">
+ <xsl:with-param name="name" select="concat($uri,': a constant operator cannot be cooked')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="uri1">
+ <xsl:call-template name="select_uris">
+ <xsl:with-param name="uris" select="$uri"/>
+ <xsl:with-param name="c-tag" select="'CONST'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="uri2">
+ <xsl:call-template name="select_uris">
+ <xsl:with-param name="uris" select="$uri"/>
+ <xsl:with-param name="c-tag" select="'MUTIND'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:if test="$uri1 != ''">
+ <xsl:call-template name="out_template_set">
+ <xsl:with-param name="name" select="@name"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="uri" select="$uri1"/>
+ <xsl:with-param name="cook" select="@cook"/>
+ <xsl:with-param name="hide" select="@hide"/>
+ <xsl:with-param name="m-tag" select="@m-tag"/>
+ <xsl:with-param name="c-tag" select="'CONST'"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:if test="$uri2 != ''">
+ <xsl:call-template name="out_template_set">
+ <xsl:with-param name="name" select="@name"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="uri" select="$uri2"/>
+ <xsl:with-param name="cook" select="@cook"/>
+ <xsl:with-param name="hide" select="@hide"/>
+ <xsl:with-param name="m-tag" select="@m-tag"/>
+ <xsl:with-param name="c-tag" select="'MUTIND'"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- *********************************************************************** -->
+<!-- MAIN FUNCTIONS -->
+<!-- *********************************************************************** -->
+
+
+<xsl:template name="out_template">
+ <xsl:param name="name"/>
+ <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="m-tag"/>
+ <xsl:param name="c-tag"/>
+
+ <xsl:variable name="apply_not">
+ <xsl:if test="$not = 'true'">*[2]/</xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="match">
+ <xsl:call-template name="out_match">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="uri" select="$uri"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="op_uri_attr">
+ <xsl:variable name="tmp_op_uri_attr">
+ <xsl:call-template name="op_uri_attr">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="substring-after(substring-before($tmp_op_uri_attr,'}'),'{')"/>
+ </xsl:variable>
+
+ <!-- TEMPLATE -->
+ <xsl:call-template name="out_comment">
+ <xsl:with-param name="name" select="$name"/>
+ </xsl:call-template>
+
+ <oxsl:template match="{$match}" mode="pure">
+ <xsl:choose>
+ <xsl:when test="$cook = 'true'">
+ <oxsl:variable name="no_params">
+ <oxsl:variable name="no_params_tmp">
+ <oxsl:call-template name="get_no_params">
+ <oxsl:with-param name="first_uri" select="$CICURI"/>
+ <oxsl:with-param name="second_uri" select="{$op_uri_attr}"/>
+ </oxsl:call-template>
+ </oxsl:variable>
+ <oxsl:value-of select="number($no_params_tmp)"/>
+ </oxsl:variable>
+ <oxsl:choose>
+ <oxsl:when test="{concat('count(',$apply_not,'*) = $no_params + ',$arity + $hide + 1)}">
+ <xsl:call-template name="out_body">
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="m-tag" select="$m-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </oxsl:when>
+ <oxsl:otherwise>
+ <oxsl:apply-imports/>
+ </oxsl:otherwise>
+ </oxsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="out_body">
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="m-tag" select="$m-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </oxsl:template>
+</xsl:template>
+
+<xsl:template name="out_template_set">
+ <xsl:param name="name"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="uri"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="m-tag"/>
+ <xsl:param name="c-tag"/>
+
+ <xsl:variable name="no_params_var">
+ <xsl:if test="$cook = 'true'">$no_params + </xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="match">
+ <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="c-tag" select="$c-tag"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="apply_not">
+ <xsl:if test="$not = 'true'">*[2]/</xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="op_uri_attr">
+ <xsl:variable name="tmp_op_uri_attr">
+ <xsl:call-template name="op_uri_attr">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="substring-after(substring-before($tmp_op_uri_attr,'}'),'{')"/>
+ </xsl:variable>
+
+
+ <!-- TEMPLATE -->
+ <xsl:call-template name="out_comment">
+ <xsl:with-param name="name" select="$name"/>
+ </xsl:call-template>
+
+ <oxsl:template match="{concat('APPLY[',$match,']')}" mode="pure">
+ <xsl:if test="$cook = 'true'">
+ <oxsl:variable name="no_params">
+ <oxsl:variable name="no_params_tmp">
+ <oxsl:call-template name="get_no_params">
+ <oxsl:with-param name="first_uri" select="$CICURI"/>
+ <oxsl:with-param name="second_uri" select="{$op_uri_attr}"/>
+ </oxsl:call-template>
+ </oxsl:variable>
+ <oxsl:value-of select="number($no_params_tmp)"/>
+ </oxsl:variable>
+ </xsl:if>
+ <oxsl:choose>
+ <xsl:for-each select="Case">
+ <oxsl:when test="{concat('count(',$apply_not,'*) = ',$no_params_var,@arity + $hide + 1)}">
+ <xsl:call-template name="out_body">
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="m-tag" select="$m-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="@arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </oxsl:when>
+ </xsl:for-each>
+ <oxsl:otherwise>
+ <oxsl:apply-imports/>
+ </oxsl:otherwise>
+ </oxsl:choose>
+ </oxsl:template>
+</xsl:template>
+
+<xsl:template name="out_comment">
+ <xsl:param name="name"/>
+ <xsl:if test="$name">
+ <xsl:comment>
+ <xsl:value-of select="concat(' ',$name,' ')"/>
+ </xsl:comment>
+ </xsl:if>
+</xsl:template>
+
+<!-- Returns a regular expression with matching operators -->
+<xsl:template name="out_match_op">
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="uri"/>
+ <xsl:param name="c-tag"/>
+
+ <!-- application with not operator -->
+ <xsl:variable name="app_not">
+ <xsl:if test="$not = 'true'">CONST[@uri='cic:/Coq/Init/Logic/not.con'] and </xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="uris">
+ <xsl:call-template name="test_on_uris">
+ <xsl:with-param name="uris" select="$uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="app_op">
+ <xsl:if test="$not = 'true'">APPLY[</xsl:if>
+ <xsl:value-of select="concat($c-tag,'[',$uris,']')"/>
+ <xsl:if test="$not = 'true'">]</xsl:if>
+ </xsl:variable>
+
+ <xsl:value-of select="concat($app_not,$app_op)"/>
+</xsl:template>
+
+<!-- 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>
+
+<xsl:template name="out_params">
+ <xsl:param name="params" select="1"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="mode" select="'noannot'"/>
+ <xsl:param name="arity" select="0"/>
+
+ <xsl:if test="$params <= $arity">
+ <xsl:variable name="param">
+ <xsl:call-template name="param">
+ <xsl:with-param name="id" select="$params"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <oxsl:apply-templates select="{$param}" mode="{$mode}"/>
+
+ <xsl:call-template name="out_params">
+ <xsl:with-param name="params" select="$params + 1"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="mode" select="$mode"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+
+<xsl:template name="out_body">
+ <xsl:param name="c-tag"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="m-tag"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <xsl:choose>
+ <!-- SIMPLE TRANSFORMATIONS -->
+ <xsl:when test="count(*) = 0">
+ <xsl:variable name="xref">{@id}</xsl:variable>
+
+ <xsl:variable name="definitionURL">
+ <xsl:call-template name="op_uri_attr">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="helm:xref">
+ <xsl:call-template name="op_id_attr">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!-- APPLY -->
+ <m:apply helm:xref="{$xref}">
+ <!-- OPERATOR -->
+ <xsl:element name="{concat('m:',$m-tag)}">
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="$definitionURL"/>
+ </xsl:attribute>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="$helm:xref"/>
+ </xsl:attribute>
+ </xsl:element>
+ <!-- PARAMS -->
+ <xsl:call-template name="out_params">
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ </xsl:call-template>
+ </m:apply>
+ </xsl:when>
+ <!-- COMPLEX TRANSFORMATIONS -->
+ <xsl:otherwise>
+ <xsl:apply-templates>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="out_mvar">
+ <xsl:param name="vname"/>
+
+ <m:ci>
+ <xsl:choose>
+ <xsl:when test="(ancestor-or-self::*[preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)]]/preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)])[position() = last()]">
+ <oxsl:value-of select="{concat('$bvar_',$vname)}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$vname"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:ci>
+</xsl:template>
+
+
+<xsl:template name="out_choose_binder">
+ <xsl:param name="binded_params" select="''"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="binder"/>
+
+ <xsl:if test="$binded_params != ''">
+ <xsl:choose>
+ <xsl:when test="contains($binded_params,'+')">
+ <xsl:call-template name="out_choose_binder">
+ <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
+ <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="binder" select="$binder"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="out_choose_binder">
+ <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
+ <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="binder" select="$binder"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="param">
+ <xsl:call-template name="param">
+ <xsl:with-param name="id" select="$binded_params"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
+ <oxsl:value-of select="{concat($param,$binder)}"/>
+ </oxsl:when>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- *********************************************************************** -->
+<!-- META LANGUAGE FOR MathML -->
+<!-- *********************************************************************** -->
+
+<xsl:template match="mapp">
+ <xsl:param name="c-tag"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <xsl:variable name="helm:xref">
+ <xsl:choose>
+ <xsl:when test="@xref">
+ <xsl:call-template name="set_attribute">
+ <xsl:with-param name="attr" select="@xref"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>{@id}</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <m:apply helm:xref="{$helm:xref}">
+ <xsl:call-template name="copy_attributes">
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="ignore" select="'xref'"/>
+ </xsl:call-template>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:apply-templates>
+ </m:apply>
+</xsl:template>
+
+
+<xsl:template match="mop">
+ <xsl:param name="c-tag"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <!-- set definitonURL attribute -->
+ <xsl:variable name="definitionURL">
+ <xsl:choose>
+ <xsl:when test="@definitionURL">
+ <xsl:call-template name="set_attribute">
+ <xsl:with-param name="attr" select="@definitionURL"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="op_uri_attr">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- set helm:xref attribute -->
+ <xsl:variable name="helm:xref">
+ <xsl:choose>
+ <xsl:when test="@xref">
+ <xsl:call-template name="set_attribute">
+ <xsl:with-param name="attr" select="@xref"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="op_id_attr">
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:element name="{concat('m:',@tag)}">
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="$definitionURL"/>
+ </xsl:attribute>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="$helm:xref"/>
+ </xsl:attribute>
+
+ <xsl:call-template name="copy_attributes">
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="ignore" select="'xref + definitionURL + tag'"/>
+ </xsl:call-template>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:apply-templates>
+ </xsl:element>
+</xsl:template>
+
+<xsl:template match="param">
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <xsl:variable name="param">
+ <xsl:call-template name="param">
+ <xsl:with-param name="id" select="@id"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="@bvar">
+ <oxsl:choose>
+ <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
+ <oxsl:apply-templates select="{concat($param,'/target')}" mode="{@mode}"/>
+ </oxsl:when>
+ <oxsl:otherwise>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
+ <m:ci>
+ <xsl:value-of select="@bvar"/>
+ </m:ci>
+ </m:apply>
+ </oxsl:otherwise>
+ </oxsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="m:*">
+ <xsl:param name="c-tag"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <xsl:copy>
+ <xsl:call-template name="copy_attributes">
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:apply-templates>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="mbvar">
+ <xsl:param name="c-tag"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <xsl:variable name="binded_params">
+ <xsl:call-template name="get_binded_params">
+ <xsl:with-param name="var" select="@name"/>
+ <xsl:with-param name="node" select="following-sibling::*"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="test">
+ <xsl:call-template name="test_on_lambda">
+ <xsl:with-param name="binded_params" select="$binded_params"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="binder">/target/@binder</xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$binded_params != ''">
+ <oxsl:variable name="{concat('bvar_',@name)}">
+ <oxsl:choose>
+ <!-- one or more lambdas exist -->
+ <oxsl:when test="{$test}">
+ <xsl:choose>
+ <!-- binded params > 1 (more than 1 lambda) -->
+ <xsl:when test="contains($binded_params,'+')">
+ <oxsl:variable name="binder">
+ <oxsl:choose>
+ <xsl:call-template name="out_choose_binder">
+ <xsl:with-param name="binded_params" select="$binded_params"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:call-template>
+ </oxsl:choose>
+ </oxsl:variable>
+ <oxsl:call-template name="insert_subscript">
+ <oxsl:with-param name="node_value" select="$binder"/>
+ </oxsl:call-template>
+ </xsl:when>
+ <!-- binded parms = 1 (1 lambda) -->
+ <xsl:otherwise>
+ <xsl:variable name="param">
+ <xsl:call-template name="param">
+ <xsl:with-param name="id" select="$binded_params"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <oxsl:call-template name="insert_subscript">
+ <oxsl:with-param name="node_value" select="{concat($param,$binder)}"/>
+ </oxsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </oxsl:when>
+ <!-- no one lambda -->
+ <oxsl:otherwise>
+ <xsl:value-of select="@name"/>
+ </oxsl:otherwise>
+ </oxsl:choose>
+ </oxsl:variable>
+
+ <m:bvar>
+ <m:ci>
+ <oxsl:value-of select="{concat('$bvar_',@name)}"/>
+ </m:ci>
+ <xsl:apply-templates>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:apply-templates>
+ </m:bvar>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:bvar>
+ <m:ci>
+ <xsl:value-of select="@name"/>
+ </m:ci>
+ <xsl:apply-templates>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:apply-templates>
+ </m:bvar>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="mvar">
+ <xsl:call-template name="out_mvar">
+ <xsl:with-param name="vname" select="@name"/>
+ </xsl:call-template>
+</xsl:template>
+
+
+
+<!-- *********************************************************************** -->
+<!-- AUXILIARY FUNCTIONS -->
+<!-- *********************************************************************** -->
+
+
+<!-- Returns a value if all uris in the list have the same c-tag -->
+<xsl:template name="get_c_tag">
+ <xsl:param name="uri" select="''"/>
+
+ <xsl:if test="$uri != ''">
+ <xsl:choose>
+ <xsl:when test="contains($uri,'|')">
+ <xsl:variable name="c-tag1">
+ <xsl:call-template name="get_c_tag">
+ <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="c-tag2">
+ <xsl:call-template name="get_c_tag">
+ <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:if test="$c-tag1 = $c-tag2">
+ <xsl:value-of select="$c-tag1"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="substring($uri,string-length($uri)-3) = '.con'">CONST</xsl:when>
+ <xsl:when test="substring($uri,string-length($uri)-3) = '.ind'">MUTIND</xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- Creates a list selecting uris according to c-tag specified -->
+<xsl:template name="select_uris">
+ <xsl:param name="uris" select="''"/>
+ <xsl:param name="c-tag"/>
+
+ <xsl:if test="$uris != ''">
+ <xsl:choose>
+ <xsl:when test="contains($uris,'|')">
+ <xsl:variable name="list1">
+ <xsl:call-template name="select_uris">
+ <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="list2">
+ <xsl:call-template name="select_uris">
+ <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$list1 != '' and $list2 != ''">
+ <xsl:value-of select="concat($list1,'|',$list2)"/>
+ </xsl:when>
+ <xsl:when test="$list1 != '' and $list2 = ''">
+ <xsl:value-of select="$list1"/>
+ </xsl:when>
+ <xsl:when test="$list1 = '' and $list2 != ''">
+ <xsl:value-of select="$list2"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="c-tag1">
+ <xsl:call-template name="get_c_tag">
+ <xsl:with-param name="uri" select="$uris"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:if test="$c-tag1 = $c-tag">
+ <xsl:value-of select="$uris"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- Returns a xpath expression matching on uri attributes -->
+<xsl:template name="test_on_uris">
+ <xsl:param name="uris" select="''"/>
+
+ <xsl:if test="$uris != ''">
+ <xsl:choose>
+ <xsl:when test="contains($uris,'|')">
+ <xsl:variable name="expr1">
+ <xsl:call-template name="test_on_uris">
+ <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="expr2">
+ <xsl:call-template name="test_on_uris">
+ <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('@uri=',"'",$uris,"'")"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- Returns a xpath expression testing on LAMBDA node existence -->
+<xsl:template name="test_on_lambda">
+ <xsl:param name="binded_params" select="''"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+
+ <xsl:if test="$binded_params != ''">
+ <xsl:choose>
+ <xsl:when test="contains($binded_params,'+')">
+ <xsl:variable name="expr1">
+ <xsl:call-template name="test_on_lambda">
+ <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="expr2">
+ <xsl:call-template name="test_on_lambda">
+ <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="param">
+ <xsl:call-template name="param">
+ <xsl:with-param name="id" select="$binded_params"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="cook" select="$cook"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat('name(',$param,') = ',"'LAMBDA'")"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- Removes white spaces from uris list -->
+<xsl:template name="remove_white_spaces">
+ <xsl:param name="uri" select="''"/>
+
+ <xsl:if test="$uri != ''">
+ <xsl:choose>
+ <xsl:when test="contains($uri,'|')">
+ <xsl:variable name="uri1">
+ <xsl:call-template name="remove_white_spaces">
+ <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="uri2">
+ <xsl:call-template name="remove_white_spaces">
+ <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat($uri1,'|',$uri2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space($uri)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!--
+ Returns a list of params id attributes concatenated with '+'.
+ The params'id attribute are selected according to the value of bindig variable 'var'
+ -->
+<xsl:template name="get_binded_params">
+ <xsl:param name="var"/>
+ <xsl:param name="node"/>
+
+ <xsl:if test="count($node) != 0">
+ <xsl:choose>
+ <!-- another variable declaration with same name -->
+ <xsl:when test="($node[1][name() = 'mbvar']) and ($node[1][@name = $var])"></xsl:when>
+ <!-- a binded param -->
+ <xsl:when test="($node[1][name() = 'param']) and ($node[1][@bvar = $var])">
+ <!-- search on siblings -->
+ <xsl:variable name="siblings_params">
+ <xsl:call-template name="get_binded_params">
+ <xsl:with-param name="var" select="$var"/>
+ <xsl:with-param name="node" select="$node[position() > 1]"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$siblings_params != ''">
+ <xsl:value-of select="concat($node[1]/@id,'+',$siblings_params)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$node[1]/@id"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- search on siblings -->
+ <xsl:variable name="siblings_params">
+ <xsl:call-template name="get_binded_params">
+ <xsl:with-param name="var" select="$var"/>
+ <xsl:with-param name="node" select="$node[position() > 1]"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!-- search on children -->
+ <xsl:variable name="children_params">
+ <xsl:call-template name="get_binded_params">
+ <xsl:with-param name="var" select="$var"/>
+ <xsl:with-param name="node" select="$node[1]/child::*"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$children_params != '' and $siblings_params != ''">
+ <xsl:value-of select="concat($children_params,'+',$siblings_params)"/>
+ </xsl:when>
+ <xsl:when test="$children_params != '' and $siblings_params = ''">
+ <xsl:value-of select="$children_params"/>
+ </xsl:when>
+ <xsl:when test="$children_params = '' and $siblings_params != ''">
+ <xsl:value-of select="$siblings_params"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- Returns a xpath string with the location of the parameter with the id specified -->
+<xsl:template name="param">
+ <xsl:param name="id"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="cook" select="'false'"/>
+ <xsl:param name="hide" select="0"/>
+
+ <xsl:variable name="apply_not">
+ <xsl:if test="$not = 'true'">*[2]/</xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="no_params_var">
+ <xsl:if test="$cook = 'true'">$no_params+</xsl:if>
+ </xsl:variable>
+
+ <xsl:value-of select="concat($apply_not,'*[',$no_params_var,$id + $hide + 1,']')"/>
+</xsl:template>
+
+<!-- Returns a xpath string with the location of the operator uri attribute -->
+<xsl:template name="op_uri_attr">
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="c-tag"/>
+ <xsl:param name="const" select="'false'"/>
+
+ <xsl:call-template name="op_attr">
+ <xsl:with-param name="attr_type" select="'@uri'"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$const"/>
+ </xsl:call-template>
+</xsl:template>
+
+<!-- Returns a xpath string with the location of the operator id attribute -->
+<xsl:template name="op_id_attr">
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="c-tag"/>
+ <xsl:param name="const" select="'false'"/>
+
+ <xsl:call-template name="op_attr">
+ <xsl:with-param name="attr_type" select="'@id'"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$const"/>
+ </xsl:call-template>
+</xsl:template>
+
+
+<!-- Returns a xpath string with the location of the operator uri or id attribute -->
+<xsl:template name="op_attr">
+ <xsl:param name="attr_type"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="c-tag"/>
+ <xsl:param name="const" select="'false'"/>
+
+ <xsl:variable name="apply">
+ <xsl:if test="$not = 'true'">APPLY/</xsl:if>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$const = 'true'">
+ <xsl:value-of select="concat('{',$attr_type,'}')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('{',$apply,$c-tag,'/',$attr_type,'}')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="copy_attributes">
+ <xsl:param name="c-tag"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+ <xsl:param name="ignore" select="''"/>
+
+ <xsl:variable name="test">
+ <xsl:call-template name="test_on_attributes">
+ <xsl:with-param name="names" select="$ignore"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:for-each select="@*">
+ <xsl:if test="contains($test,concat('+',name(),'+')) = false()">
+ <xsl:attribute name="{name()}">
+ <xsl:call-template name="set_attribute">
+ <xsl:with-param name="attr" select="."/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="hide" select="$hide"/>
+ <xsl:with-param name="arity" select="$arity"/>
+ <xsl:with-param name="not" select="$not"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template name="test_on_attributes">
+ <xsl:param name="names" select="''"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($names,'+')">
+ <xsl:variable name="name">
+ <xsl:call-template name="test_on_attributes">
+ <xsl:with-param name="names" select="normalize-space(substring-after($names,'+'))"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat('+',normalize-space(substring-before($names,'+')),$name)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('+',normalize-space($names),'+')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="set_attribute">
+ <xsl:param name="attr"/>
+ <xsl:param name="c-tag"/>
+ <xsl:param name="hide" select="0"/>
+ <xsl:param name="arity" select="0"/>
+ <xsl:param name="not" select="'false'"/>
+
+ <xsl:choose>
+ <xsl:when test="$attr = '$APP-ID'">{@id}</xsl:when>
+ <xsl:when test="$attr = '$OP-ID' or $attr = '$OP-URI'">
+ <xsl:variable name="attr_type">
+ <xsl:choose>
+ <xsl:when test="$attr = '$OP-ID'">@id</xsl:when>
+ <xsl:otherwise>@uri</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:call-template name="op_attr">
+ <xsl:with-param name="attr_type" select="$attr_type"/>
+ <xsl:with-param name="not" select="$not"/>
+ <xsl:with-param name="c-tag" select="$c-tag"/>
+ <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$attr"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>