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}"/>
51 <xsl:template match="Operator|NotOperator">
52 <xsl:variable name="uri">
53 <xsl:call-template name="remove_white_spaces">
54 <xsl:with-param name="uri" select="@uri"/>
58 <xsl:variable name="not">
60 <xsl:when test="name() = 'Operator'">false</xsl:when>
61 <xsl:otherwise>true</xsl:otherwise>
66 <xsl:when test="@arity = 0 and @hide = 0 and $not = 'true'">
67 <xsl:call-template name="out_comment">
68 <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
71 <xsl:when test="@arity = 0 and @hide = 0 and @cook = 'true'">
72 <xsl:call-template name="out_comment">
73 <xsl:with-param name="name" select="concat($uri,': a constant operator cannot be cooked')"/>
77 <!-- All uris in uri1 list (if not empty) have CONST c-tag -->
78 <xsl:variable name="uri1">
79 <xsl:call-template name="select_uris">
80 <xsl:with-param name="uris" select="$uri"/>
81 <xsl:with-param name="c-tag" select="'CONST'"/>
85 <!-- All uris in uri2 list (if not empty) have MUTIND c-tag -->
86 <xsl:variable name="uri2">
87 <xsl:call-template name="select_uris">
88 <xsl:with-param name="uris" select="$uri"/>
89 <xsl:with-param name="c-tag" select="'MUTIND'"/>
93 <xsl:if test="$uri1 != ''">
94 <xsl:call-template name="out_template">
95 <xsl:with-param name="name" select="@name"/>
96 <xsl:with-param name="not" select="$not"/>
97 <xsl:with-param name="uri" select="$uri1"/>
98 <xsl:with-param name="hide" select="@hide"/>
99 <xsl:with-param name="arity" select="@arity"/>
100 <xsl:with-param name="m-tag" select="@m-tag"/>
101 <xsl:with-param name="c-tag" select="'CONST'"/>
103 <xsl:if test="@cook = 'true'">
104 <xsl:call-template name="out_template">
105 <xsl:with-param name="name" select="@name"/>
106 <xsl:with-param name="not" select="$not"/>
107 <xsl:with-param name="uri" select="$uri1"/>
108 <xsl:with-param name="cook" select="@cook"/>
109 <xsl:with-param name="hide" select="@hide"/>
110 <xsl:with-param name="arity" select="@arity"/>
111 <xsl:with-param name="m-tag" select="@m-tag"/>
112 <xsl:with-param name="c-tag" select="'CONST'"/>
117 <xsl:if test="$uri2 != ''">
118 <xsl:call-template name="out_template">
119 <xsl:with-param name="name" select="@name"/>
120 <xsl:with-param name="not" select="$not"/>
121 <xsl:with-param name="uri" select="$uri2"/>
122 <xsl:with-param name="hide" select="@hide"/>
123 <xsl:with-param name="arity" select="@arity"/>
124 <xsl:with-param name="m-tag" select="@m-tag"/>
125 <xsl:with-param name="c-tag" select="'MUTIND'"/>
127 <xsl:if test="@cook = 'true'">
128 <xsl:call-template name="out_template">
129 <xsl:with-param name="name" select="@name"/>
130 <xsl:with-param name="not" select="$not"/>
131 <xsl:with-param name="uri" select="$uri2"/>
132 <xsl:with-param name="cook" select="@cook"/>
133 <xsl:with-param name="hide" select="@hide"/>
134 <xsl:with-param name="arity" select="@arity"/>
135 <xsl:with-param name="m-tag" select="@m-tag"/>
136 <xsl:with-param name="c-tag" select="'MUTIND'"/>
144 <xsl:template match="OpSet|NotOpSet">
145 <xsl:variable name="uri">
146 <xsl:call-template name="remove_white_spaces">
147 <xsl:with-param name="uri" select="@uri"/>
151 <xsl:variable name="not">
153 <xsl:when test="name() = 'OpSet'">false</xsl:when>
154 <xsl:otherwise>true</xsl:otherwise>
159 <xsl:when test="*[name() = 'Case']/@arity = 0 and @hide = 0 and $not = 'true'">
160 <xsl:call-template name="out_comment">
161 <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
164 <xsl:when test="*[name() = 'Case']/@arity = 0 and @hide = 0 and @cook = 'true'">
165 <xsl:call-template name="out_comment">
166 <xsl:with-param name="name" select="concat($uri,': a constant operator cannot be cooked')"/>
170 <xsl:variable name="uri1">
171 <xsl:call-template name="select_uris">
172 <xsl:with-param name="uris" select="$uri"/>
173 <xsl:with-param name="c-tag" select="'CONST'"/>
177 <xsl:variable name="uri2">
178 <xsl:call-template name="select_uris">
179 <xsl:with-param name="uris" select="$uri"/>
180 <xsl:with-param name="c-tag" select="'MUTIND'"/>
184 <xsl:if test="$uri1 != ''">
185 <xsl:call-template name="out_template_set">
186 <xsl:with-param name="name" select="@name"/>
187 <xsl:with-param name="not" select="$not"/>
188 <xsl:with-param name="uri" select="$uri1"/>
189 <xsl:with-param name="hide" select="@hide"/>
190 <xsl:with-param name="m-tag" select="@m-tag"/>
191 <xsl:with-param name="c-tag" select="'CONST'"/>
193 <xsl:if test="@cook = 'true'">
194 <xsl:call-template name="out_template_set">
195 <xsl:with-param name="name" select="@name"/>
196 <xsl:with-param name="not" select="$not"/>
197 <xsl:with-param name="uri" select="$uri1"/>
198 <xsl:with-param name="cook" select="@cook"/>
199 <xsl:with-param name="hide" select="@hide"/>
200 <xsl:with-param name="m-tag" select="@m-tag"/>
201 <xsl:with-param name="c-tag" select="'CONST'"/>
206 <xsl:if test="$uri2 != ''">
207 <xsl:call-template name="out_template_set">
208 <xsl:with-param name="name" select="@name"/>
209 <xsl:with-param name="not" select="$not"/>
210 <xsl:with-param name="uri" select="$uri2"/>
211 <xsl:with-param name="hide" select="@hide"/>
212 <xsl:with-param name="m-tag" select="@m-tag"/>
213 <xsl:with-param name="c-tag" select="'MUTIND'"/>
215 <xsl:if test="@cook = 'true'">
216 <xsl:call-template name="out_template_set">
217 <xsl:with-param name="name" select="@name"/>
218 <xsl:with-param name="not" select="$not"/>
219 <xsl:with-param name="uri" select="$uri2"/>
220 <xsl:with-param name="cook" select="@cook"/>
221 <xsl:with-param name="hide" select="@hide"/>
222 <xsl:with-param name="m-tag" select="@m-tag"/>
223 <xsl:with-param name="c-tag" select="'MUTIND'"/>
231 <!-- *********************************************************************** -->
232 <!-- MAIN FUNCTIONS -->
233 <!-- *********************************************************************** -->
236 <xsl:template name="out_template">
237 <xsl:param name="name"/>
238 <xsl:param name="not" select="'false'"/>
239 <xsl:param name="uri"/>
240 <xsl:param name="cook" select="'false'"/>
241 <xsl:param name="hide" select="0"/>
242 <xsl:param name="arity" select="0"/>
243 <xsl:param name="m-tag"/>
244 <xsl:param name="c-tag"/>
246 <xsl:variable name="match">
247 <xsl:call-template name="out_match">
248 <xsl:with-param name="not" select="$not"/>
249 <xsl:with-param name="uri" select="$uri"/>
250 <xsl:with-param name="cook" select="$cook"/>
251 <xsl:with-param name="hide" select="$hide"/>
252 <xsl:with-param name="arity" select="$arity"/>
253 <xsl:with-param name="c-tag" select="$c-tag"/>
258 <xsl:call-template name="out_comment">
259 <xsl:with-param name="name" select="$name"/>
262 <oxsl:template match="{$match}" mode="pure">
263 <xsl:call-template name="out_body">
264 <xsl:with-param name="c-tag" select="$c-tag"/>
265 <xsl:with-param name="m-tag" select="$m-tag"/>
266 <xsl:with-param name="cook" select="$cook"/>
267 <xsl:with-param name="hide" select="$hide"/>
268 <xsl:with-param name="arity" select="$arity"/>
269 <xsl:with-param name="not" select="$not"/>
274 <xsl:template name="out_template_set">
275 <xsl:param name="name"/>
276 <xsl:param name="not" select="'false'"/>
277 <xsl:param name="cook" select="'false'"/>
278 <xsl:param name="uri"/>
279 <xsl:param name="hide" select="0"/>
280 <xsl:param name="m-tag"/>
281 <xsl:param name="c-tag"/>
283 <xsl:variable name="match">
284 <xsl:call-template name="out_match_op">
285 <xsl:with-param name="not" select="$not"/>
286 <xsl:with-param name="cook" select="$cook"/>
287 <xsl:with-param name="uri" select="$uri"/>
288 <xsl:with-param name="c-tag" select="$c-tag"/>
292 <xsl:variable name="apply_not">
293 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
296 <xsl:variable name="op_uri_attr">
297 <xsl:call-template name="op_uri_attr">
298 <xsl:with-param name="not" select="$not"/>
299 <xsl:with-param name="c-tag" select="$c-tag"/>
305 <xsl:call-template name="out_comment">
306 <xsl:with-param name="name" select="$name"/>
309 <oxsl:template match="{concat('APPLY[',$match,']')}" mode="pure">
311 <xsl:for-each select="Case">
312 <oxsl:when test="{concat('count(',$apply_not,'*) = ',@arity + $hide + 1)}">
313 <xsl:call-template name="out_body">
314 <xsl:with-param name="c-tag" select="$c-tag"/>
315 <xsl:with-param name="m-tag" select="$m-tag"/>
316 <xsl:with-param name="cook" select="$cook"/>
317 <xsl:with-param name="hide" select="$hide"/>
318 <xsl:with-param name="arity" select="@arity"/>
319 <xsl:with-param name="not" select="$not"/>
324 <oxsl:apply-imports/>
330 <xsl:template name="out_comment">
331 <xsl:param name="name"/>
332 <xsl:if test="$name">
334 <xsl:value-of select="concat(' ',$name,' ')"/>
339 <!-- Returns a regular expression with matching operators -->
340 <xsl:template name="out_match_op">
341 <xsl:param name="not" select="'false'"/>
342 <xsl:param name="uri"/>
343 <xsl:param name="cook" select="'false'"/>
344 <xsl:param name="c-tag"/>
346 <xsl:variable name="instantiate">
347 <xsl:if test="$cook = 'true'">instantiate/</xsl:if>
350 <!-- application with not operator -->
351 <xsl:variable name="app_not">
352 <xsl:if test="$not = 'true'">CONST[@uri='cic:/Coq/Init/Logic/not.con'] and </xsl:if>
355 <xsl:variable name="uris">
356 <xsl:call-template name="test_on_uris">
357 <xsl:with-param name="uris" select="$uri"/>
361 <xsl:variable name="app_op">
362 <xsl:if test="$not = 'true'">APPLY[</xsl:if>
363 <xsl:value-of select="concat($instantiate,$c-tag,'[',$uris,']')"/>
364 <xsl:if test="$not = 'true'">]</xsl:if>
367 <xsl:value-of select="concat($app_not,$app_op)"/>
371 <!-- Returns a test on apply node children number-->
372 <xsl:template name="out_match_child">
373 <xsl:param name="not" select="'false'"/>
374 <xsl:param name="hide" select="0"/>
375 <xsl:param name="arity" select="0"/>
377 <!-- Test on children number only if the operator is not constant -->
378 <xsl:if test="$arity != 0 or $hide != 0">
380 <!-- if the operator has been concatenated with not, the root apply node must have only two child -->
381 <xsl:when test="$not = 'true'">
382 <xsl:value-of select="concat('count(*) = 2 and count(*[2]/*) = ',$arity + $hide + 1)"/>
385 <xsl:value-of select="concat('count(*) = ',$arity + $hide + 1)"/>
391 <xsl:template name="out_match">
392 <xsl:param name="not" select="'false'"/>
393 <xsl:param name="uri"/>
394 <xsl:param name="cook" select="'false'"/>
395 <xsl:param name="hide" select="0"/>
396 <xsl:param name="arity" select="0"/>
397 <xsl:param name="c-tag"/>
399 <!-- TEST ON OPERATOR(S) TYPE -->
400 <xsl:variable name="match_op">
401 <xsl:call-template name="out_match_op">
402 <xsl:with-param name="not" select="$not"/>
403 <xsl:with-param name="uri" select="$uri"/>
404 <xsl:with-param name="cook" select="$cook"/>
405 <xsl:with-param name="hide" select="$hide"/>
406 <xsl:with-param name="c-tag" select="$c-tag"/>
410 <!-- TEST ON CHILD(REN) NUMBER -->
411 <xsl:variable name="match_child">
412 <xsl:call-template name="out_match_child">
413 <xsl:with-param name="not" select="$not"/>
414 <xsl:with-param name="hide" select="$hide"/>
415 <xsl:with-param name="arity" select="$arity"/>
420 <!-- not a constant operator -->
421 <xsl:when test="$arity != 0 or $hide != 0">
423 <xsl:when test="$match_child != ''">
424 <xsl:value-of select="concat('APPLY[',$match_op,' and ',$match_child,']')"/>
427 <xsl:value-of select="concat('APPLY[',$match_op,']')"/>
433 <xsl:when test="$match_child != ''">
434 <xsl:value-of select="concat($match_op,' and ',$match_child)"/>
437 <xsl:value-of select="$match_op"/>
444 <xsl:template name="out_params">
445 <xsl:param name="params" select="1"/>
446 <xsl:param name="hide" select="0"/>
447 <xsl:param name="not" select="'false'"/>
448 <xsl:param name="mode" select="'noannot'"/>
449 <xsl:param name="arity" select="0"/>
451 <xsl:if test="$params <= $arity">
452 <xsl:variable name="param">
453 <xsl:call-template name="param">
454 <xsl:with-param name="id" select="$params"/>
455 <xsl:with-param name="not" select="$not"/>
456 <xsl:with-param name="hide" select="$hide"/>
460 <oxsl:apply-templates select="{$param}" mode="{$mode}"/>
462 <xsl:call-template name="out_params">
463 <xsl:with-param name="params" select="$params + 1"/>
464 <xsl:with-param name="hide" select="$hide"/>
465 <xsl:with-param name="not" select="$not"/>
466 <xsl:with-param name="mode" select="$mode"/>
467 <xsl:with-param name="arity" select="$arity"/>
472 <xsl:template name="out_body">
473 <xsl:param name="c-tag"/>
474 <xsl:param name="cook" select="'false'"/>
475 <xsl:param name="m-tag"/>
476 <xsl:param name="hide" select="0"/>
477 <xsl:param name="arity" select="0"/>
478 <xsl:param name="not" select="'false'"/>
481 <!-- SIMPLE TRANSFORMATIONS -->
482 <xsl:when test="count(*) = 0">
483 <xsl:variable name="xref">{@id}</xsl:variable>
485 <xsl:variable name="definitionURL">
486 <xsl:call-template name="op_uri_attr">
487 <xsl:with-param name="not" select="$not"/>
488 <xsl:with-param name="cook" select="$cook"/>
489 <xsl:with-param name="c-tag" select="$c-tag"/>
490 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
494 <xsl:variable name="helm:xref">
495 <xsl:call-template name="op_id_attr">
496 <xsl:with-param name="not" select="$not"/>
497 <xsl:with-param name="cook" select="$cook"/>
498 <xsl:with-param name="c-tag" select="$c-tag"/>
499 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
504 <m:apply helm:xref="{$xref}">
506 <xsl:element name="{concat('m:',$m-tag)}">
507 <xsl:attribute name="definitionURL">
508 <xsl:value-of select="$definitionURL"/>
510 <xsl:attribute name="helm:xref">
511 <xsl:value-of select="$helm:xref"/>
515 <xsl:call-template name="out_params">
516 <xsl:with-param name="hide" select="$hide"/>
517 <xsl:with-param name="not" select="$not"/>
518 <xsl:with-param name="arity" select="$arity"/>
522 <!-- COMPLEX TRANSFORMATIONS -->
524 <xsl:apply-templates>
525 <xsl:with-param name="c-tag" select="$c-tag"/>
526 <xsl:with-param name="cook" select="$cook"/>
527 <xsl:with-param name="hide" select="$hide"/>
528 <xsl:with-param name="arity" select="$arity"/>
529 <xsl:with-param name="not" select="$not"/>
530 </xsl:apply-templates>
536 <xsl:template name="out_mvar">
537 <xsl:param name="vname"/>
541 <xsl:when test="(ancestor-or-self::*[preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)]]/preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)])[position() = last()]">
542 <oxsl:value-of select="{concat('$bvar_',$vname)}"/>
545 <xsl:value-of select="$vname"/>
552 <xsl:template name="out_choose_binder">
553 <xsl:param name="binded_params" select="''"/>
554 <xsl:param name="not" select="'false'"/>
555 <xsl:param name="hide" select="0"/>
556 <xsl:param name="binder"/>
558 <xsl:if test="$binded_params != ''">
560 <xsl:when test="contains($binded_params,'+')">
561 <xsl:call-template name="out_choose_binder">
562 <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
563 <xsl:with-param name="not" select="$not"/>
564 <xsl:with-param name="hide" select="$hide"/>
565 <xsl:with-param name="binder" select="$binder"/>
568 <xsl:call-template name="out_choose_binder">
569 <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
570 <xsl:with-param name="not" select="$not"/>
571 <xsl:with-param name="hide" select="$hide"/>
572 <xsl:with-param name="binder" select="$binder"/>
576 <xsl:variable name="param">
577 <xsl:call-template name="param">
578 <xsl:with-param name="id" select="$binded_params"/>
579 <xsl:with-param name="not" select="$not"/>
580 <xsl:with-param name="hide" select="$hide"/>
584 <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
585 <oxsl:value-of select="{concat($param,$binder)}"/>
593 <!-- *********************************************************************** -->
594 <!-- META LANGUAGE FOR MathML -->
595 <!-- *********************************************************************** -->
597 <xsl:template match="mapp">
598 <xsl:param name="c-tag"/>
599 <xsl:param name="cook" select="'false'"/>
600 <xsl:param name="hide" select="0"/>
601 <xsl:param name="arity" select="0"/>
602 <xsl:param name="not" select="'false'"/>
604 <xsl:variable name="helm:xref">
606 <xsl:when test="@xref">
607 <xsl:call-template name="set_attribute">
608 <xsl:with-param name="attr" select="@xref"/>
609 <xsl:with-param name="c-tag" select="$c-tag"/>
610 <xsl:with-param name="cook" select="$cook"/>
611 <xsl:with-param name="hide" select="$hide"/>
612 <xsl:with-param name="arity" select="$arity"/>
613 <xsl:with-param name="not" select="$not"/>
616 <xsl:otherwise>{@id}</xsl:otherwise>
620 <m:apply helm:xref="{$helm:xref}">
621 <xsl:call-template name="copy_attributes">
622 <xsl:with-param name="cook" select="$cook"/>
623 <xsl:with-param name="c-tag" select="$c-tag"/>
624 <xsl:with-param name="hide" select="$hide"/>
625 <xsl:with-param name="arity" select="$arity"/>
626 <xsl:with-param name="not" select="$not"/>
627 <xsl:with-param name="ignore" select="'xref'"/>
630 <xsl:apply-templates>
631 <xsl:with-param name="c-tag" select="$c-tag"/>
632 <xsl:with-param name="cook" select="$cook"/>
633 <xsl:with-param name="hide" select="$hide"/>
634 <xsl:with-param name="arity" select="$arity"/>
635 <xsl:with-param name="not" select="$not"/>
636 </xsl:apply-templates>
640 <xsl:template match="mop">
641 <xsl:param name="c-tag"/>
642 <xsl:param name="cook" select="'false'"/>
643 <xsl:param name="hide" select="0"/>
644 <xsl:param name="arity" select="0"/>
645 <xsl:param name="not" select="'false'"/>
647 <!-- set definitonURL attribute -->
648 <xsl:variable name="definitionURL">
650 <xsl:when test="@definitionURL">
651 <xsl:call-template name="set_attribute">
652 <xsl:with-param name="attr" select="@definitionURL"/>
653 <xsl:with-param name="cook" select="$cook"/>
654 <xsl:with-param name="c-tag" select="$c-tag"/>
655 <xsl:with-param name="hide" select="$hide"/>
656 <xsl:with-param name="arity" select="$arity"/>
657 <xsl:with-param name="not" select="$not"/>
661 <xsl:call-template name="op_uri_attr">
662 <xsl:with-param name="not" select="$not"/>
663 <xsl:with-param name="cook" select="$cook"/>
664 <xsl:with-param name="c-tag" select="$c-tag"/>
665 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
671 <!-- set helm:xref attribute -->
672 <xsl:variable name="helm:xref">
674 <xsl:when test="@xref">
675 <xsl:call-template name="set_attribute">
676 <xsl:with-param name="attr" select="@xref"/>
677 <xsl:with-param name="cook" select="$cook"/>
678 <xsl:with-param name="c-tag" select="$c-tag"/>
679 <xsl:with-param name="hide" select="$hide"/>
680 <xsl:with-param name="arity" select="$arity"/>
681 <xsl:with-param name="not" select="$not"/>
685 <xsl:call-template name="op_id_attr">
686 <xsl:with-param name="not" select="$not"/>
687 <xsl:with-param name="cook" select="$cook"/>
688 <xsl:with-param name="c-tag" select="$c-tag"/>
689 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
695 <xsl:element name="{concat('m:',@tag)}">
696 <xsl:attribute name="definitionURL">
697 <xsl:value-of select="$definitionURL"/>
699 <xsl:attribute name="helm:xref">
700 <xsl:value-of select="$helm:xref"/>
703 <xsl:call-template name="copy_attributes">
704 <xsl:with-param name="cook" select="$cook"/>
705 <xsl:with-param name="c-tag" select="$c-tag"/>
706 <xsl:with-param name="hide" select="$hide"/>
707 <xsl:with-param name="arity" select="$arity"/>
708 <xsl:with-param name="not" select="$not"/>
709 <xsl:with-param name="ignore" select="'xref + definitionURL + tag'"/>
712 <xsl:apply-templates>
713 <xsl:with-param name="c-tag" select="$c-tag"/>
714 <xsl:with-param name="cook" select="$cook"/>
715 <xsl:with-param name="hide" select="$hide"/>
716 <xsl:with-param name="arity" select="$arity"/>
717 <xsl:with-param name="not" select="$not"/>
718 </xsl:apply-templates>
723 <xsl:template match="param">
724 <xsl:param name="hide" select="0"/>
725 <xsl:param name="not" select="'false'"/>
727 <xsl:variable name="param">
728 <xsl:call-template name="param">
729 <xsl:with-param name="id" select="@id"/>
730 <xsl:with-param name="not" select="$not"/>
731 <xsl:with-param name="hide" select="$hide"/>
736 <xsl:when test="@bvar">
738 <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
739 <oxsl:apply-templates select="{concat($param,'/target')}" mode="{@mode}"/>
743 <m:csymbol>app</m:csymbol>
744 <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
746 <xsl:value-of select="@bvar"/>
753 <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
759 <xsl:template match="m:*">
760 <xsl:param name="c-tag"/>
761 <xsl:param name="cook" select="'false'"/>
762 <xsl:param name="hide" select="0"/>
763 <xsl:param name="arity" select="0"/>
764 <xsl:param name="not" select="'false'"/>
767 <xsl:call-template name="copy_attributes">
768 <xsl:with-param name="cook" select="$cook"/>
769 <xsl:with-param name="c-tag" select="$c-tag"/>
770 <xsl:with-param name="hide" select="$hide"/>
771 <xsl:with-param name="arity" select="$arity"/>
772 <xsl:with-param name="not" select="$not"/>
775 <xsl:apply-templates>
776 <xsl:with-param name="c-tag" select="$c-tag"/>
777 <xsl:with-param name="cook" select="$cook"/>
778 <xsl:with-param name="hide" select="$hide"/>
779 <xsl:with-param name="arity" select="$arity"/>
780 <xsl:with-param name="not" select="$not"/>
781 </xsl:apply-templates>
786 <xsl:template match="mbvar">
787 <xsl:param name="c-tag"/>
788 <xsl:param name="cook" select="'false'"/>
789 <xsl:param name="hide" select="0"/>
790 <xsl:param name="arity" select="0"/>
791 <xsl:param name="not" select="'false'"/>
793 <xsl:variable name="binded_params">
794 <xsl:call-template name="get_binded_params">
795 <xsl:with-param name="var" select="@name"/>
796 <xsl:with-param name="node" select="following-sibling::*"/>
800 <xsl:variable name="test">
801 <xsl:call-template name="test_on_lambda">
802 <xsl:with-param name="binded_params" select="$binded_params"/>
803 <xsl:with-param name="not" select="$not"/>
804 <xsl:with-param name="hide" select="$hide"/>
808 <xsl:variable name="binder">/decl/@binder</xsl:variable>
811 <xsl:when test="$binded_params != ''">
812 <oxsl:variable name="{concat('bvar_',@name)}">
814 <!-- one or more lambdas exist -->
815 <oxsl:when test="{$test}">
817 <!-- binded params > 1 (more than 1 lambda) -->
818 <xsl:when test="contains($binded_params,'+')">
819 <oxsl:variable name="binder">
821 <xsl:call-template name="out_choose_binder">
822 <xsl:with-param name="binded_params" select="$binded_params"/>
823 <xsl:with-param name="not" select="$not"/>
824 <xsl:with-param name="hide" select="$hide"/>
825 <xsl:with-param name="binder" select="$binder"/>
829 <oxsl:call-template name="insert_subscript">
830 <oxsl:with-param name="node_value" select="$binder"/>
831 </oxsl:call-template>
833 <!-- binded parms = 1 (1 lambda) -->
835 <xsl:variable name="param">
836 <xsl:call-template name="param">
837 <xsl:with-param name="id" select="$binded_params"/>
838 <xsl:with-param name="not" select="$not"/>
839 <xsl:with-param name="hide" select="$hide"/>
843 <oxsl:call-template name="insert_subscript">
844 <oxsl:with-param name="node_value" select="{concat($param,$binder)}"/>
845 </oxsl:call-template>
849 <!-- no one lambda -->
851 <xsl:value-of select="@name"/>
858 <oxsl:value-of select="{concat('$bvar_',@name)}"/>
860 <xsl:apply-templates>
861 <xsl:with-param name="c-tag" select="$c-tag"/>
862 <xsl:with-param name="cook" select="$cook"/>
863 <xsl:with-param name="hide" select="$hide"/>
864 <xsl:with-param name="arity" select="$arity"/>
865 <xsl:with-param name="not" select="$not"/>
866 </xsl:apply-templates>
872 <xsl:value-of select="@name"/>
874 <xsl:apply-templates>
875 <xsl:with-param name="c-tag" select="$c-tag"/>
876 <xsl:with-param name="cook" select="$cook"/>
877 <xsl:with-param name="hide" select="$hide"/>
878 <xsl:with-param name="arity" select="$arity"/>
879 <xsl:with-param name="not" select="$not"/>
880 </xsl:apply-templates>
888 <xsl:template match="mvar">
889 <xsl:call-template name="out_mvar">
890 <xsl:with-param name="vname" select="@name"/>
895 <!-- *********************************************************************** -->
896 <!-- AUXILIARY FUNCTIONS -->
897 <!-- *********************************************************************** -->
900 <!-- Returns a value if all uris in the list have the same c-tag -->
901 <xsl:template name="get_c_tag">
902 <xsl:param name="uri" select="''"/>
904 <xsl:if test="$uri != ''">
906 <xsl:when test="contains($uri,'|')">
907 <xsl:variable name="c-tag1">
908 <xsl:call-template name="get_c_tag">
909 <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
913 <xsl:variable name="c-tag2">
914 <xsl:call-template name="get_c_tag">
915 <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
919 <xsl:if test="$c-tag1 = $c-tag2">
920 <xsl:value-of select="$c-tag1"/>
925 <xsl:when test="substring($uri,string-length($uri)-3) = '.con'">CONST</xsl:when>
926 <xsl:when test="substring($uri,string-length($uri)-3) = '.ind'">MUTIND</xsl:when>
933 <!-- Creates a list selecting uris according to c-tag specified -->
934 <xsl:template name="select_uris">
935 <xsl:param name="uris" select="''"/>
936 <xsl:param name="c-tag"/>
938 <xsl:if test="$uris != ''">
940 <xsl:when test="contains($uris,'|')">
941 <xsl:variable name="list1">
942 <xsl:call-template name="select_uris">
943 <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
944 <xsl:with-param name="c-tag" select="$c-tag"/>
948 <xsl:variable name="list2">
949 <xsl:call-template name="select_uris">
950 <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
951 <xsl:with-param name="c-tag" select="$c-tag"/>
956 <xsl:when test="$list1 != '' and $list2 != ''">
957 <xsl:value-of select="concat($list1,'|',$list2)"/>
959 <xsl:when test="$list1 != '' and $list2 = ''">
960 <xsl:value-of select="$list1"/>
962 <xsl:when test="$list1 = '' and $list2 != ''">
963 <xsl:value-of select="$list2"/>
968 <xsl:variable name="c-tag1">
969 <xsl:call-template name="get_c_tag">
970 <xsl:with-param name="uri" select="$uris"/>
974 <xsl:if test="$c-tag1 = $c-tag">
975 <xsl:value-of select="$uris"/>
982 <!-- Returns a xpath expression matching on uri attributes -->
983 <xsl:template name="test_on_uris">
984 <xsl:param name="uris" select="''"/>
986 <xsl:if test="$uris != ''">
988 <xsl:when test="contains($uris,'|')">
989 <xsl:variable name="expr1">
990 <xsl:call-template name="test_on_uris">
991 <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
995 <xsl:variable name="expr2">
996 <xsl:call-template name="test_on_uris">
997 <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
1001 <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
1004 <xsl:value-of select="concat('@uri=',"'",$uris,"'")"/>
1010 <!-- Returns a xpath expression testing on LAMBDA node existence -->
1011 <xsl:template name="test_on_lambda">
1012 <xsl:param name="binded_params" select="''"/>
1013 <xsl:param name="not" select="'false'"/>
1014 <xsl:param name="hide" select="0"/>
1016 <xsl:if test="$binded_params != ''">
1018 <xsl:when test="contains($binded_params,'+')">
1019 <xsl:variable name="expr1">
1020 <xsl:call-template name="test_on_lambda">
1021 <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
1022 <xsl:with-param name="not" select="$not"/>
1023 <xsl:with-param name="hide" select="$hide"/>
1024 </xsl:call-template>
1027 <xsl:variable name="expr2">
1028 <xsl:call-template name="test_on_lambda">
1029 <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
1030 <xsl:with-param name="not" select="$not"/>
1031 <xsl:with-param name="hide" select="$hide"/>
1032 </xsl:call-template>
1035 <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
1038 <xsl:variable name="param">
1039 <xsl:call-template name="param">
1040 <xsl:with-param name="id" select="$binded_params"/>
1041 <xsl:with-param name="not" select="$not"/>
1042 <xsl:with-param name="hide" select="$hide"/>
1043 </xsl:call-template>
1046 <xsl:value-of select="concat('name(',$param,') = ',"'LAMBDA'")"/>
1052 <!-- Removes white spaces from uris list -->
1053 <xsl:template name="remove_white_spaces">
1054 <xsl:param name="uri" select="''"/>
1056 <xsl:if test="$uri != ''">
1058 <xsl:when test="contains($uri,'|')">
1059 <xsl:variable name="uri1">
1060 <xsl:call-template name="remove_white_spaces">
1061 <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
1062 </xsl:call-template>
1065 <xsl:variable name="uri2">
1066 <xsl:call-template name="remove_white_spaces">
1067 <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
1068 </xsl:call-template>
1071 <xsl:value-of select="concat($uri1,'|',$uri2)"/>
1074 <xsl:value-of select="normalize-space($uri)"/>
1081 Returns a list of params id attributes concatenated with '+'.
1082 The params'id attribute are selected according to the value of bindig variable 'var'
1084 <xsl:template name="get_binded_params">
1085 <xsl:param name="var"/>
1086 <xsl:param name="node"/>
1088 <xsl:if test="count($node) != 0">
1090 <!-- another variable declaration with same name -->
1091 <xsl:when test="($node[1][name() = 'mbvar']) and ($node[1][@name = $var])"></xsl:when>
1092 <!-- a binded param -->
1093 <xsl:when test="($node[1][name() = 'param']) and ($node[1][@bvar = $var])">
1094 <!-- search on siblings -->
1095 <xsl:variable name="siblings_params">
1096 <xsl:call-template name="get_binded_params">
1097 <xsl:with-param name="var" select="$var"/>
1098 <xsl:with-param name="node" select="$node[position() > 1]"/>
1099 </xsl:call-template>
1102 <xsl:when test="$siblings_params != ''">
1103 <xsl:value-of select="concat($node[1]/@id,'+',$siblings_params)"/>
1106 <xsl:value-of select="$node[1]/@id"/>
1111 <!-- search on siblings -->
1112 <xsl:variable name="siblings_params">
1113 <xsl:call-template name="get_binded_params">
1114 <xsl:with-param name="var" select="$var"/>
1115 <xsl:with-param name="node" select="$node[position() > 1]"/>
1116 </xsl:call-template>
1118 <!-- search on children -->
1119 <xsl:variable name="children_params">
1120 <xsl:call-template name="get_binded_params">
1121 <xsl:with-param name="var" select="$var"/>
1122 <xsl:with-param name="node" select="$node[1]/child::*"/>
1123 </xsl:call-template>
1127 <xsl:when test="$children_params != '' and $siblings_params != ''">
1128 <xsl:value-of select="concat($children_params,'+',$siblings_params)"/>
1130 <xsl:when test="$children_params != '' and $siblings_params = ''">
1131 <xsl:value-of select="$children_params"/>
1133 <xsl:when test="$children_params = '' and $siblings_params != ''">
1134 <xsl:value-of select="$siblings_params"/>
1142 <!-- Returns a xpath string with the location of the parameter with the id specified -->
1143 <xsl:template name="param">
1144 <xsl:param name="id"/>
1145 <xsl:param name="not" select="'false'"/>
1146 <xsl:param name="hide" select="0"/>
1148 <xsl:variable name="apply_not">
1149 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
1152 <xsl:value-of select="concat($apply_not,'*[',$id + $hide + 1,']')"/>
1155 <!-- Returns a xpath string with the location of the operator uri attribute -->
1156 <xsl:template name="op_uri_attr">
1157 <xsl:param name="not" select="'false'"/>
1158 <xsl:param name="cook" select="'false'"/>
1159 <xsl:param name="c-tag"/>
1160 <xsl:param name="const" select="'false'"/>
1162 <xsl:call-template name="op_attr">
1163 <xsl:with-param name="attr_type" select="'@uri'"/>
1164 <xsl:with-param name="not" select="$not"/>
1165 <xsl:with-param name="cook" select="$cook"/>
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="cook" select="'false'"/>
1175 <xsl:param name="c-tag"/>
1176 <xsl:param name="const" select="'false'"/>
1178 <xsl:call-template name="op_attr">
1179 <xsl:with-param name="attr_type" select="'@id'"/>
1180 <xsl:with-param name="not" select="$not"/>
1181 <xsl:with-param name="cook" select="$cook"/>
1182 <xsl:with-param name="c-tag" select="$c-tag"/>
1183 <xsl:with-param name="const" select="$const"/>
1184 </xsl:call-template>
1188 <!-- Returns a xpath string with the location of the operator uri or id attribute -->
1189 <xsl:template name="op_attr">
1190 <xsl:param name="attr_type"/>
1191 <xsl:param name="not" select="'false'"/>
1192 <xsl:param name="cook" select="'false'"/>
1193 <xsl:param name="c-tag"/>
1194 <xsl:param name="const" select="'false'"/>
1196 <xsl:variable name="instantiate">
1197 <xsl:if test="$cook = 'true'">instantiate/</xsl:if>
1200 <xsl:variable name="apply">
1201 <xsl:if test="$not = 'true'">APPLY/</xsl:if>
1205 <xsl:when test="$const = 'true'">
1206 <xsl:value-of select="concat('{',$attr_type,'}')"/>
1209 <xsl:value-of select="concat('{',$apply,$instantiate,$c-tag,'/',$attr_type,'}')"/>
1214 <xsl:template name="copy_attributes">
1215 <xsl:param name="cook" select="'false'"/>
1216 <xsl:param name="c-tag"/>
1217 <xsl:param name="hide" select="0"/>
1218 <xsl:param name="arity" select="0"/>
1219 <xsl:param name="not" select="'false'"/>
1220 <xsl:param name="ignore" select="''"/>
1222 <xsl:variable name="test">
1223 <xsl:call-template name="test_on_attributes">
1224 <xsl:with-param name="names" select="$ignore"/>
1225 </xsl:call-template>
1228 <xsl:for-each select="@*">
1229 <xsl:if test="contains($test,concat('+',name(),'+')) = false()">
1230 <xsl:attribute name="{name()}">
1231 <xsl:call-template name="set_attribute">
1232 <xsl:with-param name="attr" select="."/>
1233 <xsl:with-param name="cook" select="$cook"/>
1234 <xsl:with-param name="c-tag" select="$c-tag"/>
1235 <xsl:with-param name="hide" select="$hide"/>
1236 <xsl:with-param name="arity" select="$arity"/>
1237 <xsl:with-param name="not" select="$not"/>
1238 </xsl:call-template>
1244 <xsl:template name="test_on_attributes">
1245 <xsl:param name="names" select="''"/>
1248 <xsl:when test="contains($names,'+')">
1249 <xsl:variable name="name">
1250 <xsl:call-template name="test_on_attributes">
1251 <xsl:with-param name="names" select="normalize-space(substring-after($names,'+'))"/>
1252 </xsl:call-template>
1255 <xsl:value-of select="concat('+',normalize-space(substring-before($names,'+')),$name)"/>
1258 <xsl:value-of select="concat('+',normalize-space($names),'+')"/>
1263 <xsl:template name="set_attribute">
1264 <xsl:param name="attr"/>
1265 <xsl:param name="c-tag"/>
1266 <xsl:param name="cook" select="'false'"/>
1267 <xsl:param name="hide" select="0"/>
1268 <xsl:param name="arity" select="0"/>
1269 <xsl:param name="not" select="'false'"/>
1272 <xsl:when test="$attr = '$APP-ID'">{@id}</xsl:when>
1273 <xsl:when test="$attr = '$OP-ID' or $attr = '$OP-URI'">
1274 <xsl:variable name="attr_type">
1276 <xsl:when test="$attr = '$OP-ID'">@id</xsl:when>
1277 <xsl:otherwise>@uri</xsl:otherwise>
1281 <xsl:call-template name="op_attr">
1282 <xsl:with-param name="attr_type" select="$attr_type"/>
1283 <xsl:with-param name="not" select="$not"/>
1284 <xsl:with-param name="cook" select="$cook"/>
1285 <xsl:with-param name="c-tag" select="$c-tag"/>
1286 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
1287 </xsl:call-template>
1290 <xsl:value-of select="$attr"/>