Mercurial > hg > ooxml
comparison a2n.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 | 5d9806f90896 |
comparison
equal
deleted
inserted
replaced
35:e500d7c18aad | 36:ae605b77d1e4 |
---|---|
1 <?xml version='1.0'?> | 1 <?xml version='1.0'?> |
2 <!DOCTYPE xsl:stylesheet SYSTEM "file:///C:/C64/home/ht/lib/xml/xsl.dtd" > | 2 <!DOCTYPE xsl:stylesheet SYSTEM "file:///C:/C64/home/ht/lib/xml/xsl.dtd" > |
3 <xsl:stylesheet xmlns:e="http://markup.co.uk/excel" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0"> | 3 <xsl:stylesheet xmlns:e="http://markup.co.uk/excel" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0" xmlns:xpf="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="e xpf xs" xmlns="http://markup.co.uk/excel"> |
4 <xsl:function name="e:a2n" as="xs:integer"> | 4 |
5 <xsl:function name="e:a2n" as="xs:integer"> | |
5 <!-- Convert an alphabetic excel column 'index' into a number, | 6 <!-- Convert an alphabetic excel column 'index' into a number, |
6 a sort of base 26 + 1, since 'A' is 1 and 'AA' is 27 --> | 7 a sort of base 26 + 1, since 'A' is 1 and 'AA' is 27 --> |
7 <xsl:param name="aa" as="xs:string"/> | 8 <xsl:param name="aa" as="xs:string" required="yes"/> |
9 <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/> | |
8 <xsl:value-of select="let $l := string-length($aa), | 10 <xsl:value-of select="let $l := string-length($aa), |
9 $lv := string-to-codepoints(substring($aa,$l))-$codeBase | 11 $lv := string-to-codepoints(substring($aa,$l))-$codeBase |
10 return if ($l=1) then $lv | 12 return if ($l=1) then $lv |
11 else $lv+(26*e:a2n(substring($aa,1,$l - 1)))"/> | 13 else $lv+(26*e:a2n(substring($aa,1,$l - 1)))"/> |
12 </xsl:function> | 14 </xsl:function> |
15 | |
16 <xsl:function name="e:cr" as="element(e:s)"> | |
17 <!-- Parse a single cell reference into left and right halves, | |
18 either e:a(bsolute) or e:r(elocatable) --> | |
19 <xsl:param name="ref" as="xs:string" required="yes"/> | |
20 <xsl:param name="row" as="xs:integer" required="yes"/> | |
21 <xsl:param name="col" as="xs:integer" required="yes"/> | |
22 <xsl:variable name="cr" select="analyze-string($ref,'([$]?)([A-Z]+)([$]?)([0-9]+)')"/> | |
23 <xsl:variable name="c" select="if ($cr//xpf:group[@nr=1][text()]) then 'a' else 'r'"/> | |
24 <xsl:variable name="cv" select="e:a2n($cr//xpf:group[@nr=2])"/> | |
25 <xsl:variable name="r" select="if ($cr//xpf:group[@nr=3][text()]) then 'a' else 'r'"/> | |
26 <xsl:variable name="rv" select="xs:integer($cr//xpf:group[@nr=4])"/> | |
27 <s r="{$ref}"> | |
28 <xsl:element name="{$c}" namespace="http://markup.co.uk/excel"> | |
29 <xsl:if test="$c='r'"> | |
30 <xsl:attribute name="d"><xsl:value-of select="$cv - $col"/></xsl:attribute> | |
31 </xsl:if> | |
32 <xsl:value-of select="$cv"/> | |
33 </xsl:element> | |
34 <xsl:element name="{$r}" namespace="http://markup.co.uk/excel"> | |
35 <xsl:if test="$r='r'"> | |
36 <xsl:attribute name="d"><xsl:value-of select="$rv - $row"/></xsl:attribute> | |
37 </xsl:if> | |
38 <xsl:value-of select="$rv"/> | |
39 </xsl:element> | |
40 </s> | |
41 </xsl:function> | |
13 </xsl:stylesheet> | 42 </xsl:stylesheet> |