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>
65 <xsl:when test="@arity = 0 and @hide = 0 and $not = 'true'">
66 <xsl:call-template name="out_comment">
67 <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
70 <xsl:when test="@arity = 0 and @hide = 0 and @cook = 'true'">
71 <xsl:call-template name="out_comment">
72 <xsl:with-param name="name" select="concat($uri,': a constant operator cannot be cooked')"/>
76 <!-- All uris in uri1 list (if not empty) have CONST c-tag -->
77 <xsl:variable name="uri1">
78 <xsl:call-template name="select_uris">
79 <xsl:with-param name="uris" select="$uri"/>
80 <xsl:with-param name="c-tag" select="'CONST'"/>
84 <!-- All uris in uri2 list (if not empty) have MUTIND c-tag -->
85 <xsl:variable name="uri2">
86 <xsl:call-template name="select_uris">
87 <xsl:with-param name="uris" select="$uri"/>
88 <xsl:with-param name="c-tag" select="'MUTIND'"/>
92 <xsl:if test="$uri1 != ''">
93 <xsl:call-template name="out_template">
94 <xsl:with-param name="name" select="@name"/>
95 <xsl:with-param name="not" select="$not"/>
96 <xsl:with-param name="uri" select="$uri1"/>
97 <xsl:with-param name="cook" select="@cook"/>
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'"/>
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'"/>
121 <xsl:template match="OpSet|NotOpSet">
122 <xsl:variable name="uri">
123 <xsl:call-template name="remove_white_spaces">
124 <xsl:with-param name="uri" select="@uri"/>
128 <xsl:variable name="not">
130 <xsl:when test="name() = 'OpSet'">false</xsl:when>
131 <xsl:otherwise>true</xsl:otherwise>
136 <xsl:when test="*[name() = 'Case']/@arity = 0 and @hide = 0 and $not = 'true'">
137 <xsl:call-template name="out_comment">
138 <xsl:with-param name="name" select="concat($uri,': "not" cannot be applyed to a constant operator')"/>
141 <xsl:when test="*[name() = 'Case']/@arity = 0 and @hide = 0 and @cook = 'true'">
142 <xsl:call-template name="out_comment">
143 <xsl:with-param name="name" select="concat($uri,': a constant operator cannot be cooked')"/>
147 <xsl:variable name="uri1">
148 <xsl:call-template name="select_uris">
149 <xsl:with-param name="uris" select="$uri"/>
150 <xsl:with-param name="c-tag" select="'CONST'"/>
154 <xsl:variable name="uri2">
155 <xsl:call-template name="select_uris">
156 <xsl:with-param name="uris" select="$uri"/>
157 <xsl:with-param name="c-tag" select="'MUTIND'"/>
161 <xsl:if test="$uri1 != ''">
162 <xsl:call-template name="out_template_set">
163 <xsl:with-param name="name" select="@name"/>
164 <xsl:with-param name="not" select="$not"/>
165 <xsl:with-param name="uri" select="$uri1"/>
166 <xsl:with-param name="cook" select="@cook"/>
167 <xsl:with-param name="hide" select="@hide"/>
168 <xsl:with-param name="m-tag" select="@m-tag"/>
169 <xsl:with-param name="c-tag" select="'CONST'"/>
173 <xsl:if test="$uri2 != ''">
174 <xsl:call-template name="out_template_set">
175 <xsl:with-param name="name" select="@name"/>
176 <xsl:with-param name="not" select="$not"/>
177 <xsl:with-param name="uri" select="$uri2"/>
178 <xsl:with-param name="cook" select="@cook"/>
179 <xsl:with-param name="hide" select="@hide"/>
180 <xsl:with-param name="m-tag" select="@m-tag"/>
181 <xsl:with-param name="c-tag" select="'MUTIND'"/>
188 <!-- *********************************************************************** -->
189 <!-- MAIN FUNCTIONS -->
190 <!-- *********************************************************************** -->
193 <xsl:template name="out_template">
194 <xsl:param name="name"/>
195 <xsl:param name="not" select="'false'"/>
196 <xsl:param name="uri"/>
197 <xsl:param name="cook" select="'false'"/>
198 <xsl:param name="hide" select="0"/>
199 <xsl:param name="arity" select="0"/>
200 <xsl:param name="m-tag"/>
201 <xsl:param name="c-tag"/>
203 <xsl:variable name="apply_not">
204 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
207 <xsl:variable name="match">
208 <xsl:call-template name="out_match">
209 <xsl:with-param name="not" select="$not"/>
210 <xsl:with-param name="uri" select="$uri"/>
211 <xsl:with-param name="cook" select="$cook"/>
212 <xsl:with-param name="hide" select="$hide"/>
213 <xsl:with-param name="arity" select="$arity"/>
214 <xsl:with-param name="c-tag" select="$c-tag"/>
218 <xsl:variable name="op_uri_attr">
219 <xsl:variable name="tmp_op_uri_attr">
220 <xsl:call-template name="op_uri_attr">
221 <xsl:with-param name="not" select="$not"/>
222 <xsl:with-param name="c-tag" select="$c-tag"/>
223 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
226 <xsl:value-of select="substring-after(substring-before($tmp_op_uri_attr,'}'),'{')"/>
230 <xsl:call-template name="out_comment">
231 <xsl:with-param name="name" select="$name"/>
234 <oxsl:template match="{$match}" mode="pure">
236 <xsl:when test="$cook = 'true'">
237 <oxsl:variable name="no_params">
238 <oxsl:variable name="no_params_tmp">
239 <oxsl:call-template name="get_no_params">
240 <oxsl:with-param name="first_uri" select="$CICURI"/>
241 <oxsl:with-param name="second_uri" select="{$op_uri_attr}"/>
242 </oxsl:call-template>
244 <oxsl:value-of select="number($no_params_tmp)"/>
247 <oxsl:when test="{concat('count(',$apply_not,'*) = $no_params + ',$arity + $hide + 1)}">
248 <xsl:call-template name="out_body">
249 <xsl:with-param name="c-tag" select="$c-tag"/>
250 <xsl:with-param name="m-tag" select="$m-tag"/>
251 <xsl:with-param name="cook" select="$cook"/>
252 <xsl:with-param name="hide" select="$hide"/>
253 <xsl:with-param name="arity" select="$arity"/>
254 <xsl:with-param name="not" select="$not"/>
258 <oxsl:apply-imports/>
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"/>
276 <xsl:template name="out_template_set">
277 <xsl:param name="name"/>
278 <xsl:param name="not" select="'false'"/>
279 <xsl:param name="cook" select="'false'"/>
280 <xsl:param name="uri"/>
281 <xsl:param name="hide" select="0"/>
282 <xsl:param name="m-tag"/>
283 <xsl:param name="c-tag"/>
285 <xsl:variable name="no_params_var">
286 <xsl:if test="$cook = 'true'">$no_params + </xsl:if>
289 <xsl:variable name="match">
290 <xsl:call-template name="out_match_op">
291 <xsl:with-param name="not" select="$not"/>
292 <xsl:with-param name="uri" select="$uri"/>
293 <xsl:with-param name="c-tag" select="$c-tag"/>
297 <xsl:variable name="apply_not">
298 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
301 <xsl:variable name="op_uri_attr">
302 <xsl:variable name="tmp_op_uri_attr">
303 <xsl:call-template name="op_uri_attr">
304 <xsl:with-param name="not" select="$not"/>
305 <xsl:with-param name="c-tag" select="$c-tag"/>
308 <xsl:value-of select="substring-after(substring-before($tmp_op_uri_attr,'}'),'{')"/>
313 <xsl:call-template name="out_comment">
314 <xsl:with-param name="name" select="$name"/>
317 <oxsl:template match="{concat('APPLY[',$match,']')}" mode="pure">
318 <xsl:if test="$cook = 'true'">
319 <oxsl:variable name="no_params">
320 <oxsl:variable name="no_params_tmp">
321 <oxsl:call-template name="get_no_params">
322 <oxsl:with-param name="first_uri" select="$CICURI"/>
323 <oxsl:with-param name="second_uri" select="{$op_uri_attr}"/>
324 </oxsl:call-template>
326 <oxsl:value-of select="number($no_params_tmp)"/>
330 <xsl:for-each select="Case">
331 <oxsl:when test="{concat('count(',$apply_not,'*) = ',$no_params_var,@arity + $hide + 1)}">
332 <xsl:call-template name="out_body">
333 <xsl:with-param name="c-tag" select="$c-tag"/>
334 <xsl:with-param name="m-tag" select="$m-tag"/>
335 <xsl:with-param name="cook" select="$cook"/>
336 <xsl:with-param name="hide" select="$hide"/>
337 <xsl:with-param name="arity" select="@arity"/>
338 <xsl:with-param name="not" select="$not"/>
343 <oxsl:apply-imports/>
349 <xsl:template name="out_comment">
350 <xsl:param name="name"/>
351 <xsl:if test="$name">
353 <xsl:value-of select="concat(' ',$name,' ')"/>
358 <!-- Returns a regular expression with matching operators -->
359 <xsl:template name="out_match_op">
360 <xsl:param name="not" select="'false'"/>
361 <xsl:param name="uri"/>
362 <xsl:param name="c-tag"/>
364 <!-- application with not operator -->
365 <xsl:variable name="app_not">
366 <xsl:if test="$not = 'true'">CONST[@uri='cic:/Coq/Init/Logic/not.con'] and </xsl:if>
369 <xsl:variable name="uris">
370 <xsl:call-template name="test_on_uris">
371 <xsl:with-param name="uris" select="$uri"/>
375 <xsl:variable name="app_op">
376 <xsl:if test="$not = 'true'">APPLY[</xsl:if>
377 <xsl:value-of select="concat($c-tag,'[',$uris,']')"/>
378 <xsl:if test="$not = 'true'">]</xsl:if>
381 <xsl:value-of select="concat($app_not,$app_op)"/>
384 <!-- Returns a test on apply node children number-->
385 <xsl:template name="out_match_child">
386 <xsl:param name="not" select="'false'"/>
387 <xsl:param name="cook" select="'false'"/>
388 <xsl:param name="hide" select="0"/>
389 <xsl:param name="arity" select="0"/>
392 Test on children number only if the operator is concatenated with not of
393 if it is not constant and it has not to be cooked.
394 It is not possible to concatenate a constant operator with not.
396 <xsl:if test="$not = 'true' or (($arity != 0 or $hide != 0) and $cook = 'false')">
398 <!-- if the operator has been concatenated with not, the root apply node must have only two child -->
399 <xsl:when test="$not = 'true'">
400 <xsl:variable name="test_apply_children">
401 <xsl:if test="$cook = 'false'">
402 <xsl:value-of select="concat(' and count(*[2]/*) = ',$arity + $hide + 1)"/>
406 <xsl:value-of select="concat('count(*) = 2',$test_apply_children)"/>
409 <xsl:value-of select="concat('count(*) = ',$arity + $hide + 1)"/>
415 <xsl:template name="out_match">
416 <xsl:param name="not" select="'false'"/>
417 <xsl:param name="uri"/>
418 <xsl:param name="cook" select="'false'"/>
419 <xsl:param name="hide" select="0"/>
420 <xsl:param name="arity" select="0"/>
421 <xsl:param name="c-tag"/>
423 <!-- TEST ON OPERATOR(S) TYPE -->
424 <xsl:variable name="match_op">
425 <xsl:call-template name="out_match_op">
426 <xsl:with-param name="not" select="$not"/>
427 <xsl:with-param name="uri" select="$uri"/>
428 <xsl:with-param name="hide" select="$hide"/>
429 <xsl:with-param name="c-tag" select="$c-tag"/>
433 <!-- TEST ON CHILD(REN) NUMBER -->
434 <xsl:variable name="match_child">
435 <xsl:call-template name="out_match_child">
436 <xsl:with-param name="not" select="$not"/>
437 <xsl:with-param name="cook" select="$cook"/>
438 <xsl:with-param name="hide" select="$hide"/>
439 <xsl:with-param name="arity" select="$arity"/>
444 <!-- not a constant operator -->
445 <xsl:when test="$arity != 0 or $hide != 0">
447 <xsl:when test="$match_child != ''">
448 <xsl:value-of select="concat('APPLY[',$match_op,' and ',$match_child,']')"/>
451 <xsl:value-of select="concat('APPLY[',$match_op,']')"/>
457 <xsl:when test="$match_child != ''">
458 <xsl:value-of select="concat($match_op,' and ',$match_child)"/>
461 <xsl:value-of select="$match_op"/>
468 <xsl:template name="out_params">
469 <xsl:param name="params" select="1"/>
470 <xsl:param name="cook" select="'false'"/>
471 <xsl:param name="hide" select="0"/>
472 <xsl:param name="not" select="'false'"/>
473 <xsl:param name="mode" select="'noannot'"/>
474 <xsl:param name="arity" select="0"/>
476 <xsl:if test="$params <= $arity">
477 <xsl:variable name="param">
478 <xsl:call-template name="param">
479 <xsl:with-param name="id" select="$params"/>
480 <xsl:with-param name="not" select="$not"/>
481 <xsl:with-param name="cook" select="$cook"/>
482 <xsl:with-param name="hide" select="$hide"/>
486 <oxsl:apply-templates select="{$param}" mode="{$mode}"/>
488 <xsl:call-template name="out_params">
489 <xsl:with-param name="params" select="$params + 1"/>
490 <xsl:with-param name="cook" select="$cook"/>
491 <xsl:with-param name="hide" select="$hide"/>
492 <xsl:with-param name="not" select="$not"/>
493 <xsl:with-param name="mode" select="$mode"/>
494 <xsl:with-param name="arity" select="$arity"/>
500 <xsl:template name="out_body">
501 <xsl:param name="c-tag"/>
502 <xsl:param name="cook" select="'false'"/>
503 <xsl:param name="m-tag"/>
504 <xsl:param name="hide" select="0"/>
505 <xsl:param name="arity" select="0"/>
506 <xsl:param name="not" select="'false'"/>
509 <!-- SIMPLE TRANSFORMATIONS -->
510 <xsl:when test="count(*) = 0">
511 <xsl:variable name="xref">{@id}</xsl:variable>
513 <xsl:variable name="definitionURL">
514 <xsl:call-template name="op_uri_attr">
515 <xsl:with-param name="not" select="$not"/>
516 <xsl:with-param name="c-tag" select="$c-tag"/>
517 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
521 <xsl:variable name="helm:xref">
522 <xsl:call-template name="op_id_attr">
523 <xsl:with-param name="not" select="$not"/>
524 <xsl:with-param name="c-tag" select="$c-tag"/>
525 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
530 <m:apply helm:xref="{$xref}">
532 <xsl:element name="{concat('m:',$m-tag)}">
533 <xsl:attribute name="definitionURL">
534 <xsl:value-of select="$definitionURL"/>
536 <xsl:attribute name="helm:xref">
537 <xsl:value-of select="$helm:xref"/>
541 <xsl:call-template name="out_params">
542 <xsl:with-param name="cook" select="$cook"/>
543 <xsl:with-param name="hide" select="$hide"/>
544 <xsl:with-param name="not" select="$not"/>
545 <xsl:with-param name="arity" select="$arity"/>
549 <!-- COMPLEX TRANSFORMATIONS -->
551 <xsl:apply-templates>
552 <xsl:with-param name="c-tag" select="$c-tag"/>
553 <xsl:with-param name="cook" select="$cook"/>
554 <xsl:with-param name="hide" select="$hide"/>
555 <xsl:with-param name="arity" select="$arity"/>
556 <xsl:with-param name="not" select="$not"/>
557 </xsl:apply-templates>
562 <xsl:template name="out_mvar">
563 <xsl:param name="vname"/>
567 <xsl:when test="(ancestor-or-self::*[preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)]]/preceding-sibling::*[(name() = 'mbvar') and (@name = $vname)])[position() = last()]">
568 <oxsl:value-of select="{concat('$bvar_',$vname)}"/>
571 <xsl:value-of select="$vname"/>
578 <xsl:template name="out_choose_binder">
579 <xsl:param name="binded_params" select="''"/>
580 <xsl:param name="not" select="'false'"/>
581 <xsl:param name="cook" select="'false'"/>
582 <xsl:param name="hide" select="0"/>
583 <xsl:param name="binder"/>
585 <xsl:if test="$binded_params != ''">
587 <xsl:when test="contains($binded_params,'+')">
588 <xsl:call-template name="out_choose_binder">
589 <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
590 <xsl:with-param name="not" select="$not"/>
591 <xsl:with-param name="cook" select="$cook"/>
592 <xsl:with-param name="hide" select="$hide"/>
593 <xsl:with-param name="binder" select="$binder"/>
596 <xsl:call-template name="out_choose_binder">
597 <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
598 <xsl:with-param name="not" select="$not"/>
599 <xsl:with-param name="cook" select="$cook"/>
600 <xsl:with-param name="hide" select="$hide"/>
601 <xsl:with-param name="binder" select="$binder"/>
605 <xsl:variable name="param">
606 <xsl:call-template name="param">
607 <xsl:with-param name="id" select="$binded_params"/>
608 <xsl:with-param name="not" select="$not"/>
609 <xsl:with-param name="cook" select="$cook"/>
610 <xsl:with-param name="hide" select="$hide"/>
614 <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
615 <oxsl:value-of select="{concat($param,$binder)}"/>
622 <!-- *********************************************************************** -->
623 <!-- META LANGUAGE FOR MathML -->
624 <!-- *********************************************************************** -->
626 <xsl:template match="mapp">
627 <xsl:param name="c-tag"/>
628 <xsl:param name="cook" select="'false'"/>
629 <xsl:param name="hide" select="0"/>
630 <xsl:param name="arity" select="0"/>
631 <xsl:param name="not" select="'false'"/>
633 <xsl:variable name="helm:xref">
635 <xsl:when test="@xref">
636 <xsl:call-template name="set_attribute">
637 <xsl:with-param name="attr" select="@xref"/>
638 <xsl:with-param name="c-tag" select="$c-tag"/>
639 <xsl:with-param name="hide" select="$hide"/>
640 <xsl:with-param name="arity" select="$arity"/>
641 <xsl:with-param name="not" select="$not"/>
644 <xsl:otherwise>{@id}</xsl:otherwise>
648 <m:apply helm:xref="{$helm:xref}">
649 <xsl:call-template name="copy_attributes">
650 <xsl:with-param name="c-tag" select="$c-tag"/>
651 <xsl:with-param name="hide" select="$hide"/>
652 <xsl:with-param name="arity" select="$arity"/>
653 <xsl:with-param name="not" select="$not"/>
654 <xsl:with-param name="ignore" select="'xref'"/>
657 <xsl:apply-templates>
658 <xsl:with-param name="c-tag" select="$c-tag"/>
659 <xsl:with-param name="cook" select="$cook"/>
660 <xsl:with-param name="hide" select="$hide"/>
661 <xsl:with-param name="arity" select="$arity"/>
662 <xsl:with-param name="not" select="$not"/>
663 </xsl:apply-templates>
668 <xsl:template match="mop">
669 <xsl:param name="c-tag"/>
670 <xsl:param name="cook" select="'false'"/>
671 <xsl:param name="hide" select="0"/>
672 <xsl:param name="arity" select="0"/>
673 <xsl:param name="not" select="'false'"/>
675 <!-- set definitonURL attribute -->
676 <xsl:variable name="definitionURL">
678 <xsl:when test="@definitionURL">
679 <xsl:call-template name="set_attribute">
680 <xsl:with-param name="attr" select="@definitionURL"/>
681 <xsl:with-param name="c-tag" select="$c-tag"/>
682 <xsl:with-param name="hide" select="$hide"/>
683 <xsl:with-param name="arity" select="$arity"/>
684 <xsl:with-param name="not" select="$not"/>
688 <xsl:call-template name="op_uri_attr">
689 <xsl:with-param name="not" select="$not"/>
690 <xsl:with-param name="c-tag" select="$c-tag"/>
691 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
697 <!-- set helm:xref attribute -->
698 <xsl:variable name="helm:xref">
700 <xsl:when test="@xref">
701 <xsl:call-template name="set_attribute">
702 <xsl:with-param name="attr" select="@xref"/>
703 <xsl:with-param name="c-tag" select="$c-tag"/>
704 <xsl:with-param name="hide" select="$hide"/>
705 <xsl:with-param name="arity" select="$arity"/>
706 <xsl:with-param name="not" select="$not"/>
710 <xsl:call-template name="op_id_attr">
711 <xsl:with-param name="not" select="$not"/>
712 <xsl:with-param name="c-tag" select="$c-tag"/>
713 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
719 <xsl:element name="{concat('m:',@tag)}">
720 <xsl:attribute name="definitionURL">
721 <xsl:value-of select="$definitionURL"/>
723 <xsl:attribute name="helm:xref">
724 <xsl:value-of select="$helm:xref"/>
727 <xsl:call-template name="copy_attributes">
728 <xsl:with-param name="c-tag" select="$c-tag"/>
729 <xsl:with-param name="hide" select="$hide"/>
730 <xsl:with-param name="arity" select="$arity"/>
731 <xsl:with-param name="not" select="$not"/>
732 <xsl:with-param name="ignore" select="'xref + definitionURL + tag'"/>
735 <xsl:apply-templates>
736 <xsl:with-param name="c-tag" select="$c-tag"/>
737 <xsl:with-param name="cook" select="$cook"/>
738 <xsl:with-param name="hide" select="$hide"/>
739 <xsl:with-param name="arity" select="$arity"/>
740 <xsl:with-param name="not" select="$not"/>
741 </xsl:apply-templates>
745 <xsl:template match="param">
746 <xsl:param name="cook" select="'false'"/>
747 <xsl:param name="hide" select="0"/>
748 <xsl:param name="not" select="'false'"/>
750 <xsl:variable name="param">
751 <xsl:call-template name="param">
752 <xsl:with-param name="id" select="@id"/>
753 <xsl:with-param name="not" select="$not"/>
754 <xsl:with-param name="cook" select="$cook"/>
755 <xsl:with-param name="hide" select="$hide"/>
760 <xsl:when test="@bvar">
762 <oxsl:when test="{concat('name(',$param,') = ',"'LAMBDA'")}">
763 <oxsl:apply-templates select="{concat($param,'/target')}" mode="{@mode}"/>
767 <m:csymbol>app</m:csymbol>
768 <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
770 <xsl:value-of select="@bvar"/>
777 <oxsl:apply-templates select="{$param}" mode="{@mode}"/>
782 <xsl:template match="m:*">
783 <xsl:param name="c-tag"/>
784 <xsl:param name="cook" select="'false'"/>
785 <xsl:param name="hide" select="0"/>
786 <xsl:param name="arity" select="0"/>
787 <xsl:param name="not" select="'false'"/>
790 <xsl:call-template name="copy_attributes">
791 <xsl:with-param name="c-tag" select="$c-tag"/>
792 <xsl:with-param name="hide" select="$hide"/>
793 <xsl:with-param name="arity" select="$arity"/>
794 <xsl:with-param name="not" select="$not"/>
797 <xsl:apply-templates>
798 <xsl:with-param name="c-tag" select="$c-tag"/>
799 <xsl:with-param name="cook" select="$cook"/>
800 <xsl:with-param name="hide" select="$hide"/>
801 <xsl:with-param name="arity" select="$arity"/>
802 <xsl:with-param name="not" select="$not"/>
803 </xsl:apply-templates>
807 <xsl:template match="mbvar">
808 <xsl:param name="c-tag"/>
809 <xsl:param name="cook" select="'false'"/>
810 <xsl:param name="hide" select="0"/>
811 <xsl:param name="arity" select="0"/>
812 <xsl:param name="not" select="'false'"/>
814 <xsl:variable name="binded_params">
815 <xsl:call-template name="get_binded_params">
816 <xsl:with-param name="var" select="@name"/>
817 <xsl:with-param name="node" select="following-sibling::*"/>
821 <xsl:variable name="test">
822 <xsl:call-template name="test_on_lambda">
823 <xsl:with-param name="binded_params" select="$binded_params"/>
824 <xsl:with-param name="not" select="$not"/>
825 <xsl:with-param name="cook" select="$cook"/>
826 <xsl:with-param name="hide" select="$hide"/>
830 <xsl:variable name="binder">/target/@binder</xsl:variable>
833 <xsl:when test="$binded_params != ''">
834 <oxsl:variable name="{concat('bvar_',@name)}">
836 <!-- one or more lambdas exist -->
837 <oxsl:when test="{$test}">
839 <!-- binded params > 1 (more than 1 lambda) -->
840 <xsl:when test="contains($binded_params,'+')">
841 <oxsl:variable name="binder">
843 <xsl:call-template name="out_choose_binder">
844 <xsl:with-param name="binded_params" select="$binded_params"/>
845 <xsl:with-param name="not" select="$not"/>
846 <xsl:with-param name="hide" select="$hide"/>
847 <xsl:with-param name="cook" select="$cook"/>
848 <xsl:with-param name="binder" select="$binder"/>
852 <oxsl:call-template name="insert_subscript">
853 <oxsl:with-param name="node_value" select="$binder"/>
854 </oxsl:call-template>
856 <!-- binded parms = 1 (1 lambda) -->
858 <xsl:variable name="param">
859 <xsl:call-template name="param">
860 <xsl:with-param name="id" select="$binded_params"/>
861 <xsl:with-param name="not" select="$not"/>
862 <xsl:with-param name="cook" select="$cook"/>
863 <xsl:with-param name="hide" select="$hide"/>
867 <oxsl:call-template name="insert_subscript">
868 <oxsl:with-param name="node_value" select="{concat($param,$binder)}"/>
869 </oxsl:call-template>
873 <!-- no one lambda -->
875 <xsl:value-of select="@name"/>
882 <oxsl:value-of select="{concat('$bvar_',@name)}"/>
884 <xsl:apply-templates>
885 <xsl:with-param name="c-tag" select="$c-tag"/>
886 <xsl:with-param name="cook" select="$cook"/>
887 <xsl:with-param name="hide" select="$hide"/>
888 <xsl:with-param name="arity" select="$arity"/>
889 <xsl:with-param name="not" select="$not"/>
890 </xsl:apply-templates>
896 <xsl:value-of select="@name"/>
898 <xsl:apply-templates>
899 <xsl:with-param name="c-tag" select="$c-tag"/>
900 <xsl:with-param name="cook" select="$cook"/>
901 <xsl:with-param name="hide" select="$hide"/>
902 <xsl:with-param name="arity" select="$arity"/>
903 <xsl:with-param name="not" select="$not"/>
904 </xsl:apply-templates>
910 <xsl:template match="mvar">
911 <xsl:call-template name="out_mvar">
912 <xsl:with-param name="vname" select="@name"/>
918 <!-- *********************************************************************** -->
919 <!-- AUXILIARY FUNCTIONS -->
920 <!-- *********************************************************************** -->
923 <!-- Returns a value if all uris in the list have the same c-tag -->
924 <xsl:template name="get_c_tag">
925 <xsl:param name="uri" select="''"/>
927 <xsl:if test="$uri != ''">
929 <xsl:when test="contains($uri,'|')">
930 <xsl:variable name="c-tag1">
931 <xsl:call-template name="get_c_tag">
932 <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
936 <xsl:variable name="c-tag2">
937 <xsl:call-template name="get_c_tag">
938 <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
942 <xsl:if test="$c-tag1 = $c-tag2">
943 <xsl:value-of select="$c-tag1"/>
948 <xsl:when test="substring($uri,string-length($uri)-3) = '.con'">CONST</xsl:when>
949 <xsl:when test="substring($uri,string-length($uri)-3) = '.ind'">MUTIND</xsl:when>
956 <!-- Creates a list selecting uris according to c-tag specified -->
957 <xsl:template name="select_uris">
958 <xsl:param name="uris" select="''"/>
959 <xsl:param name="c-tag"/>
961 <xsl:if test="$uris != ''">
963 <xsl:when test="contains($uris,'|')">
964 <xsl:variable name="list1">
965 <xsl:call-template name="select_uris">
966 <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
967 <xsl:with-param name="c-tag" select="$c-tag"/>
971 <xsl:variable name="list2">
972 <xsl:call-template name="select_uris">
973 <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
974 <xsl:with-param name="c-tag" select="$c-tag"/>
979 <xsl:when test="$list1 != '' and $list2 != ''">
980 <xsl:value-of select="concat($list1,'|',$list2)"/>
982 <xsl:when test="$list1 != '' and $list2 = ''">
983 <xsl:value-of select="$list1"/>
985 <xsl:when test="$list1 = '' and $list2 != ''">
986 <xsl:value-of select="$list2"/>
991 <xsl:variable name="c-tag1">
992 <xsl:call-template name="get_c_tag">
993 <xsl:with-param name="uri" select="$uris"/>
997 <xsl:if test="$c-tag1 = $c-tag">
998 <xsl:value-of select="$uris"/>
1005 <!-- Returns a xpath expression matching on uri attributes -->
1006 <xsl:template name="test_on_uris">
1007 <xsl:param name="uris" select="''"/>
1009 <xsl:if test="$uris != ''">
1011 <xsl:when test="contains($uris,'|')">
1012 <xsl:variable name="expr1">
1013 <xsl:call-template name="test_on_uris">
1014 <xsl:with-param name="uris" select="substring-before($uris,'|')"/>
1015 </xsl:call-template>
1018 <xsl:variable name="expr2">
1019 <xsl:call-template name="test_on_uris">
1020 <xsl:with-param name="uris" select="substring-after($uris,'|')"/>
1021 </xsl:call-template>
1024 <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
1027 <xsl:value-of select="concat('@uri=',"'",$uris,"'")"/>
1033 <!-- Returns a xpath expression testing on LAMBDA node existence -->
1034 <xsl:template name="test_on_lambda">
1035 <xsl:param name="binded_params" select="''"/>
1036 <xsl:param name="not" select="'false'"/>
1037 <xsl:param name="cook" select="'false'"/>
1038 <xsl:param name="hide" select="0"/>
1040 <xsl:if test="$binded_params != ''">
1042 <xsl:when test="contains($binded_params,'+')">
1043 <xsl:variable name="expr1">
1044 <xsl:call-template name="test_on_lambda">
1045 <xsl:with-param name="binded_params" select="substring-before($binded_params,'+')"/>
1046 <xsl:with-param name="not" select="$not"/>
1047 <xsl:with-param name="cook" select="$cook"/>
1048 <xsl:with-param name="hide" select="$hide"/>
1049 </xsl:call-template>
1052 <xsl:variable name="expr2">
1053 <xsl:call-template name="test_on_lambda">
1054 <xsl:with-param name="binded_params" select="substring-after($binded_params,'+')"/>
1055 <xsl:with-param name="not" select="$not"/>
1056 <xsl:with-param name="cook" select="$cook"/>
1057 <xsl:with-param name="hide" select="$hide"/>
1058 </xsl:call-template>
1061 <xsl:value-of select="concat($expr1,' or ',$expr2)"/>
1064 <xsl:variable name="param">
1065 <xsl:call-template name="param">
1066 <xsl:with-param name="id" select="$binded_params"/>
1067 <xsl:with-param name="not" select="$not"/>
1068 <xsl:with-param name="cook" select="$cook"/>
1069 <xsl:with-param name="hide" select="$hide"/>
1070 </xsl:call-template>
1073 <xsl:value-of select="concat('name(',$param,') = ',"'LAMBDA'")"/>
1079 <!-- Removes white spaces from uris list -->
1080 <xsl:template name="remove_white_spaces">
1081 <xsl:param name="uri" select="''"/>
1083 <xsl:if test="$uri != ''">
1085 <xsl:when test="contains($uri,'|')">
1086 <xsl:variable name="uri1">
1087 <xsl:call-template name="remove_white_spaces">
1088 <xsl:with-param name="uri" select="substring-before($uri,'|')"/>
1089 </xsl:call-template>
1092 <xsl:variable name="uri2">
1093 <xsl:call-template name="remove_white_spaces">
1094 <xsl:with-param name="uri" select="substring-after($uri,'|')"/>
1095 </xsl:call-template>
1098 <xsl:value-of select="concat($uri1,'|',$uri2)"/>
1101 <xsl:value-of select="normalize-space($uri)"/>
1108 Returns a list of params id attributes concatenated with '+'.
1109 The params'id attribute are selected according to the value of bindig variable 'var'
1111 <xsl:template name="get_binded_params">
1112 <xsl:param name="var"/>
1113 <xsl:param name="node"/>
1115 <xsl:if test="count($node) != 0">
1117 <!-- another variable declaration with same name -->
1118 <xsl:when test="($node[1][name() = 'mbvar']) and ($node[1][@name = $var])"></xsl:when>
1119 <!-- a binded param -->
1120 <xsl:when test="($node[1][name() = 'param']) and ($node[1][@bvar = $var])">
1121 <!-- search on siblings -->
1122 <xsl:variable name="siblings_params">
1123 <xsl:call-template name="get_binded_params">
1124 <xsl:with-param name="var" select="$var"/>
1125 <xsl:with-param name="node" select="$node[position() > 1]"/>
1126 </xsl:call-template>
1129 <xsl:when test="$siblings_params != ''">
1130 <xsl:value-of select="concat($node[1]/@id,'+',$siblings_params)"/>
1133 <xsl:value-of select="$node[1]/@id"/>
1138 <!-- search on siblings -->
1139 <xsl:variable name="siblings_params">
1140 <xsl:call-template name="get_binded_params">
1141 <xsl:with-param name="var" select="$var"/>
1142 <xsl:with-param name="node" select="$node[position() > 1]"/>
1143 </xsl:call-template>
1145 <!-- search on children -->
1146 <xsl:variable name="children_params">
1147 <xsl:call-template name="get_binded_params">
1148 <xsl:with-param name="var" select="$var"/>
1149 <xsl:with-param name="node" select="$node[1]/child::*"/>
1150 </xsl:call-template>
1154 <xsl:when test="$children_params != '' and $siblings_params != ''">
1155 <xsl:value-of select="concat($children_params,'+',$siblings_params)"/>
1157 <xsl:when test="$children_params != '' and $siblings_params = ''">
1158 <xsl:value-of select="$children_params"/>
1160 <xsl:when test="$children_params = '' and $siblings_params != ''">
1161 <xsl:value-of select="$siblings_params"/>
1169 <!-- Returns a xpath string with the location of the parameter with the id specified -->
1170 <xsl:template name="param">
1171 <xsl:param name="id"/>
1172 <xsl:param name="not" select="'false'"/>
1173 <xsl:param name="cook" select="'false'"/>
1174 <xsl:param name="hide" select="0"/>
1176 <xsl:variable name="apply_not">
1177 <xsl:if test="$not = 'true'">*[2]/</xsl:if>
1180 <xsl:variable name="no_params_var">
1181 <xsl:if test="$cook = 'true'">$no_params+</xsl:if>
1184 <xsl:value-of select="concat($apply_not,'*[',$no_params_var,$id + $hide + 1,']')"/>
1187 <!-- Returns a xpath string with the location of the operator uri attribute -->
1188 <xsl:template name="op_uri_attr">
1189 <xsl:param name="not" select="'false'"/>
1190 <xsl:param name="c-tag"/>
1191 <xsl:param name="const" select="'false'"/>
1193 <xsl:call-template name="op_attr">
1194 <xsl:with-param name="attr_type" select="'@uri'"/>
1195 <xsl:with-param name="not" select="$not"/>
1196 <xsl:with-param name="c-tag" select="$c-tag"/>
1197 <xsl:with-param name="const" select="$const"/>
1198 </xsl:call-template>
1201 <!-- Returns a xpath string with the location of the operator id attribute -->
1202 <xsl:template name="op_id_attr">
1203 <xsl:param name="not" select="'false'"/>
1204 <xsl:param name="c-tag"/>
1205 <xsl:param name="const" select="'false'"/>
1207 <xsl:call-template name="op_attr">
1208 <xsl:with-param name="attr_type" select="'@id'"/>
1209 <xsl:with-param name="not" select="$not"/>
1210 <xsl:with-param name="c-tag" select="$c-tag"/>
1211 <xsl:with-param name="const" select="$const"/>
1212 </xsl:call-template>
1216 <!-- Returns a xpath string with the location of the operator uri or id attribute -->
1217 <xsl:template name="op_attr">
1218 <xsl:param name="attr_type"/>
1219 <xsl:param name="not" select="'false'"/>
1220 <xsl:param name="c-tag"/>
1221 <xsl:param name="const" select="'false'"/>
1223 <xsl:variable name="apply">
1224 <xsl:if test="$not = 'true'">APPLY/</xsl:if>
1228 <xsl:when test="$const = 'true'">
1229 <xsl:value-of select="concat('{',$attr_type,'}')"/>
1232 <xsl:value-of select="concat('{',$apply,$c-tag,'/',$attr_type,'}')"/>
1237 <xsl:template name="copy_attributes">
1238 <xsl:param name="c-tag"/>
1239 <xsl:param name="hide" select="0"/>
1240 <xsl:param name="arity" select="0"/>
1241 <xsl:param name="not" select="'false'"/>
1242 <xsl:param name="ignore" select="''"/>
1244 <xsl:variable name="test">
1245 <xsl:call-template name="test_on_attributes">
1246 <xsl:with-param name="names" select="$ignore"/>
1247 </xsl:call-template>
1250 <xsl:for-each select="@*">
1251 <xsl:if test="contains($test,concat('+',name(),'+')) = false()">
1252 <xsl:attribute name="{name()}">
1253 <xsl:call-template name="set_attribute">
1254 <xsl:with-param name="attr" select="."/>
1255 <xsl:with-param name="c-tag" select="$c-tag"/>
1256 <xsl:with-param name="hide" select="$hide"/>
1257 <xsl:with-param name="arity" select="$arity"/>
1258 <xsl:with-param name="not" select="$not"/>
1259 </xsl:call-template>
1265 <xsl:template name="test_on_attributes">
1266 <xsl:param name="names" select="''"/>
1269 <xsl:when test="contains($names,'+')">
1270 <xsl:variable name="name">
1271 <xsl:call-template name="test_on_attributes">
1272 <xsl:with-param name="names" select="normalize-space(substring-after($names,'+'))"/>
1273 </xsl:call-template>
1276 <xsl:value-of select="concat('+',normalize-space(substring-before($names,'+')),$name)"/>
1279 <xsl:value-of select="concat('+',normalize-space($names),'+')"/>
1284 <xsl:template name="set_attribute">
1285 <xsl:param name="attr"/>
1286 <xsl:param name="c-tag"/>
1287 <xsl:param name="hide" select="0"/>
1288 <xsl:param name="arity" select="0"/>
1289 <xsl:param name="not" select="'false'"/>
1292 <xsl:when test="$attr = '$APP-ID'">{@id}</xsl:when>
1293 <xsl:when test="$attr = '$OP-ID' or $attr = '$OP-URI'">
1294 <xsl:variable name="attr_type">
1296 <xsl:when test="$attr = '$OP-ID'">@id</xsl:when>
1297 <xsl:otherwise>@uri</xsl:otherwise>
1301 <xsl:call-template name="op_attr">
1302 <xsl:with-param name="attr_type" select="$attr_type"/>
1303 <xsl:with-param name="not" select="$not"/>
1304 <xsl:with-param name="c-tag" select="$c-tag"/>
1305 <xsl:with-param name="const" select="$arity = 0 and $hide = 0"/>
1306 </xsl:call-template>
1309 <xsl:value-of select="$attr"/>