Mercurial > hg > ooxml
comparison tokenise.xsl @ 40:ac6d1ca099f7
simplified rect output, refs (not refs2) working again
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Tue, 02 May 2017 09:20:13 +0100 |
parents | 4c6a341e75da |
children | 9bb415e0adc9 |
comparison
equal
deleted
inserted
replaced
39:4c6a341e75da | 40:ac6d1ca099f7 |
---|---|
20 <!-- Tokenise a formula, recursively wrt variables | 20 <!-- Tokenise a formula, recursively wrt variables |
21 Output is composed of e:* as follows: | 21 Output is composed of e:* as follows: |
22 b: Boolean constant | 22 b: Boolean constant |
23 c: A list (function parameter) separator | 23 c: A list (function parameter) separator |
24 e: An external (variable, cell or range) reference | 24 e: An external (variable, cell or range) reference |
25 f: A function name followed by an opening parenthesis | |
26 l: The beginning of the formula or an opening paren | 25 l: The beginning of the formula or an opening paren |
27 m: A constant matrix | 26 m: A constant matrix |
27 o: A function name followed by an opening parenthesis | |
28 p: A close-paren | 28 p: A close-paren |
29 q: A text (delimited by double quotes) | 29 q: A text (delimited by double quotes) |
30 r: A range reference (two children, either e or s or u (unsupported)) | 30 r: A range reference (two children, either e or s or u (unsupported)) |
31 s: A single-cell reference | 31 s: A single-cell reference |
32 v: A variable name [should only occur inside e] | 32 v: A variable name [should only occur inside e] |
34 --> | 34 --> |
35 <xsl:param name="formula" as="xs:string" required="yes"/> | 35 <xsl:param name="formula" as="xs:string" required="yes"/> |
36 <!-- The row and column number of the cell whence the formula came --> | 36 <!-- The row and column number of the cell whence the formula came --> |
37 <xsl:param name="row" required="yes" as="xs:integer"/> | 37 <xsl:param name="row" required="yes" as="xs:integer"/> |
38 <xsl:param name="col" required="yes" as="xs:integer"/> | 38 <xsl:param name="col" required="yes" as="xs:integer"/> |
39 <xsl:message>tok: <xsl:value-of select="$formula"/></xsl:message> | 39 <xsl:if test="false()"><xsl:message>tok: <xsl:value-of select="$formula"/></xsl:message></xsl:if> |
40 <xsl:sequence select=" | 40 <xsl:sequence select=" |
41 let $tokens := analyze-string($formula,$pat)/xf:match/xf:group | 41 let $tokens := analyze-string($formula,$pat)/xf:match/xf:group |
42 return e:tok1($tokens,count($tokens),1,$row,$col,())"/> | 42 return e:tok1($tokens,count($tokens),1,$row,$col,())"/> |
43 </xsl:function> | 43 </xsl:function> |
44 | 44 |
48 <xsl:param name="i" required="yes" as="xs:integer"/> | 48 <xsl:param name="i" required="yes" as="xs:integer"/> |
49 <xsl:param name="row" required="yes" as="xs:integer"/> | 49 <xsl:param name="row" required="yes" as="xs:integer"/> |
50 <xsl:param name="col" required="yes" as="xs:integer"/> | 50 <xsl:param name="col" required="yes" as="xs:integer"/> |
51 <xsl:param name="soFar" as="element(*)*"/> | 51 <xsl:param name="soFar" as="element(*)*"/> |
52 <xsl:variable name="last" select="$soFar[count($soFar)]"></xsl:variable> | 52 <xsl:variable name="last" select="$soFar[count($soFar)]"></xsl:variable> |
53 <xsl:message>tok1: <xsl:value-of select="$n"/>|<xsl:value-of select="$i"/>|<xsl:value-of select="if ($last instance of element()) then name($last) else 'bogus'"/>|<xsl:value-of select="string($last)"/></xsl:message> | 53 <xsl:if test="false()"><xsl:message>tok1: <xsl:value-of select="$n"/>|<xsl:value-of select="$i"/>|<xsl:value-of select="if ($last instance of element()) then name($last) else 'bogus'"/>|<xsl:value-of select="string($last)"/></xsl:message></xsl:if> |
54 <xsl:sequence select=" | 54 <xsl:sequence select=" |
55 if ($i gt $n) | 55 if ($i gt $n) |
56 then $soFar | 56 then $soFar |
57 else | 57 else |
58 let $next := e:expand($tokens,$i,true(),$row,$col), | 58 let $next := e:expand($tokens,$i,true(),$row,$col), |
65 <xsl:param name="tokens" required="yes" as="element(xf:group)*"/> | 65 <xsl:param name="tokens" required="yes" as="element(xf:group)*"/> |
66 <xsl:param name="i" required="yes" as="xs:integer"/> | 66 <xsl:param name="i" required="yes" as="xs:integer"/> |
67 <xsl:param name="local" required="yes" as="xs:boolean"/> | 67 <xsl:param name="local" required="yes" as="xs:boolean"/> |
68 <xsl:param name="row" required="yes" as="xs:integer"/> | 68 <xsl:param name="row" required="yes" as="xs:integer"/> |
69 <xsl:param name="col" required="yes" as="xs:integer"/> | 69 <xsl:param name="col" required="yes" as="xs:integer"/> |
70 <xsl:message>exp: <xsl:value-of select="$tokens[$i]/@nr"/>:<xsl:value-of select="$tokens[$i]"/>,<xsl:value-of select="$tokens[$i+1]"/></xsl:message> | 70 <xsl:if test="false()"><xsl:message>exp: <xsl:value-of select="$tokens[$i]/@nr"/>:<xsl:value-of select="$tokens[$i]"/>,<xsl:value-of select="$tokens[$i+1]"/></xsl:message></xsl:if> |
71 <xsl:sequence select=" | 71 <xsl:sequence select=" |
72 let $t := $tokens[$i], | 72 let $t := $tokens[$i], |
73 $r := $tokens[$i + 1] return | 73 $r := $tokens[$i + 1] return |
74 if ($t/@nr=1) then e:exp1($i,'q',string($t)) | 74 if ($t/@nr=1) then e:exp1($i,'q',string($t)) |
75 else if ($t/@nr=2) then e:exp1($i,'m',string($t)) | 75 else if ($t/@nr=2) then e:exp1($i,'m',string($t)) |
76 else if ($t/@nr=3) then e:exp1($i,'c',',') | 76 else if ($t/@nr=3) then e:exp1($i,'c',',') |
77 else if ($t/@nr=4) then e:exp1($i,'f',string($t)) | 77 else if ($t/@nr=4) then e:exp1($i,'o',string($t)) |
78 else if ($t/@nr=5) then e:exp1($i,'p',')') | 78 else if ($t/@nr=5) then e:exp1($i,'p',')') |
79 else if ($t/@nr=6) then e:exp1($i,'l',string($t)) | 79 else if ($t/@nr=6) then e:exp1($i,'l',string($t)) |
80 else if ($t/@nr=7) | 80 else if ($t/@nr=7) |
81 then let $xref := substring-before($t,'!') return | 81 then let $xref := substring-before($t,'!') return |
82 if ($xref=('[0]',$sheet-name)) | 82 if ($xref=('[0]',$sheet-name)) |
110 </xsl:when> | 110 </xsl:when> |
111 <xsl:otherwise> | 111 <xsl:otherwise> |
112 <xsl:variable name="res"> | 112 <xsl:variable name="res"> |
113 <x><xsl:value-of select="$soFar"/></x> | 113 <x><xsl:value-of select="$soFar"/></x> |
114 </xsl:variable> | 114 </xsl:variable> |
115 <xsl:message>amal: <xsl:value-of select="$res/."/></xsl:message> | 115 <xsl:if test="false()"><xsl:message>amal: <xsl:value-of select="$res/."/></xsl:message></xsl:if> |
116 <xsl:sequence select="[$i,$res/*]"/> | 116 <xsl:sequence select="[$i,$res/*]"/> |
117 </xsl:otherwise> | 117 </xsl:otherwise> |
118 </xsl:choose> | 118 </xsl:choose> |
119 | 119 |
120 </xsl:function> | 120 </xsl:function> |
126 <xsl:variable name="elt"> | 126 <xsl:variable name="elt"> |
127 <xsl:element name="{$name}" namespace="http://markup.co.uk/excel"> | 127 <xsl:element name="{$name}" namespace="http://markup.co.uk/excel"> |
128 <xsl:value-of select="$val"/> | 128 <xsl:value-of select="$val"/> |
129 </xsl:element> | 129 </xsl:element> |
130 </xsl:variable> | 130 </xsl:variable> |
131 <xsl:message>exp1: <xsl:value-of select="$name"/>|<xsl:value-of select="$val"/>|<xsl:value-of select="name($elt/*)"/></xsl:message> | 131 <xsl:if test="false()"><xsl:message>exp1: <xsl:value-of select="$name"/>|<xsl:value-of select="$val"/>|<xsl:value-of select="name($elt/*)"/></xsl:message></xsl:if> |
132 <xsl:sequence select="[$i+1,$elt/*]"/> | 132 <xsl:sequence select="[$i+1,$elt/*]"/> |
133 </xsl:function> | 133 </xsl:function> |
134 | 134 |
135 <xsl:function name="e:single" as="element(e:s)"> | 135 <xsl:function name="e:single" as="element(e:s)"> |
136 <!-- I'm _guessing_ that external doesn't matter, i.e. that you | 136 <!-- I'm _guessing_ that external doesn't matter, i.e. that you |