Mercurial > hg > ooxml
comparison n2a.xsl @ 49:d3569a8cbf7a
shared refs rebuilt correctly
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Wed, 10 May 2017 20:13:06 +0100 |
parents | 6ed900e8cc61 |
children | 9bb415e0adc9 |
comparison
equal
deleted
inserted
replaced
48:5d9806f90896 | 49:d3569a8cbf7a |
---|---|
55 else if (local-name($b)='e') | 55 else if (local-name($b)='e') |
56 then concat($b/@x,'!',e:rnf($b/*)) | 56 then concat($b/@x,'!',e:rnf($b/*)) |
57 else $b/text())"/> | 57 else $b/text())"/> |
58 </xsl:function> | 58 </xsl:function> |
59 | 59 |
60 <xsl:template name="shift"> | |
61 <xsl:param name="row" as="xs:integer"/> | |
62 <xsl:param name="col" as="xs:integer"/> | |
63 <!-- Reconstruct a shifted version of an analysed formula, relative to a new position --> | |
64 <xsl:copy> | |
65 <xsl:apply-templates select="@*"/> | |
66 <xsl:apply-templates select="*" mode="shift"> | |
67 <xsl:with-param name="row" select="$row"/> | |
68 <xsl:with-param name="col" select="$col"/> | |
69 </xsl:apply-templates> | |
70 </xsl:copy> | |
71 </xsl:template> | |
72 | |
73 <xsl:template match="e:s" mode="shift"> | |
74 <xsl:param name="row" as="xs:integer"/> | |
75 <xsl:param name="col" as="xs:integer"/> | |
76 <xsl:copy> | |
77 <xsl:attribute name="r"> | |
78 <xsl:value-of select="concat(e:n2a(e:delta(*[1],$col)), | |
79 e:delta(*[2],$row))"/> | |
80 </xsl:attribute> | |
81 <xsl:apply-templates select="node()" mode="shift"> | |
82 <xsl:with-param name="row" select="$row"/> | |
83 <xsl:with-param name="col" select="$col"/> | |
84 </xsl:apply-templates> | |
85 </xsl:copy> | |
86 </xsl:template> | |
87 | |
88 <xsl:function name="e:delta" as="xs:integer"> | |
89 <xsl:param name="c" as="element(*)"/> | |
90 <xsl:param name="h" as="xs:integer"/> | |
91 <xsl:value-of select="if (local-name($c)='a') then xs:integer($c/text()) | |
92 else if (local-name($c)='r') | |
93 then xs:integer($c/@d)+$h | |
94 else e:shouldnt()"/> | |
95 </xsl:function> | |
96 | |
97 <xsl:template match="e:*|@*" mode="shift"> | |
98 <xsl:param name="row" as="xs:integer"/> | |
99 <xsl:param name="col" as="xs:integer"/> | |
100 <xsl:copy> | |
101 <xsl:apply-templates select="node()|@*" mode="shift"> | |
102 <xsl:with-param name="row" select="$row"/> | |
103 <xsl:with-param name="col" select="$col"/> | |
104 </xsl:apply-templates> | |
105 </xsl:copy> | |
106 </xsl:template> | |
107 | |
60 <xsl:function name="e:shouldnt"> | 108 <xsl:function name="e:shouldnt"> |
61 <xsl:message terminate="yes">shouldn't happen</xsl:message> | 109 <xsl:message terminate="yes">shouldn't happen</xsl:message> |
62 </xsl:function> | 110 </xsl:function> |
63 </xsl:stylesheet> | 111 </xsl:stylesheet> |