comparison rect.xsl @ 48:5d9806f90896

basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 10 May 2017 16:52:04 +0100
parents 3e9a3e51627e
children d3569a8cbf7a
comparison
equal deleted inserted replaced
47:3e9a3e51627e 48:5d9806f90896
5 5
6 <xsl:include href="a2n.xsl"/> 6 <xsl:include href="a2n.xsl"/>
7 <xsl:include href="n2a.xsl"/> 7 <xsl:include href="n2a.xsl"/>
8 <xsl:include href="tokenise.xsl"/> 8 <xsl:include href="tokenise.xsl"/>
9 9
10 <xsl:variable name="shared">
11 <xsl:apply-templates select="collection()[2]/*"/>
12 </xsl:variable>
13
14 <xsl:key name="shared" match="e:master" use="@si"/>
15
10 <xsl:variable name="dim" select="//s:dimension/@ref"/> 16 <xsl:variable name="dim" select="//s:dimension/@ref"/>
17
18 <xsl:function name="e:analyse" as="element(*)*">
19 <xsl:param name="formula" as="xs:string"/>
20 <xsl:param name="row" as="xs:integer"/>
21 <xsl:param name="col" as="xs:integer"/>
22 <xsl:variable name="toks" select="e:tokenise($formula,$row,$col)"/>
23 <xsl:sequence>
24 <f>
25 <xsl:copy-of select="$toks"/>
26 </f>
27 <nf><xsl:copy-of select="e:fnf($toks)"/></nf>
28 </xsl:sequence>
29 </xsl:function>
30
31 <xsl:template match="e:master">
32 <xsl:variable name="rp" select="e:pr(@r)"/>
33 <xsl:copy>
34 <xsl:copy-of select="@si"/>
35 <xsl:sequence select="e:analyse(text(),xs:integer($rp//xpf:group[@nr=4]),
36 e:a2n($rp//xpf:group[@nr=2]))"/>
37 </xsl:copy>
38 </xsl:template>
11 39
12 <xsl:template match="/"> 40 <xsl:template match="/">
13 <xsl:apply-templates select="//s:sheetData"/> 41 <xsl:apply-templates select="//s:sheetData"/>
14 </xsl:template> 42 </xsl:template>
15 43
32 <xsl:variable name="c" select="$cells[@r=$r]"/> 60 <xsl:variable name="c" select="$cells[@r=$r]"/>
33 <c c="{$col}"> 61 <c c="{$col}">
34 <xsl:if test="$c/*"> 62 <xsl:if test="$c/*">
35 <xsl:if test="$c/@e:class"><xsl:attribute name="t"><xsl:value-of select="substring($c/@e:class,1,1)"/></xsl:attribute></xsl:if> 63 <xsl:if test="$c/@e:class"><xsl:attribute name="t"><xsl:value-of select="substring($c/@e:class,1,1)"/></xsl:attribute></xsl:if>
36 <xsl:if test="$c/@e:code"><xsl:attribute name="l"><xsl:value-of select="$c/@e:code"/></xsl:attribute></xsl:if> 64 <xsl:if test="$c/@e:code"><xsl:attribute name="l"><xsl:value-of select="$c/@e:code"/></xsl:attribute></xsl:if>
37 <xsl:if test="$c/s:f"> 65 <xsl:variable name="si" select="$c/s:f/@si"/>
38 <xsl:variable name="toks" select="e:tokenise($c/s:f,$row,$col)"/> 66 <xsl:copy-of select="$si"/>
39 <f> 67 <xsl:choose>
40 <xsl:copy-of select="$toks"/> 68 <xsl:when test="$c/s:f/text()">
41 </f> 69 <xsl:sequence select="e:analyse($c/s:f/text(),$row,$col)"/>
42 <nf> 70 </xsl:when>
43 <xsl:copy-of select="e:fnf($toks)"/> 71 <xsl:when test="$c/s:f/@si">
44 </nf> 72 <xsl:copy-of select="key('shared',$si,$shared)/*"/>
45 </xsl:if> 73 </xsl:when>
74 </xsl:choose>
46 <xsl:value-of select="substring($c/@e:type,1,1)"/> 75 <xsl:value-of select="substring($c/@e:type,1,1)"/>
47 </xsl:if> 76 </xsl:if>
48 </c> 77 </c>
49 </xsl:for-each></xsl:if> 78 </xsl:for-each></xsl:if>
50 </r> 79 </r>