annotate rect.xsl @ 72:0654e37583b5

appears to read kdir.js correctly
author Henry S. Thompson <ht@markup.co.uk>
date Thu, 29 Jun 2017 17:58:06 +0100
parents d3569a8cbf7a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
1 <?xml version='1.0'?>
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" >
40
ac6d1ca099f7 simplified rect output, refs (not refs2) working again
Henry S. Thompson <ht@markup.co.uk>
parents: 39
diff changeset
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:s="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs s xpf e" xmlns="http://markup.co.uk/excel" xmlns:xpf="http://www.w3.org/2005/xpath-functions">
13
f78e8c55c06b three steps now
Henry S. Thompson <ht@markup.co.uk>
parents: 12
diff changeset
4 <xsl:strip-space elements="s:sheetData"/>
8
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
5
34
93fd0d532754 fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents: 27
diff changeset
6 <xsl:include href="a2n.xsl"/>
93fd0d532754 fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents: 27
diff changeset
7 <xsl:include href="n2a.xsl"/>
38
468a6cf8bf0b big change wrt formulae compiles, crashes
Henry S. Thompson <ht@markup.co.uk>
parents: 34
diff changeset
8 <xsl:include href="tokenise.xsl"/>
34
93fd0d532754 fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents: 27
diff changeset
9
48
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
10 <xsl:variable name="shared">
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
11 <xsl:apply-templates select="collection()[2]/*"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
12 </xsl:variable>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
13
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
14 <xsl:key name="shared" match="e:master" use="@si"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
15
10
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
16 <xsl:variable name="dim" select="//s:dimension/@ref"/>
48
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
17
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
18 <xsl:function name="e:analyse" as="element(*)*">
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
19 <xsl:param name="formula" as="xs:string"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
20 <xsl:param name="row" as="xs:integer"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
21 <xsl:param name="col" as="xs:integer"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
22 <xsl:variable name="toks" select="e:tokenise($formula,$row,$col)"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
23 <xsl:sequence>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
24 <f>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
25 <xsl:copy-of select="$toks"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
26 </f>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
27 <nf><xsl:copy-of select="e:fnf($toks)"/></nf>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
28 </xsl:sequence>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
29 </xsl:function>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
30
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
31 <xsl:template match="e:master">
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
32 <xsl:variable name="rp" select="e:pr(@r)"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
33 <xsl:copy>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
34 <xsl:copy-of select="@si"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
35 <xsl:sequence select="e:analyse(text(),xs:integer($rp//xpf:group[@nr=4]),
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
36 e:a2n($rp//xpf:group[@nr=2]))"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
37 </xsl:copy>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
38 </xsl:template>
16
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
39
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
40 <xsl:template match="/">
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
41 <xsl:apply-templates select="//s:sheetData"/>
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
42 </xsl:template>
10
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
43
8
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
44 <xsl:template match="s:sheetData">
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
45 <xsl:if test="s:row">
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
46 <xsl:variable name="dims" select="analyze-string($dim,'([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)')"/>
10
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
47 <xsl:variable name="height" select="1+xs:integer($dims//xpf:group[@nr='4'])-xs:integer($dims//xpf:group[@nr='2'])"/>
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
48 <xsl:variable name="width" select="1+e:a2n($dims//xpf:group[@nr='3'])-e:a2n($dims//xpf:group[@nr='1'])"/>
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
49 <!-- Brute force! -->
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
50 <xsl:variable name="sheet" select="."/>
24
87e0d620deea switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents: 20
diff changeset
51 <a>
10
01e80c7a9575 simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents: 8
diff changeset
52 <xsl:text>&#10;</xsl:text>
11
480454d218f7 add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
53 <xsl:for-each select="(1 to $height)"><xsl:variable name="row" select="."/>
24
87e0d620deea switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents: 20
diff changeset
54 <r r="{$row}">
16
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
55 <xsl:variable select="$sheet/s:row[@r=$row]/s:c" name="cells"/>
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
56 <xsl:if test="$cells/*">
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
57 <xsl:for-each select="(1 to $width)">
11
480454d218f7 add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
58 <xsl:variable name="col" select="."/>
480454d218f7 add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
59 <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/>
16
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
60 <xsl:variable name="c" select="$cells[@r=$r]"/>
24
87e0d620deea switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents: 20
diff changeset
61 <c c="{$col}">
27
8309dcfce613 preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents: 26
diff changeset
62 <xsl:if test="$c/*">
40
ac6d1ca099f7 simplified rect output, refs (not refs2) working again
Henry S. Thompson <ht@markup.co.uk>
parents: 39
diff changeset
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>
27
8309dcfce613 preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents: 26
diff changeset
64 <xsl:if test="$c/@e:code"><xsl:attribute name="l"><xsl:value-of select="$c/@e:code"/></xsl:attribute></xsl:if>
48
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
65 <xsl:variable name="si" select="$c/s:f/@si"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
66 <xsl:copy-of select="$si"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
67 <xsl:choose>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
68 <xsl:when test="$c/s:f/text()">
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
69 <xsl:sequence select="e:analyse($c/s:f/text(),$row,$col)"/>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
70 </xsl:when>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
71 <xsl:when test="$c/s:f/@si">
49
d3569a8cbf7a shared refs rebuilt correctly
Henry S. Thompson <ht@markup.co.uk>
parents: 48
diff changeset
72 <xsl:variable name="s" select="key('shared',$si,$shared)"/>
d3569a8cbf7a shared refs rebuilt correctly
Henry S. Thompson <ht@markup.co.uk>
parents: 48
diff changeset
73 <xsl:for-each select="$s/e:f"><xsl:call-template name="shift">
d3569a8cbf7a shared refs rebuilt correctly
Henry S. Thompson <ht@markup.co.uk>
parents: 48
diff changeset
74 <xsl:with-param name="row" select="$row"/>
d3569a8cbf7a shared refs rebuilt correctly
Henry S. Thompson <ht@markup.co.uk>
parents: 48
diff changeset
75 <xsl:with-param name="col" select="$col"/>
d3569a8cbf7a shared refs rebuilt correctly
Henry S. Thompson <ht@markup.co.uk>
parents: 48
diff changeset
76 </xsl:call-template></xsl:for-each>
d3569a8cbf7a shared refs rebuilt correctly
Henry S. Thompson <ht@markup.co.uk>
parents: 48
diff changeset
77 <xsl:copy-of select="$s/e:nf"/>
48
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
78 </xsl:when>
5d9806f90896 basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
Henry S. Thompson <ht@markup.co.uk>
parents: 47
diff changeset
79 </xsl:choose>
40
ac6d1ca099f7 simplified rect output, refs (not refs2) working again
Henry S. Thompson <ht@markup.co.uk>
parents: 39
diff changeset
80 <xsl:value-of select="substring($c/@e:type,1,1)"/>
27
8309dcfce613 preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents: 26
diff changeset
81 </xsl:if>
24
87e0d620deea switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents: 20
diff changeset
82 </c>
16
2bbd067529b6 improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents: 13
diff changeset
83 </xsl:for-each></xsl:if>
24
87e0d620deea switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents: 20
diff changeset
84 </r>
11
480454d218f7 add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
85 <xsl:text>&#10;</xsl:text></xsl:for-each>
24
87e0d620deea switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents: 20
diff changeset
86 </a>
8
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
87 </xsl:if>
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
88 </xsl:template>
785187b9caef working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
89 </xsl:stylesheet>