Mercurial > hg > ooxml
annotate refs.xsl @ 36:ae605b77d1e4
compute (but not use) master formula cells info,
extend refs collection to include abs/reloc info
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Tue, 25 Apr 2017 12:24:31 +0100 |
parents | 93fd0d532754 |
children | ac3cd8de7a10 |
rev | line source |
---|---|
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
1 <?xml version='1.0'?> |
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" > |
23 | 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 e xf" xmlns="http://markup.co.uk/excel" xmlns:xf="http://www.w3.org/2005/xpath-functions"> |
27
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
4 <xsl:param name="sheet-number"/> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
5 <xsl:param name="xlDir"/> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
6 |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
7 <xsl:include href="a2n.xsl"/> |
27
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
8 |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
9 <xsl:variable name="pat1">("[^"]*")|(\{[^}]+})|(,)|([^=\-+*/();:,.$<>^!]+(?:\.[^=\-+*/();:,.$<>^!]+)*\()|([)])|(^=|\()|((?:'[^']+')|(?:\[[0-9]+\][^!]*))|(\$?[A-Z]+\$?[0-9]+)|([a-zA-Z_\\][a-zA-Z0-9._]*)|(.)</xsl:variable> |
27
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
10 <xsl:param name="pat" select="$pat1"/><!-- xsl:param for refinement debugging by passing in the pattern --> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
11 |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
12 <xsl:variable name="workbook" select="document(concat($xlDir,'/workbook.xml'))/*"/> |
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
13 <xsl:variable name="sheet-name" select="$workbook/s:sheets/s:sheet[@sheetId=$sheet-number]/@name"/> |
29
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
14 |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
15 <xsl:function name="e:lookup" as="xs:string*"> |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
16 <xsl:param name="name" as="xs:string" required="yes"/> |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
17 <xsl:variable name="defn" select="$workbook/s:definedNames/s:definedName[@name=$name]"/> |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
18 <xsl:sequence select="let $prefix := concat($sheet-name,'!') |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
19 return if ($defn and |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
20 starts-with($defn,$prefix)) |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
21 then substring-after($defn,$prefix) |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
22 else ()"/> |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
23 </xsl:function> |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
24 |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
25 <xsl:function name="e:tokenise" as="array(element(*)*)*"> |
29
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
26 <!-- Tokenise a formula, recursively wrt variables --> |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
27 <xsl:param name="formula" as="xs:string" required="yes"/> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
28 <!-- The row and column number of the cell whence the formula came --> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
29 <xsl:param name="row" required="yes" as="xs:int"/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
30 <xsl:param name="col" required="yes" as="xs:int"/> |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
31 <xsl:sequence select=" |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
32 let $tokens := analyze-string($formula,$pat)/xf:match/xf:group |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
33 return if ($tokens[@nr=(7,8,9)]) |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
34 then |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
35 let $n := count($tokens), |
30
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
36 $vars := for $i in (1 to $n) return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
37 let $t := $tokens[$i], |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
38 $l := $tokens[$i - 1], |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
39 $r := $tokens[$i + 1] return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
40 if ($t/@nr=9 and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
41 not($l[@nr=10 and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
42 .=(':','!')]) and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
43 not($r[@nr=10 and .=':'])) |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
44 then string($t) |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
45 else (), |
29
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
46 $defns := for $var in $vars return e:lookup($var), |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
47 $recur := for $sub in $defns |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
48 return if ($sub) then e:tokenise($sub,$row,$col) |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
49 else (), |
30
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
50 $singles := for $i in (1 to $n) return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
51 let $t := $tokens[$i], |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
52 $l := $tokens[$i - 1], |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
53 $r := $tokens[$i + 1] return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
54 if ($t/@nr=8 and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
55 not($l[@nr=10 and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
56 .=(':','!')]) and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
57 not($r[@nr=10 and .=':'])) |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
58 then e:single($t,$row,$col,false()) |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
59 else (), |
30
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
60 $ranges := for $i in (1 to count($tokens)) return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
61 let $t := $tokens[$i] return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
62 if ($t[@nr=10 and .=':' and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
63 not($i gt 2 and |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
64 $tokens[$i - 2][@nr=10 and .='!'])]) |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
65 then let $l := $tokens[$i - 1], |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
66 $r := $tokens[$i + 1] |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
67 return e:range(e:single($l, |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
68 $row,$col,false()), |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
69 e:single($r, |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
70 $row,$col,false())) |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
71 else (), |
30
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
72 $externals := for $i in (1 to count($tokens)) return |
16eff0d30d4d
tidied dereferencing, added simple (no recursion) coverage for variables in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
29
diff
changeset
|
73 let $t := $tokens[$i] return |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
33
diff
changeset
|
74 if ($t/@nr=7 and $tokens[$i+1]='!') |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
75 then |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
76 let $ext := $t!='[0]', |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
77 $ref := e:single($tokens[$i + 2], |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
78 $row,$col,$ext), |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
79 $res := if ((($i+3) le $n) and |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
80 $tokens[$i + 3][@nr=10 and .=':']) |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
81 then e:range($ref, |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
82 e:single($tokens[$i+4], |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
83 $row,$col,$ext)) |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
84 else $ref return |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
85 if ($ext) |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
86 then e:external($t,$res) |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
87 else $res |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
88 else () |
29
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
89 return [($singles,for $a in $recur return $a?1), |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
90 ($ranges,for $a in $recur return $a?2), |
87ed04a0fde2
recursion in place, need to check for names in ranges
Henry S. Thompson <ht@markup.co.uk>
parents:
28
diff
changeset
|
91 ($externals,for $a in $recur return $a?3)] |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
92 else ()"/> |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
93 </xsl:function> |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
94 |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
95 <xsl:function name="e:single" as="element(*)"> |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
96 <xsl:param name="group" as="element(xf:group)"/> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
97 <xsl:param name="row" as="xs:integer"/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
98 <xsl:param name="col" as="xs:integer"/> |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
99 <xsl:param name="external" as="xs:boolean"/> |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
100 <xsl:variable name="val" select="if ($group/@nr=9) then e:lookup($group) |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
101 else string($group)"/> |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
102 <xsl:choose> |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
103 <xsl:when test="count($val)>0 or not($external)"> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
104 <xsl:sequence select="e:cr($val,$row,$col)"/> |
33
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
105 </xsl:when> |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
106 <xsl:otherwise> |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
107 <v><xsl:value-of select="$group"/></v> |
27bffc66ce10
external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
Henry S. Thompson <ht@markup.co.uk>
parents:
32
diff
changeset
|
108 </xsl:otherwise> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
109 </xsl:choose> |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
110 </xsl:function> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
111 |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
112 <xsl:function name="e:range" as="element(e:r)"> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
113 <xsl:param name="l" as="element(e:s)" required="yes"/> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
114 <xsl:param name="r" as="element(e:s)" required="yes"/> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
115 <r><xsl:copy-of select="$l"/><xsl:copy-of select="$r"/></r> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
116 </xsl:function> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
117 |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
118 <xsl:function name="e:external" as="element(e:e)"> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
119 <xsl:param name="source" as="element(xf:group)" required="yes"/> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
120 <xsl:param name="ref" as="element(*)" required="yes"/> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
121 <e s="{$source}"><xsl:sequence select="$ref"/></e> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
122 </xsl:function> |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
123 |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
124 <xsl:template match="/"> |
27
8309dcfce613
preparing for variable deref
Henry S. Thompson <ht@markup.co.uk>
parents:
25
diff
changeset
|
125 <refs sheetName="{$sheet-name}"><xsl:apply-templates select="//s:c"/></refs> |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
126 </xsl:template> |
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
127 |
18
16bba7a0d0bd
one form of refs output, not sure it's what is wanted...
Henry S. Thompson <ht@markup.co.uk>
parents:
17
diff
changeset
|
128 <xsl:template match="s:c[s:f]"> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
129 <xsl:variable name="cr" select="e:cr(@r,0,0)"/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
130 <xsl:variable name="tokens" select="e:tokenise(s:f/.,$cr/e:r[1],$cr/e:r[2])"/> |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
33
diff
changeset
|
131 <xsl:if test="@r='xxx'"><xsl:message><xsl:value-of select="s:f"/>|<xsl:value-of select="(analyze-string(s:f/.,$pat)/xf:match/xf:group)[3]/@nr"/></xsl:message> |
21 | 132 </xsl:if> |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
133 <xsl:if test="count($tokens)>0"> |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
134 <xsl:variable name="singles" select="$tokens?1"/> |
23 | 135 <!-- Note that we don't bother to treat external ranges as ranges, |
136 since we're not going to try to detect cross-document refs --> | |
28
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
137 <xsl:variable name="ranges" select="$tokens?2"/> |
c56a2e6990bd
convert tokenisation to a function, so can make recursive
Henry S. Thompson <ht@markup.co.uk>
parents:
27
diff
changeset
|
138 <xsl:variable name="externals" select="$tokens?3"/> |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
139 <!-- Lost distinct-values filter, not sure it's really possible... --> |
23 | 140 <ref c="{@r}"> |
32
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
141 <xsl:copy-of select="$singles"/> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
142 <xsl:copy-of select="$ranges"/> |
f4432c1faf7f
move to more structure mostly working but external vars are lost
Henry S. Thompson <ht@markup.co.uk>
parents:
31
diff
changeset
|
143 <xsl:copy-of select="$externals"/> |
23 | 144 </ref></xsl:if> |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
145 </xsl:template> |
18
16bba7a0d0bd
one form of refs output, not sure it's what is wanted...
Henry S. Thompson <ht@markup.co.uk>
parents:
17
diff
changeset
|
146 |
16bba7a0d0bd
one form of refs output, not sure it's what is wanted...
Henry S. Thompson <ht@markup.co.uk>
parents:
17
diff
changeset
|
147 <xsl:template match="s:c"/> |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
148 </xsl:stylesheet> |