Mercurial > hg > ooxml
annotate refs2.xsl @ 59:f90bbd38b8f6
towards display of reffed info via colour
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Fri, 02 Jun 2017 12:54:54 +0100 |
parents | adeb9575b273 |
children |
rev | line source |
---|---|
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
1 <?xml version='1.0'?> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" > |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs e" xmlns="http://markup.co.uk/excel"> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
4 <!-- Invert the singleton references extracted from formulae by refs.xsl |
41
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
5 Input e:refs/e:ref/(e:s|e:r) e:ref[@r] contains one or more e:s or e:r |
40
ac6d1ca099f7
simplified rect output, refs (not refs2) working again
Henry S. Thompson <ht@markup.co.uk>
parents:
36
diff
changeset
|
6 for each singleton/range reference |
41
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
7 to [e:r/]e:s/@r in @r's formula |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
8 Output e:refs/e:i/e:r e:i[@r] contains one e:r for each cell which |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
9 references r --> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
10 |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
11 <xsl:include href="n2a.xsl"/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
12 <xsl:include href="a2n.xsl"/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
13 |
41
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
14 <xsl:key name="ref" match="e:ref[e:s]" use="for $s in e:s return translate($s/@r,'$','')"/> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
15 <xsl:key name="rrefTL" match="e:ref[e:r]" use="for $s in e:r/(e:s[1]) return translate($s/@r,'$','')"/> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
16 <xsl:key name="rrefBR" match="e:ref[e:r]" use="for $s in e:r/(e:s[2]) return translate($s/@r,'$','')"/> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
17 |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
18 <xsl:template match="e:refs"> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
19 <xsl:variable name="refs" select="."/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
20 <xsl:variable name="invert"> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
21 <xsl:for-each select="distinct-values( |
41
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
22 for $s in e:ref//e:s return translate($s/@r,'$',''))"> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
23 <xsl:variable name="r" select="."/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
24 <i r="{$r}"> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
25 <xsl:for-each select="key('ref',$r,$refs)"> |
58
adeb9575b273
add inverted rel pointers back to referencing from referenced
Henry S. Thompson <ht@markup.co.uk>
parents:
47
diff
changeset
|
26 <r b="{string-join(distinct-values(for $s in e:s return |
adeb9575b273
add inverted rel pointers back to referencing from referenced
Henry S. Thompson <ht@markup.co.uk>
parents:
47
diff
changeset
|
27 if (translate($s/@r,'$','')=$r) then e:bcrnf($s) else ()), |
adeb9575b273
add inverted rel pointers back to referencing from referenced
Henry S. Thompson <ht@markup.co.uk>
parents:
47
diff
changeset
|
28 ',')}"><xsl:value-of select="@r"/></r> |
41
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
29 </xsl:for-each> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
30 <xsl:for-each select="key('rrefTL',$r,$refs)"> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
31 <r><<xsl:value-of select="@r"/></r> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
32 </xsl:for-each> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
33 <xsl:for-each select="key('rrefBR',$r,$refs)"> |
afda541de4c4
working again with new refs
Henry S. Thompson <ht@markup.co.uk>
parents:
40
diff
changeset
|
34 <r><xsl:value-of select="@r"/>></r> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
35 </xsl:for-each> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
36 </i> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
37 </xsl:for-each> |
47
3e9a3e51627e
explicit form match working, but shared still needs work
Henry S. Thompson <ht@markup.co.uk>
parents:
46
diff
changeset
|
38 <!-- We want to be able to sort by frequency, so just d-v isn't enough --> |
3e9a3e51627e
explicit form match working, but shared still needs work
Henry S. Thompson <ht@markup.co.uk>
parents:
46
diff
changeset
|
39 <xsl:for-each-group select="e:nf" group-by="text()"> |
3e9a3e51627e
explicit form match working, but shared still needs work
Henry S. Thompson <ht@markup.co.uk>
parents:
46
diff
changeset
|
40 <nf i="{position()}" n="{count(current-group())}"><xsl:value-of select="current-group()[1]/text()"/></nf> |
3e9a3e51627e
explicit form match working, but shared still needs work
Henry S. Thompson <ht@markup.co.uk>
parents:
46
diff
changeset
|
41 </xsl:for-each-group> |
36
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
42 </xsl:variable> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
43 <xsl:copy> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
44 <xsl:copy-of select="$invert"/> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
45 </xsl:copy> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
46 </xsl:template> |
ae605b77d1e4
compute (but not use) master formula cells info,
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
47 </xsl:stylesheet> |