1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 xmlns:m="http://www.w3.org/1998/Math/MathML"
3 xmlns:xlink="http://www.w3.org/1999/xlink">
5 <xsl:key name="sequent" use="m:mtr/m:mtd/m:mrow/m:mtext/text()" match="m:mtable[starts-with(m:mtr/m:mtd/m:mrow/m:mtext/text(),'Sequent (')]"/>
7 <xsl:template match="/">
8 <xsl:apply-templates select="*"/>
11 <xsl:template match="m:mi">
12 <xsl:param name="sequentno" select="'/..'"/>
14 <xsl:when test="contains(.,'%')">
15 <xsl:variable name="var" select="."/>
16 <m:maction actiontype="toggle">
17 <m:mi mathcolor="green"><xsl:value-of select="."/></m:mi>
19 <m:mi mathcolor="green"><xsl:value-of select="$var"/>: </m:mi>
20 <xsl:call-template name="look_for_decl">
21 <xsl:with-param name="csequent" select="$sequentno"/>
22 <xsl:with-param name="var" select="$var"/>
29 <xsl:apply-templates select="@*|node()"/>
35 <xsl:template match="m:mtable[starts-with(m:mtr/m:mtd/m:mrow/m:mtext/text(),'Sequent')]">
37 <xsl:variable name="text" select="m:mtr/m:mtd/m:mrow/m:mtext/text()"/>
38 <xsl:variable name="tmp1" select="substring-after($text,'Sequent (')"/>
39 <xsl:variable name="tmp2" select="substring-before($tmp1,')')"/>
40 <xsl:apply-templates select="*|@*|text()">
41 <xsl:with-param name="sequentno" select="$tmp2"/>
42 </xsl:apply-templates>
46 <xsl:template match="*|@*|text()">
47 <xsl:param name="sequentno" select="'/..'"/>
49 <xsl:apply-templates select="*|@*|text()">
50 <xsl:with-param name="sequentno" select="$sequentno"/>
51 </xsl:apply-templates>
55 <xsl:template name="look_for_decl">
56 <xsl:param name="csequent" select="/.."/>
57 <xsl:param name="var" select="''"/>
58 <xsl:param name="result" select="0"/>
60 <xsl:when test="$csequent=''">
66 <xsl:variable name="sect_table" select="key('sequent',concat('Sequent (',$csequent,')'))"/>
67 <xsl:variable name="check_res" select="$sect_table/m:mtr/m:mtable/m:mtr/m:mtd/m:mrow/m:mo[text()=$var]/following-sibling::*[2]"/>
69 <xsl:when test="not ($check_res)">
70 <xsl:variable name="new_sequent">
71 <xsl:call-template name="truncate">
72 <xsl:with-param name="tail" select="$csequent"/>
75 <xsl:call-template name="look_for_decl">
76 <xsl:with-param name="csequent" select="$new_sequent"/>
77 <xsl:with-param name="var" select="$var"/>
81 <xsl:copy-of select="$check_res"/>
88 <xsl:template name="truncate">
89 <xsl:param name="tail" select="''"/>
90 <xsl:param name="head" select="''"/>
92 <xsl:when test="substring-before($tail,' ')=''">
93 <xsl:value-of select="$head"/>
96 <xsl:variable name="head1">
97 <xsl:if test="$head !=''">
98 <xsl:value-of select="concat($head,' ')"/>
101 <xsl:call-template name="truncate">
102 <xsl:with-param name="tail" select="substring-after($tail,' ')"/>
103 <xsl:with-param name="head" select="concat($head1,substring-before($tail,' '))"/>