Mercurial > hg > ooxml
annotate rect.xsl @ 34:93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
adapt html and ascii to new-format refs,
move a2n and n2a into separate files for re-use
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Wed, 12 Apr 2017 21:35:04 +0100 |
parents | 8309dcfce613 |
children | 468a6cf8bf0b |
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" > |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
20
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" xmlns="http://markup.co.uk/excel" xmlns:xpf="http://www.w3.org/2005/xpath-functions"> |
13 | 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"/> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
8 |
19
9b1b169dc8db
use refs, but broken: doesn't deal with ranges (false negs) or external refs (false pos), and not finding things it should (e.g. kenneth_lay X88)
Henry S. Thompson <ht@markup.co.uk>
parents:
16
diff
changeset
|
9 <xsl:variable name="refs" select="collection()[2]/*"/> |
9b1b169dc8db
use refs, but broken: doesn't deal with ranges (false negs) or external refs (false pos), and not finding things it should (e.g. kenneth_lay X88)
Henry S. Thompson <ht@markup.co.uk>
parents:
16
diff
changeset
|
10 |
26
d2ca3ea1f5ae
plumb in and use inverted ref table (via key)
Henry S. Thompson <ht@markup.co.uk>
parents:
24
diff
changeset
|
11 <xsl:key name="ref" match="e:i" use="@r"/> |
10
01e80c7a9575
simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents:
8
diff
changeset
|
12 |
01e80c7a9575
simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents:
8
diff
changeset
|
13 <xsl:variable name="dim" select="//s:dimension/@ref"/> |
16
2bbd067529b6
improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents:
13
diff
changeset
|
14 |
2bbd067529b6
improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents:
13
diff
changeset
|
15 <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
|
16 <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
|
17 </xsl:template> |
10
01e80c7a9575
simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents:
8
diff
changeset
|
18 |
8
785187b9caef
working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
19 <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
|
20 <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
|
21 <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
|
22 <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
|
23 <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
|
24 <!-- Brute force! --> |
01e80c7a9575
simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents:
8
diff
changeset
|
25 <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
|
26 <a> |
10
01e80c7a9575
simple ascii type matrix output working
Henry S. Thompson <ht@markup.co.uk>
parents:
8
diff
changeset
|
27 <xsl:text> </xsl:text> |
11
480454d218f7
add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents:
10
diff
changeset
|
28 <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
|
29 <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
|
30 <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
|
31 <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
|
32 <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
|
33 <xsl:variable name="col" select="."/> |
480454d218f7
add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents:
10
diff
changeset
|
34 <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
|
35 <xsl:variable name="c" select="$cells[@r=$r]"/> |
19
9b1b169dc8db
use refs, but broken: doesn't deal with ranges (false negs) or external refs (false pos), and not finding things it should (e.g. kenneth_lay X88)
Henry S. Thompson <ht@markup.co.uk>
parents:
16
diff
changeset
|
36 <xsl:variable name="reffed" select="key('ref',$r,$refs)"/> |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
37 <c c="{$col}"> |
11
480454d218f7
add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents:
10
diff
changeset
|
38 <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if> |
27
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
39 <xsl:if test="$c/*"> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
40 <t> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
41 <xsl:if test="$c/@e:class"><xsl:attribute name="c"><xsl:value-of select="substring($c/@e:class,1,1)"/></xsl:attribute></xsl:if> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
42 <xsl:if test="$c/@e:code"><xsl:attribute name="l"><xsl:value-of select="$c/@e:code"/></xsl:attribute></xsl:if> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
43 <xsl:value-of select="substring($c/@e:type,1,1)"/> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
44 </t> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
26
diff
changeset
|
45 </xsl:if> |
26
d2ca3ea1f5ae
plumb in and use inverted ref table (via key)
Henry S. Thompson <ht@markup.co.uk>
parents:
24
diff
changeset
|
46 <xsl:if test="$reffed"><xsl:copy-of select="$reffed/e:r"/></xsl:if> |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
47 </c> |
16
2bbd067529b6
improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents:
13
diff
changeset
|
48 </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
|
49 </r> |
11
480454d218f7
add markup, indicate if computed or not
Henry S. Thompson <ht@markup.co.uk>
parents:
10
diff
changeset
|
50 <xsl:text> </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
|
51 </a> |
8
785187b9caef
working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
52 </xsl:if> |
785187b9caef
working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
53 </xsl:template> |
785187b9caef
working toward doing an ascii-rectangle repr of a sheet
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
54 </xsl:stylesheet> |