Mercurial > hg > ooxml
annotate refs.xsl @ 26:d2ca3ea1f5ae
plumb in and use inverted ref table (via key)
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Fri, 07 Apr 2017 18:42:47 +0100 |
parents | a5125a2e77ea |
children | 8309dcfce613 |
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"> |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
4 <xsl:variable name="pat1">("[^"]*")|(\{[^}]+})|(,)|([^=\-+*/();:,.$<>^!]+(?:\.[^=\-+*/();:,.$<>^!]+)*\()|([)])|(^=|\()|((?:'[^']+')|(?:\[[0-9]+\][^!]*))|(\$?[A-Z]+\$?[0-9]+)|([a-zA-Z_\\][a-zA-Z0-9._]*)|(.)</xsl:variable> |
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
5 <xsl:param name="pat" select="$pat1"/> |
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
6 |
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
7 <xsl:template match="/"> |
23 | 8 <refs><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
|
9 </xsl:template> |
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
10 |
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
|
11 <xsl:template match="s:c[s:f]"> |
22
ca98c74a7cb1
towards var handling, no lookup yet
Henry S. Thompson <ht@markup.co.uk>
parents:
21
diff
changeset
|
12 <xsl:variable name="tokens" select="analyze-string(s:f/.,$pat)/xf:match/xf:group"/> |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
13 <xsl:if test="@r='xxx'"><xsl:message><xsl:value-of select="$tokens/@nr"/></xsl:message> |
21 | 14 <xsl:message><xsl:value-of select="$tokens/."/></xsl:message> |
15 </xsl:if> | |
22
ca98c74a7cb1
towards var handling, no lookup yet
Henry S. Thompson <ht@markup.co.uk>
parents:
21
diff
changeset
|
16 <xsl:if test="$tokens[@nr=(7,8,9)]"> |
21 | 17 <xsl:variable name="n" select="count($tokens)"/> |
18 <xsl:variable name="singles" select="for $i in (1 to $n) | |
23 | 19 return if ($tokens[$i][@nr=(8,9)] and |
20 not($tokens[$i - 1][@nr=10 and | |
21 .=(':','!')]) and | |
22 not($tokens[$i + 1][@nr=10 and .=':'])) | |
21 | 23 then translate($tokens[$i],'$','') |
24 else ()"/> | |
23 | 25 <!-- Note that we don't bother to treat external ranges as ranges, |
26 since we're not going to try to detect cross-document refs --> | |
21 | 27 <xsl:variable name="ranges" select="for $i in (1 to count($tokens)) |
28 return if ($tokens[$i][@nr=10 and .=':' and | |
29 not($i gt 2 and | |
30 $tokens[$i - 2][@nr=10 and .='!'])]) | |
31 then translate(concat($tokens[$i - 1],':',$tokens[$i + 1]),'$','') | |
32 else ()"/> | |
33 <xsl:variable name="externals" select="for $i in (1 to count($tokens)) | |
34 return if ($tokens[$i][@nr=7]) | |
35 then | |
36 let $bit := concat($tokens[$i],'!', | |
37 translate($tokens[$i + 2],'$','')) | |
23 | 38 return if ((($i+3) le $n) and |
39 $tokens[$i + 3][@nr=10 and .=':']) | |
21 | 40 then concat($bit,':',translate($tokens[$i + 4],'$','')) |
41 else $bit | |
42 else ()"/> | |
23 | 43 <ref c="{@r}"> |
25
a5125a2e77ea
towards inverted map of refs
Henry S. Thompson <ht@markup.co.uk>
parents:
24
diff
changeset
|
44 <xsl:for-each select="distinct-values($singles)"> |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
45 <s><xsl:value-of select="."/></s> |
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
46 </xsl:for-each> |
25
a5125a2e77ea
towards inverted map of refs
Henry S. Thompson <ht@markup.co.uk>
parents:
24
diff
changeset
|
47 <xsl:for-each select="distinct-values($ranges)"> |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
48 <r><xsl:value-of select="."/></r> |
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
49 </xsl:for-each> |
25
a5125a2e77ea
towards inverted map of refs
Henry S. Thompson <ht@markup.co.uk>
parents:
24
diff
changeset
|
50 <xsl:for-each select="distinct-values($externals)"> |
24
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
51 <e><xsl:value-of select="."/></e> |
87e0d620deea
switch to elements from attributes and default namespace
Henry S. Thompson <ht@markup.co.uk>
parents:
23
diff
changeset
|
52 </xsl:for-each> |
23 | 53 </ref></xsl:if> |
17
a874f2a81ed2
default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
54 </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
|
55 |
16bba7a0d0bd
one form of refs output, not sure it's what is wanted...
Henry S. Thompson <ht@markup.co.uk>
parents:
17
diff
changeset
|
56 <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
|
57 </xsl:stylesheet> |