3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:m="http://www.w3.org/1998/Math/MathML"
5 xmlns:helm="http://www.cs.unibo.it/helm"
6 xmlns:oxsl="http://www.w3.org/1999/XSL/TransformAlias">
8 <xsl:output method="xml"/>
10 <xsl:namespace-alias stylesheet-prefix="oxsl" result-prefix="xsl"/>
12 <xsl:template match="OpList">
13 <xsl:comment> Copyright (C) 2000, HELM Team </xsl:comment>
14 <xsl:comment> </xsl:comment>
15 <xsl:comment> This file is part of HELM, an Hypertextual, Electronic </xsl:comment>
16 <xsl:comment> Library of Mathematics, developed at the Computer Science </xsl:comment>
17 <xsl:comment> Department, University of Bologna, Italy. </xsl:comment>
18 <xsl:comment> </xsl:comment>
19 <xsl:comment> HELM is free software; you can redistribute it and/or </xsl:comment>
20 <xsl:comment> modify it under the terms of the GNU General Public License </xsl:comment>
21 <xsl:comment> as published by the Free Software Foundation; either version 2 </xsl:comment>
22 <xsl:comment> of the License, or (at your option) any later version. </xsl:comment>
23 <xsl:comment> </xsl:comment>
24 <xsl:comment> HELM is distributed in the hope that it will be useful, </xsl:comment>
25 <xsl:comment> but WITHOUT ANY WARRANTY; without even the implied warranty of </xsl:comment>
26 <xsl:comment> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the </xsl:comment>
27 <xsl:comment> GNU General Public License for more details. </xsl:comment>
28 <xsl:comment> </xsl:comment>
29 <xsl:comment> You should have received a copy of the GNU General Public License </xsl:comment>
30 <xsl:comment> along with HELM; if not, write to the Free Software </xsl:comment>
31 <xsl:comment> Foundation, Inc., 59 Temple Place - Suite 330, Boston, </xsl:comment>
32 <xsl:comment> MA 02111-1307, USA. </xsl:comment>
33 <xsl:comment> </xsl:comment>
34 <xsl:comment> For details, see the HELM World-Wide-Web page, </xsl:comment>
35 <xsl:comment> http://cs.unibo.it/helm/. </xsl:comment>
37 <oxsl:stylesheet version="1.0">
38 <xsl:apply-templates/>
42 <xsl:template match="import">
43 <oxsl:import href="{@href}"/>
46 <xsl:template match="include">
47 <oxsl:include href="{@href}"/>
50 <xsl:template match="Operator|NotOperator">
51 <xsl:variable name="uri">
52 <xsl:call-template name="remove_white_spaces">
53 <xsl:with-param name="uri" select="@uri"/>
57 <xsl:variable name="not">
59 <xsl:when test="name() = 'Operator'">false</xsl:when>
60 <xsl:otherwise>true</xsl:otherwise>
64 <xsl:variable name="const">
65 <xsl:value-of select="@arity = 0 and @hide = 0 and @cook = 'false'"/>
69 <xsl:when test="$const = 'true' and $not = 'true'">
70 <xsl:call-template name="out_comment">
71 <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
75 <!-- All uris in uri1 list (if not empty) have CONST c-tag -->
76 <xsl:variable name="uri1">
77 <xsl:call-template name="select_uris">
78 <xsl:with-param name="uris" select="$uri"/>
79 <xsl:with-param name="c-tag" select="'CONST'"/>
83 <!-- All uris in uri2 list (if not empty) have MUTIND c-tag -->
84 <xsl:variable name="uri2">
85 <xsl:call-template name="select_uris">
86 <xsl:with-param name="uris" select="$uri"/>
87 <xsl:with-param name="c-tag" select="'MUTIND'"/>
91 <xsl:if test="$uri1 != ''">
92 <xsl:call-template name="out_template">
93 <xsl:with-param name="name" select="@name"/>
94 <xsl:with-param name="not" select="$not"/>
95 <xsl:with-param name="uri" select="$uri1"/>
96 <xsl:with-param name="cook" select="@cook"/>
97 <xsl:with-param name="hide" select="@hide"/>
98 <xsl:with-param name="arity" select="@arity"/>
99 <xsl:with-param name="m-tag" select="@m-tag"/>
100 <xsl:with-param name="c-tag" select="'CONST'"/>
101 <xsl:with-param name="const" select="$const"/>
105 <xsl:if test="$uri2 != ''">
106 <xsl:call-template name="out_template">
107 <xsl:with-param name="name" select="@name"/>
108 <xsl:with-param name="not" select="$not"/>
109 <xsl:with-param name="uri" select="$uri2"/>
110 <xsl:with-param name="cook" select="@cook"/>
111 <xsl:with-param name="hide" select="@hide"/>
112 <xsl:with-param name="arity" select="@arity"/>
113 <xsl:with-param name="m-tag" select="@m-tag"/>
114 <xsl:with-param name="c-tag" select="'MUTIND'"/>
115 <xsl:with-param name="const" select="$const"/>
122 <xsl:template match="OpSet|NotOpSet">
123 <xsl:variable name="uri">
124 <xsl:call-template name="remove_white_spaces">
125 <xsl:with-param name="uri" select="@uri"/>
129 <xsl:variable name="not">
131 <xsl:when test="name() = 'OpSet'">false</xsl:when>
132 <xsl:otherwise>true</xsl:otherwise>
136 <xsl:variable name="const">
137 <xsl:value-of select="*[name() = 'Case']/@arity = 0 and @hide = 0 and @cook = 'false'"/>
141 <xsl:when test="$const = 'false' and $not = 'true'">
142 <xsl:call-template name="out_comment">
143 <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
146 <xsl:when test="$const = 'true'">
147 <xsl:call-template name="out_comment">
148 <xsl:with-param name="name" select="concat($uri,': cannot be specified a constant operator when using OpSet element')"/>
152 <xsl:variable name="uri1">
153 <xsl:call-template name="select_uris">
154 <xsl:with-param name="uris" select="$uri"/>
155 <xsl:with-param name="c-tag" select="'CONST'"/>
159 <xsl:variable name="uri2">
160 <xsl:call-template name="select_uris">
161 <xsl:with-param name="uris" select="$uri"/>
162 <xsl:with-param name="c-tag" select="'MUTIND'"/>
166 <xsl:if test="$uri1 != ''">
167 <xsl:call-template name="out_template_set">
168 <xsl:with-param name="name" select="@name"/>
169 <xsl:with-param name="not" select="$not"/>
170 <xsl:with-param name="uri" select="$uri1"/>
171 <xsl:with-param name="cook" select="@cook"/>
172 <xsl:with-param name="hide" select="@hide"/>
173 <xsl:with-param name="m-tag" select="@m-tag"/>
174 <xsl:with-param name="c-tag" select="'CONST'"/>
178 <xsl:if test="$uri2 != ''">
179 <xsl:call-template name="out_template_set">
180 <xsl:with-param name="name" select="@name"/>
181 <xsl:with-param name="not" select="$not"/>
182 <xsl:with-param name="uri" select="$uri2"/>
183 <xsl:with-param name="cook" select="@cook"/>
184 <xsl:with-param name="hide" select="@hide"/>
185 <xsl:with-param name="m-tag" select="@m-tag"/>
186 <xsl:with-param name="c-tag" select="'MUTIND'"/>
193 <!-- *********************************************************************** -->
194 <!-- MAIN FUNCTIONS -->
195 <!-- *********************************************************************** -->
198 <xsl:template name="out_template">
199 <xsl:param name="name"/>
200 <xsl:param name="not" select="'false'"/>
201 <xsl:param name="uri"/>
202 <xsl:param name="cook" select="'false'"/>
203 <xsl:param name="hide" select="0"/>
204 <xsl:param name="arity" select="0"/>
205 <xsl:param name="m-tag"/>
206 <xsl:param name="c-tag"/>
207 <xsl:param name="const" select="'false'"/>
209 <xsl:variable name="apply_not">
210 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
213 <xsl:variable name="match">
214 <xsl:variable name="match_op">
215 <xsl:call-template name="out_match_op">
216 <xsl:with-param name="not" select="$not"/>
217 <xsl:with-param name="uri" select="$uri"/>
218 <xsl:with-param name="c-tag" select="$c-tag"/>
222 <xsl:variable name="match_child">
223 <xsl:if test="$cook = 'false' or $not = 'true'">
225 <!-- if the operator has been concatenated with not, the root apply node must have only two child -->
226 <xsl:when test="$not = 'true' and $cook = 'true'"> and count(*) = 2</xsl:when>
227 <xsl:when test="$not = 'true' and $cook = 'false'">
228 <xsl:value-of select="concat(' and count(*) = 2 and count(*[2]/*) = ',$arity + $hide + 1)"/>
231 <xsl:value-of select="concat('count(*) = ',$arity + $hide + 1)"/>
238 <xsl:when test="$const = 'false'">
239 <xsl:value-of select="concat('APPLY[',$match_op,$match_child,']')"/>
242 <xsl:value-of select="$match_op"/>
247 <xsl:variable name="op_uri_attr">
248 <xsl:variable name="tmp_op_uri_attr">
249 <xsl:call-template name="op_uri_attr">
250 <xsl:with-param name="not" select="$not"/>
251 <xsl:with-param name="c-tag" select="$c-tag"/>
252 <xsl:with-param name="const" select="$const"/>
255 <xsl:value-of select="substring-after(substring-before($tmp_op_uri_attr,'}'),'{')"/>
259 <xsl:call-template name="out_comment">
260 <xsl:with-param name="name" select="$name"/>
263 <oxsl:template match="{$match}" mode="pure">
265 <xsl:when test="$cook = 'true'">
266 <oxsl:variable name="no_params">
267 <oxsl:call-template name="get_no_params">
268 <oxsl:with-param name="first_uri" select="$CICURI"/>
269 <oxsl:with-param name="second_uri" select="{$op_uri_attr}"/>
270 </oxsl:call-template>
273 <oxsl:when test="{concat('count(',$apply_not,'*) = $no_params + ',$arity + $hide + 1)}">
274 <xsl:call-template name="out_body">
275 <xsl:with-param name="c-tag" select="$c-tag"/>
276 <xsl:with-param name="m-tag" select="$m-tag"/>
277 <xsl:with-param name="cook" select="$cook"/>
278 <xsl:with-param name="hide" select="$hide"/>
279 <xsl:with-param name="arity" select="$arity"/>
280 <xsl:with-param name="not" select="$not"/>
281 <xsl:with-param name="const" select="$const"/>
285 <oxsl:apply-imports/>
290 <xsl:call-template name="out_body">
291 <xsl:with-param name="c-tag" select="$c-tag"/>
292 <xsl:with-param name="m-tag" select="$m-tag"/>
293 <xsl:with-param name="cook" select="$cook"/>
294 <xsl:with-param name="hide" select="$hide"/>
295 <xsl:with-param name="arity" select="$arity"/>
296 <xsl:with-param name="not" select="$not"/>
297 <xsl:with-param name="const" select="$const"/>
304 <xsl:template name="out_template_set">
305 <xsl:param name="name"/>
306 <xsl:param name="not" select="'false'"/>
307 <xsl:param name="cook" select="'false'"/>
308 <xsl:param name="uri"/>
309 <xsl:param name="hide" select="0"/>
310 <xsl:param name="m-tag"/>
311 <xsl:param name="c-tag"/>
313 <xsl:variable name="no_params_var">
314 <xsl:if test="$cook = 'true'">$no_params + </xsl:if>
317 <xsl:variable name="match">
318 <xsl:variable name="match_op">
319 <xsl:call-template name="out_match_op">
320 <xsl:with-param name="not" select="$not"/>
321 <xsl:with-param name="uri" select="$uri"/>
322 <xsl:with-param name="c-tag" select="$c-tag"/>
326 <xsl:variable name="match_child">
327 <xsl:if test="$not = 'true'"> and count(*) = 2</xsl:if>
330 <xsl:value-of select="concat('APPLY[',$match_op,$match_child,']')"/>
333 <xsl:variable name="apply_not">
334 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
337 <xsl:variable name="op_uri_attr">
338 <xsl:variable name="tmp_op_uri_attr">
339 <xsl:call-template name="op_uri_attr">
340 <xsl:with-param name="not" select="$not"/>
341 <xsl:with-param name="c-tag" select="$c-tag"/>
344 <xsl:value-of select="substring-after(substring-before($tmp_op_uri_attr,'}'),'{')"/>
349 <xsl:call-template name="out_comment">
350 <xsl:with-param name="name" select="$name"/>
353 <oxsl:template match="{$match}" mode="pure">
354 <xsl:if test="$cook = 'true'">
355 <oxsl:variable name="no_params">
356 <oxsl:call-template name="get_no_params">
357 <oxsl:with-param name="first_uri" select="$CICURI"/>
358 <oxsl:with-param name="second_uri" select="{$op_uri_attr}"/>
359 </oxsl:call-template>
363 <xsl:for-each select="Case">
364 <oxsl:when test="{concat('count(',$apply_not,'*) = ',$no_params_var,@arity + $hide + 1)}">
365 <xsl:call-template name="out_body">
366 <xsl:with-param name="c-tag" select="$c-tag"/>
367 <xsl:with-param name="m-tag" select="$m-tag"/>
368 <xsl:with-param name="cook" select="$cook"/>
369 <xsl:with-param name="hide" select="$hide"/>
370 <xsl:with-param name="arity" select="@arity"/>
371 <xsl:with-param name="not" select="$not"/>
376 <oxsl:apply-imports/>
382 <xsl:template name="out_comment">
383 <xsl:param name="name"/>
384 <xsl:if test="$name">
386 <xsl:value-of select="concat(' ',$name,' ')"/>
391 <!-- Returns a regular expression with matching operators -->
392 <xsl:template name="out_match_op">
393 <xsl:param name="not" select="'false'"/>
394 <xsl:param name="uri"/>
395 <xsl:param name="c-tag"/>
397 <!-- application with not operator -->
398 <xsl:variable name="app_not">
399 <xsl:if test="$not = 'true'">CONST[@uri='cic:/Coq/Init/Logic/not.con'] and </xsl:if>
402 <xsl:variable name="uris">
403 <xsl:call-template name="test_on_uris">
404 <xsl:with-param name="uris" select="$uri"/>
408 <xsl:variable name="app_op">
409 <xsl:if test="$not = 'true'">APPLY[</xsl:if>
410 <xsl:value-of select="concat($c-tag,'[',$uris,']')"/>
411 <xsl:if test="$not = 'true'">]</xsl:if>
414 <xsl:value-of select="concat($app_not,$app_op)"/>
417 <xsl:template name="out_params">
418 <xsl:param name="params" select="1"/>
419 <xsl:param name="cook" select="'false'"/>
420 <xsl:param name="hide" select="0"/>
421 <xsl:param name="not" select="'false'"/>
422 <xsl:param name="mode" select="'noannot'"/>
423 <xsl:param name="arity" select="0"/>
425 <xsl:if test="$params <= $arity">
426 <xsl:variable name="param">
427 <xsl:call-template name="param">
428 <xsl:with-param name="id" select="$params"/>
429 <xsl:with-param name="not" select="$not"/>
430 <xsl:with-param name="cook" select="$cook"/>
431 <xsl:with-param name="hide" select="$hide"/>
435 <oxsl:apply-templates select="{$param}" mode="{$mode}"/>
437 <xsl:call-template name="out_params">
438 <xsl:with-param name="params" select="$params + 1"/>
439 <xsl:with-param name="cook" select="$cook"/>
440 <xsl:with-param name="hide" select="$hide"/>
441 <xsl:with-param name="not" select="$not"/>
442 <xsl:with-param name="mode" select="$mode"/>
443 <xsl:with-param name="arity" select="$arity"/>
449 <xsl:template name="out_body">
450 <xsl:param name="c-tag"/>
451 <xsl:param name="cook" select="'false'"/>
452 <xsl:param name="m-tag"/>
453 <xsl:param name="hide" select="0"/>
454 <xsl:param name="arity" select="0"/>
455 <xsl:param name="not" select="'false'"/>
456 <xsl:param name="const" select="'false'"/>
459 <!-- SIMPLE TRANSFORMATIONS -->
460 <xsl:when test="count(*) = 0">
461 <xsl:variable name="xref">
462 <xsl:if test="$const = 'false'">{@id}</xsl:if>
465 <xsl:variable name="definitionURL">
466 <xsl:call-template name="op_uri_attr">
467 <xsl:with-param name="not" select="$not"/>
468 <xsl:with-param name="c-tag" select="$c-tag"/>
469 <xsl:with-param name="const" select="$const"/>
473 <xsl:variable name="helm:xref">
474 <xsl:call-template name="op_id_attr">
475 <xsl:with-param name="not" select="$not"/>
476 <xsl:with-param name="c-tag" select="$c-tag"/>
477 <xsl:with-param name="const" select="$const"/>
482 <m:apply helm:xref="{$xref}">
484 <xsl:element name="{concat('m:',$m-tag)}">
485 <xsl:attribute name="definitionURL">
486 <xsl:value-of select="$definitionURL"/>
488 <xsl:attribute name="helm:xref">
489 <xsl:value-of select="$helm:xref"/>
493 <xsl:call-template name="out_params">
494 <xsl:with-param name="cook" select="$cook"/>
495 <xsl:with-param name="hide" select="$hide"/>
496 <xsl:with-param name="not" select="$not"/>
497 <xsl:with-param name="arity" select="$arity"/>
501 <!-- COMPLEX TRANSFORMATIONS -->
503 <xsl:apply-templates>
504 <xsl:with-param name="c-tag" select="$c-tag"/>
505 <xsl:with-param name="cook" select="$cook"/>
506 <xsl:with-param name="hide" select="$hide"/>
507 <xsl:with-param name="arity" select="$arity"/>
508 <xsl:with-param name="not" select="$not"/>
509 <xsl:with-param name="const" select="$const"/>
510 </xsl:apply-templates>
515 <xsl:template name="out_mvar">
516 <xsl:param name="vname"/>
520 <xsl:when test="(ancestor-or-self::*[preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)]]/preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)])[position() = last()]">
521 <oxsl:value-of select="{concat('$bvar_',$vname)}"/>
524 <xsl:value-of select="$vname"/>
531 <xsl:template name="out_choose_binder">
532 <xsl:param name="binded_params" select="''"/>
533 <xsl:param name="not" select="'false'"/>
534 <xsl:param name="cook" select="'false'"/>
535 <xsl:param name="hide" select="0"/>
536 <xsl:param name="binder"/>
538 <xsl:if test="$binded_params != ''">
540 <xsl:when test="contains($binded_params,'+')">
541 <xsl:call-template name="out_choose_binder">
542 <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
543 <xsl:with-param name="not" select="$not"/>
544 <xsl:with-param name="cook" select="$cook"/>
545 <xsl:with-param name="hide" select="$hide"/>
546 <xsl:with-param name="binder" select="$binder"/>
549 <xsl:call-template name="out_choose_binder">
550 <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
551 <xsl:with-param name="not" select="$not"/>
552 <xsl:with-param name="cook" select="$cook"/>
553 <xsl:with-param name="hide" select="$hide"/>
554 <xsl:with-param name="binder" select="$binder"/>
558 <xsl:variable name="param">
559 <xsl:call-template name="param">
560 <xsl:with-param name="id" select="$binded_params"/>
561 <xsl:with-param name="not" select="$not"/>
562 <xsl:with-param name="cook" select="$cook"/>
563 <xsl:with-param name="hide" select="$hide"/>
567 <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
568 <oxsl:value-of select="{concat($param,$binder)}"/>
575 <!-- *********************************************************************** -->
576 <!-- META LANGUAGE FOR MathML -->
577 <!-- *********************************************************************** -->
579 <xsl:template match="mapp">
580 <xsl:param name="c-tag"/>
581 <xsl:param name="cook" select="'false'"/>
582 <xsl:param name="hide" select="0"/>
583 <xsl:param name="arity" select="0"/>
584 <xsl:param name="not" select="'false'"/>
585 <xsl:param name="const" select="'false'"/>
587 <xsl:variable name="helm:xref">
589 <xsl:when test="@xref">
590 <xsl:call-template name="set_attribute">
591 <xsl:with-param name="attr" select="@xref"/>
592 <xsl:with-param name="c-tag" select="$c-tag"/>
593 <xsl:with-param name="hide" select="$hide"/>
594 <xsl:with-param name="arity" select="$arity"/>
595 <xsl:with-param name="not" select="$not"/>
596 <xsl:with-param name="const" select="$const"/>
600 <xsl:if test="$const = 'false'">{@id}</xsl:if>
605 <m:apply helm:xref="{$helm:xref}">
606 <xsl:call-template name="copy_attributes">
607 <xsl:with-param name="c-tag" select="$c-tag"/>
608 <xsl:with-param name="hide" select="$hide"/>
609 <xsl:with-param name="arity" select="$arity"/>
610 <xsl:with-param name="not" select="$not"/>
611 <xsl:with-param name="const" select="$const"/>
612 <xsl:with-param name="ignore" select="'xref'"/>
615 <xsl:apply-templates>
616 <xsl:with-param name="c-tag" select="$c-tag"/>
617 <xsl:with-param name="cook" select="$cook"/>
618 <xsl:with-param name="hide" select="$hide"/>
619 <xsl:with-param name="arity" select="$arity"/>
620 <xsl:with-param name="not" select="$not"/>
621 <xsl:with-param name="const" select="$const"/>
622 </xsl:apply-templates>
627 <xsl:template match="mop">
628 <xsl:param name="c-tag"/>
629 <xsl:param name="cook" select="'false'"/>
630 <xsl:param name="hide" select="0"/>
631 <xsl:param name="arity" select="0"/>
632 <xsl:param name="not" select="'false'"/>
633 <xsl:param name="const" select="'false'"/>
635 <!-- set definitonURL attribute -->
636 <xsl:variable name="definitionURL">
638 <xsl:when test="@definitionURL">
639 <xsl:call-template name="set_attribute">
640 <xsl:with-param name="attr" select="@definitionURL"/>
641 <xsl:with-param name="c-tag" select="$c-tag"/>
642 <xsl:with-param name="hide" select="$hide"/>
643 <xsl:with-param name="arity" select="$arity"/>
644 <xsl:with-param name="not" select="$not"/>
645 <xsl:with-param name="const" select="$const"/>
649 <xsl:call-template name="op_uri_attr">
650 <xsl:with-param name="not" select="$not"/>
651 <xsl:with-param name="c-tag" select="$c-tag"/>
652 <xsl:with-param name="const" select="$const"/>
658 <!-- set helm:xref attribute -->
659 <xsl:variable name="helm:xref">
661 <xsl:when test="@xref">
662 <xsl:call-template name="set_attribute">
663 <xsl:with-param name="attr" select="@xref"/>
664 <xsl:with-param name="c-tag" select="$c-tag"/>
665 <xsl:with-param name="hide" select="$hide"/>
666 <xsl:with-param name="arity" select="$arity"/>
667 <xsl:with-param name="not" select="$not"/>
668 <xsl:with-param name="const" select="$const"/>
672 <xsl:call-template name="op_id_attr">
673 <xsl:with-param name="not" select="$not"/>
674 <xsl:with-param name="c-tag" select="$c-tag"/>
675 <xsl:with-param name="const" select="$const"/>
681 <xsl:element name="{concat('m:',@tag)}">
682 <xsl:attribute name="definitionURL">
683 <xsl:value-of select="$definitionURL"/>
685 <xsl:attribute name="helm:xref">
686 <xsl:value-of select="$helm:xref"/>
689 <xsl:call-template name="copy_attributes">
690 <xsl:with-param name="c-tag" select="$c-tag"/>
691 <xsl:with-param name="hide" select="$hide"/>
692 <xsl:with-param name="arity" select="$arity"/>
693 <xsl:with-param name="not" select="$not"/>
694 <xsl:with-param name="const" select="$const"/>
695 <xsl:with-param name="ignore" select="'xref + definitionURL + tag'"/>
698 <xsl:apply-templates>
699 <xsl:with-param name="c-tag" select="$c-tag"/>
700 <xsl:with-param name="cook" select="$cook"/>
701 <xsl:with-param name="hide" select="$hide"/>
702 <xsl:with-param name="arity" select="$arity"/>
703 <xsl:with-param name="not" select="$not"/>
704 <xsl:with-param name="const" select="$const"/>
705 </xsl:apply-templates>
709 <xsl:template match="param">
710 <xsl:param name="cook" select="'false'"/>
711 <xsl:param name="hide" select="0"/>
712 <xsl:param name="not" select="'false'"/>
714 <xsl:variable name="param">
715 <xsl:call-template name="param">
716 <xsl:with-param name="id" select="@id"/>
717 <xsl:with-param name="not" select="$not"/>
718 <xsl:with-param name="cook" select="$cook"/>
719 <xsl:with-param name="hide" select="$hide"/>
724 <xsl:when test="@bvar">
726 <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
727 <oxsl:apply-templates select="{concat($param,'/target')}" mode="{@mode}"/>
731 <m:csymbol>app</m:csymbol>
732 <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
734 <xsl:value-of select="@bvar"/>
741 <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
746 <xsl:template match="m:*">
747 <xsl:param name="c-tag"/>
748 <xsl:param name="cook" select="'false'"/>
749 <xsl:param name="hide" select="0"/>
750 <xsl:param name="arity" select="0"/>
751 <xsl:param name="not" select="'false'"/>
752 <xsl:param name="const" select="'false'"/>
755 <xsl:call-template name="copy_attributes">
756 <xsl:with-param name="c-tag" select="$c-tag"/>
757 <xsl:with-param name="hide" select="$hide"/>
758 <xsl:with-param name="arity" select="$arity"/>
759 <xsl:with-param name="not" select="$not"/>
760 <xsl:with-param name="const" select="$const"/>
763 <xsl:apply-templates>
764 <xsl:with-param name="c-tag" select="$c-tag"/>
765 <xsl:with-param name="cook" select="$cook"/>
766 <xsl:with-param name="hide" select="$hide"/>
767 <xsl:with-param name="arity" select="$arity"/>
768 <xsl:with-param name="not" select="$not"/>
769 <xsl:with-param name="const" select="$const"/>
770 </xsl:apply-templates>
774 <xsl:template match="mbvar">
775 <xsl:param name="c-tag"/>
776 <xsl:param name="cook" select="'false'"/>
777 <xsl:param name="hide" select="0"/>
778 <xsl:param name="arity" select="0"/>
779 <xsl:param name="not" select="'false'"/>
780 <xsl:param name="const" select="'false'"/>
782 <xsl:variable name="binded_params">
783 <xsl:call-template name="get_binded_params">
784 <xsl:with-param name="var" select="@name"/>
785 <xsl:with-param name="node" select="following-sibling::*"/>
789 <xsl:variable name="test">
790 <xsl:call-template name="test_on_lambda">
791 <xsl:with-param name="binded_params" select="$binded_params"/>
792 <xsl:with-param name="not" select="$not"/>
793 <xsl:with-param name="cook" select="$cook"/>
794 <xsl:with-param name="hide" select="$hide"/>
798 <xsl:variable name="binder">/target/@binder</xsl:variable>
801 <xsl:when test="$binded_params != ''">
802 <oxsl:variable name="{concat('bvar_',@name)}">
804 <!-- one or more lambdas exist -->
805 <oxsl:when test="{$test}">
807 <!-- binded params > 1 (more than 1 lambda) -->
808 <xsl:when test="contains($binded_params,'+')">
809 <oxsl:variable name="binder">
811 <xsl:call-template name="out_choose_binder">
812 <xsl:with-param name="binded_params" select="$binded_params"/>
813 <xsl:with-param name="not" select="$not"/>
814 <xsl:with-param name="hide" select="$hide"/>
815 <xsl:with-param name="cook" select="$cook"/>
816 <xsl:with-param name="binder" select="$binder"/>
820 <oxsl:call-template name="insert_subscript">
821 <oxsl:with-param name="node_value" select="$binder"/>
822 </oxsl:call-template>
824 <!-- binded parms = 1 (1 lambda) -->
826 <xsl:variable name="param">
827 <xsl:call-template name="param">
828 <xsl:with-param name="id" select="$binded_params"/>
829 <xsl:with-param name="not" select="$not"/>
830 <xsl:with-param name="cook" select="$cook"/>
831 <xsl:with-param name="hide" select="$hide"/>
835 <oxsl:call-template name="insert_subscript">
836 <oxsl:with-param name="node_value" select="{concat($param,$binder)}"/>
837 </oxsl:call-template>
841 <!-- no one lambda -->
843 <xsl:value-of select="@name"/>
850 <oxsl:value-of select="{concat('$bvar_',@name)}"/>
852 <xsl:apply-templates>
853 <xsl:with-param name="c-tag" select="$c-tag"/>
854 <xsl:with-param name="cook" select="$cook"/>
855 <xsl:with-param name="hide" select="$hide"/>
856 <xsl:with-param name="arity" select="$arity"/>
857 <xsl:with-param name="not" select="$not"/>
858 <xsl:with-param name="const" select="$const"/>
859 </xsl:apply-templates>
865 <xsl:value-of select="@name"/>
867 <xsl:apply-templates>
868 <xsl:with-param name="c-tag" select="$c-tag"/>
869 <xsl:with-param name="cook" select="$cook"/>
870 <xsl:with-param name="hide" select="$hide"/>
871 <xsl:with-param name="arity" select="$arity"/>
872 <xsl:with-param name="not" select="$not"/>
873 <xsl:with-param name="const" select="$const"/>
874 </xsl:apply-templates>
880 <xsl:template match="mvar">
881 <xsl:call-template name="out_mvar">
882 <xsl:with-param name="vname" select="@name"/>
888 <!-- *********************************************************************** -->
889 <!-- AUXILIARY FUNCTIONS -->
890 <!-- *********************************************************************** -->
893 <!-- Returns a value if all uris in the list have the same c-tag -->
894 <xsl:template name="get_c_tag">
895 <xsl:param name="uri" select="''"/>
897 <xsl:if test="$uri != ''">
899 <xsl:when test="contains($uri,'|')">
900 <xsl:variable name="c-tag1">
901 <xsl:call-template name="get_c_tag">
902 <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
906 <xsl:variable name="c-tag2">
907 <xsl:call-template name="get_c_tag">
908 <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
912 <xsl:if test="$c-tag1 = $c-tag2">
913 <xsl:value-of select="$c-tag1"/>
918 <xsl:when test="substring($uri,string-length($uri)-3) = '.con'">CONST</xsl:when>
919 <xsl:when test="substring($uri,string-length($uri)-3) = '.ind'">MUTIND</xsl:when>
926 <!-- Creates a list selecting uris according to c-tag specified -->
927 <xsl:template name="select_uris">
928 <xsl:param name="uris" select="''"/>
929 <xsl:param name="c-tag"/>
931 <xsl:if test="$uris != ''">
933 <xsl:when test="contains($uris,'|')">
934 <xsl:variable name="list1">
935 <xsl:call-template name="select_uris">
936 <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
937 <xsl:with-param name="c-tag" select="$c-tag"/>
941 <xsl:variable name="list2">
942 <xsl:call-template name="select_uris">
943 <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
944 <xsl:with-param name="c-tag" select="$c-tag"/>
949 <xsl:when test="$list1 != '' and $list2 != ''">
950 <xsl:value-of select="concat($list1,'|',$list2)"/>
952 <xsl:when test="$list1 != '' and $list2 = ''">
953 <xsl:value-of select="$list1"/>
955 <xsl:when test="$list1 = '' and $list2 != ''">
956 <xsl:value-of select="$list2"/>
961 <xsl:variable name="c-tag1">
962 <xsl:call-template name="get_c_tag">
963 <xsl:with-param name="uri" select="$uris"/>
967 <xsl:if test="$c-tag1 = $c-tag">
968 <xsl:value-of select="$uris"/>
975 <!-- Returns a xpath expression matching on uri attributes -->
976 <xsl:template name="test_on_uris">
977 <xsl:param name="uris" select="''"/>
979 <xsl:if test="$uris != ''">
981 <xsl:when test="contains($uris,'|')">
982 <xsl:variable name="expr1">
983 <xsl:call-template name="test_on_uris">
984 <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
988 <xsl:variable name="expr2">
989 <xsl:call-template name="test_on_uris">
990 <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
994 <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
997 <xsl:value-of select="concat('@uri=',"'",$uris,"'")"/>
1003 <!-- Returns a xpath expression testing on LAMBDA node existence -->
1004 <xsl:template name="test_on_lambda">
1005 <xsl:param name="binded_params" select="''"/>
1006 <xsl:param name="not" select="'false'"/>
1007 <xsl:param name="cook" select="'false'"/>
1008 <xsl:param name="hide" select="0"/>
1010 <xsl:if test="$binded_params != ''">
1012 <xsl:when test="contains($binded_params,'+')">
1013 <xsl:variable name="expr1">
1014 <xsl:call-template name="test_on_lambda">
1015 <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
1016 <xsl:with-param name="not" select="$not"/>
1017 <xsl:with-param name="cook" select="$cook"/>
1018 <xsl:with-param name="hide" select="$hide"/>
1019 </xsl:call-template>
1022 <xsl:variable name="expr2">
1023 <xsl:call-template name="test_on_lambda">
1024 <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
1025 <xsl:with-param name="not" select="$not"/>
1026 <xsl:with-param name="cook" select="$cook"/>
1027 <xsl:with-param name="hide" select="$hide"/>
1028 </xsl:call-template>
1031 <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
1034 <xsl:variable name="param">
1035 <xsl:call-template name="param">
1036 <xsl:with-param name="id" select="$binded_params"/>
1037 <xsl:with-param name="not" select="$not"/>
1038 <xsl:with-param name="cook" select="$cook"/>
1039 <xsl:with-param name="hide" select="$hide"/>
1040 </xsl:call-template>
1043 <xsl:value-of select="concat('name(',$param,') = ',"'LAMBDA'")"/>
1049 <!-- Removes white spaces from uris list -->
1050 <xsl:template name="remove_white_spaces">
1051 <xsl:param name="uri" select="''"/>
1053 <xsl:if test="$uri != ''">
1055 <xsl:when test="contains($uri,'|')">
1056 <xsl:variable name="uri1">
1057 <xsl:call-template name="remove_white_spaces">
1058 <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
1059 </xsl:call-template>
1062 <xsl:variable name="uri2">
1063 <xsl:call-template name="remove_white_spaces">
1064 <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
1065 </xsl:call-template>
1068 <xsl:value-of select="concat($uri1,'|',$uri2)"/>
1071 <xsl:value-of select="normalize-space($uri)"/>
1078 Returns a list of params id attributes concatenated with '+'.
1079 The params'id attribute are selected according to the value of bindig variable 'var'
1081 <xsl:template name="get_binded_params">
1082 <xsl:param name="var"/>
1083 <xsl:param name="node"/>
1085 <xsl:if test="count($node) != 0">
1087 <!-- another variable declaration with same name -->
1088 <xsl:when test="($node[1][name() = 'mbvar']) and ($node[1][@name = $var])"></xsl:when>
1089 <!-- a binded param -->
1090 <xsl:when test="($node[1][name() = 'param']) and ($node[1][@bvar = $var])">
1091 <!-- search on siblings -->
1092 <xsl:variable name="siblings_params">
1093 <xsl:call-template name="get_binded_params">
1094 <xsl:with-param name="var" select="$var"/>
1095 <xsl:with-param name="node" select="$node[position() > 1]"/>
1096 </xsl:call-template>
1099 <xsl:when test="$siblings_params != ''">
1100 <xsl:value-of select="concat($node[1]/@id,'+',$siblings_params)"/>
1103 <xsl:value-of select="$node[1]/@id"/>
1108 <!-- search on siblings -->
1109 <xsl:variable name="siblings_params">
1110 <xsl:call-template name="get_binded_params">
1111 <xsl:with-param name="var" select="$var"/>
1112 <xsl:with-param name="node" select="$node[position() > 1]"/>
1113 </xsl:call-template>
1115 <!-- search on children -->
1116 <xsl:variable name="children_params">
1117 <xsl:call-template name="get_binded_params">
1118 <xsl:with-param name="var" select="$var"/>
1119 <xsl:with-param name="node" select="$node[1]/child::*"/>
1120 </xsl:call-template>
1124 <xsl:when test="$children_params != '' and $siblings_params != ''">
1125 <xsl:value-of select="concat($children_params,'+',$siblings_params)"/>
1127 <xsl:when test="$children_params != '' and $siblings_params = ''">
1128 <xsl:value-of select="$children_params"/>
1130 <xsl:when test="$children_params = '' and $siblings_params != ''">
1131 <xsl:value-of select="$siblings_params"/>
1139 <!-- Returns a xpath string with the location of the parameter with the id specified -->
1140 <xsl:template name="param">
1141 <xsl:param name="id"/>
1142 <xsl:param name="not" select="'false'"/>
1143 <xsl:param name="cook" select="'false'"/>
1144 <xsl:param name="hide" select="0"/>
1146 <xsl:variable name="apply_not">
1147 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
1150 <xsl:variable name="no_params_var">
1151 <xsl:if test="$cook = 'true'">$no_params+</xsl:if>
1154 <xsl:value-of select="concat($apply_not,'*[',$no_params_var,$id + $hide + 1,']')"/>
1157 <!-- Returns a xpath string with the location of the operator uri attribute -->
1158 <xsl:template name="op_uri_attr">
1159 <xsl:param name="not" select="'false'"/>
1160 <xsl:param name="c-tag"/>
1161 <xsl:param name="const" select="'false'"/>
1163 <xsl:call-template name="op_attr">
1164 <xsl:with-param name="attr_type" select="'@uri'"/>
1165 <xsl:with-param name="not" select="$not"/>
1166 <xsl:with-param name="c-tag" select="$c-tag"/>
1167 <xsl:with-param name="const" select="$const"/>
1168 </xsl:call-template>
1171 <!-- Returns a xpath string with the location of the operator id attribute -->
1172 <xsl:template name="op_id_attr">
1173 <xsl:param name="not" select="'false'"/>
1174 <xsl:param name="c-tag"/>
1175 <xsl:param name="const" select="'false'"/>
1177 <xsl:call-template name="op_attr">
1178 <xsl:with-param name="attr_type" select="'@id'"/>
1179 <xsl:with-param name="not" select="$not"/>
1180 <xsl:with-param name="c-tag" select="$c-tag"/>
1181 <xsl:with-param name="const" select="$const"/>
1182 </xsl:call-template>
1186 <!-- Returns a xpath string with the location of the operator uri or id attribute -->
1187 <xsl:template name="op_attr">
1188 <xsl:param name="attr_type"/>
1189 <xsl:param name="not" select="'false'"/>
1190 <xsl:param name="c-tag"/>
1191 <xsl:param name="const" select="'false'"/>
1193 <xsl:variable name="apply">
1194 <xsl:if test="$not = 'true'">APPLY/</xsl:if>
1198 <xsl:when test="$const = 'true'">
1199 <xsl:value-of select="concat('{',$attr_type,'}')"/>
1202 <xsl:value-of select="concat('{',$apply,$c-tag,'/',$attr_type,'}')"/>
1207 <xsl:template name="copy_attributes">
1208 <xsl:param name="c-tag"/>
1209 <xsl:param name="hide" select="0"/>
1210 <xsl:param name="arity" select="0"/>
1211 <xsl:param name="not" select="'false'"/>
1212 <xsl:param name="const" select="'false'"/>
1213 <xsl:param name="ignore" select="''"/>
1215 <xsl:variable name="test">
1216 <xsl:call-template name="test_on_attributes">
1217 <xsl:with-param name="names" select="$ignore"/>
1218 </xsl:call-template>
1221 <xsl:for-each select="@*">
1222 <xsl:if test="contains($test,concat('+',name(),'+')) = false()">
1223 <xsl:variable name="name">
1225 <xsl:when test="name() = 'xref'">helm:xref</xsl:when>
1227 <xsl:value-of select="name()"/>
1232 <xsl:attribute name="{$name}">
1233 <xsl:call-template name="set_attribute">
1234 <xsl:with-param name="attr" select="."/>
1235 <xsl:with-param name="c-tag" select="$c-tag"/>
1236 <xsl:with-param name="hide" select="$hide"/>
1237 <xsl:with-param name="arity" select="$arity"/>
1238 <xsl:with-param name="not" select="$not"/>
1239 <xsl:with-param name="const" select="$const"/>
1240 </xsl:call-template>
1246 <xsl:template name="test_on_attributes">
1247 <xsl:param name="names" select="''"/>
1250 <xsl:when test="contains($names,'+')">
1251 <xsl:variable name="name">
1252 <xsl:call-template name="test_on_attributes">
1253 <xsl:with-param name="names" select="normalize-space(substring-after($names,'+'))"/>
1254 </xsl:call-template>
1257 <xsl:value-of select="concat('+',normalize-space(substring-before($names,'+')),$name)"/>
1260 <xsl:value-of select="concat('+',normalize-space($names),'+')"/>
1265 <xsl:template name="set_attribute">
1266 <xsl:param name="attr"/>
1267 <xsl:param name="c-tag"/>
1268 <xsl:param name="hide" select="0"/>
1269 <xsl:param name="arity" select="0"/>
1270 <xsl:param name="not" select="'false'"/>
1271 <xsl:param name="const" select="'false'"/>
1274 <xsl:when test="$attr = '$APP-ID'">
1275 <xsl:if test="$const = 'false'">{@id}</xsl:if>
1277 <xsl:when test="$attr = '$OP-ID' or $attr = '$OP-URI'">
1278 <xsl:variable name="attr_type">
1280 <xsl:when test="$attr = '$OP-ID'">@id</xsl:when>
1281 <xsl:otherwise>@uri</xsl:otherwise>
1285 <xsl:call-template name="op_attr">
1286 <xsl:with-param name="attr_type" select="$attr_type"/>
1287 <xsl:with-param name="not" select="$not"/>
1288 <xsl:with-param name="c-tag" select="$c-tag"/>
1289 <xsl:with-param name="const" select="$const"/>
1290 </xsl:call-template>
1293 <xsl:value-of select="$attr"/>