annotate refs.xsl @ 21:f05f0d0ee296

fix false positives
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 05 Apr 2017 11:24:11 +0100
parents 16bba7a0d0bd
children ca98c74a7cb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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" >
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
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" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" 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">("[^"]*")|(\{[^}]+})|(,)|([^=\-+*/();:,.$&lt;>^!]+(?:\.[^=\-+*/();:,.$&lt;>^!]+)*\()|([)])|(^=|\()|((?:'[^']+')|(?:\[[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="/">
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
8 <e:refs><xsl:apply-templates select="//s:c"/></e: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]">
21
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
12 <xsl:variable name="tokens" select="analyze-string(.,$pat)/xf:match/xf:group"/>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
13 <xsl:if test="@r='B1'"><xsl:message><xsl:value-of select="$tokens/@nr"/></xsl:message>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
14 <xsl:message><xsl:value-of select="$tokens/."/></xsl:message>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
15 </xsl:if>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
16 <xsl:if test="$tokens[@nr=8]">
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
17 <xsl:variable name="n" select="count($tokens)"/>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
18 <xsl:variable name="singles" select="for $i in (1 to $n)
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
19 return if ($tokens[$i][@nr=8] and not($tokens[$i - 1][@nr=10 and .=(':','!')]) and not($tokens[$i + 1][@nr=10 and .=':']))
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
20 then translate($tokens[$i],'$','')
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
21 else ()"/>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
22 <xsl:variable name="ranges" select="for $i in (1 to count($tokens))
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
23 return if ($tokens[$i][@nr=10 and .=':' and
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
24 not($i gt 2 and
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
25 $tokens[$i - 2][@nr=10 and .='!'])])
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
26 then translate(concat($tokens[$i - 1],':',$tokens[$i + 1]),'$','')
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
27 else ()"/>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
28 <xsl:variable name="externals" select="for $i in (1 to count($tokens))
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
29 return if ($tokens[$i][@nr=7])
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
30 then
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
31 let $bit := concat($tokens[$i],'!',
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
32 translate($tokens[$i + 2],'$',''))
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
33 return if ((($i+3) le $n) and $tokens[$i + 3][@nr=10 and .=':'])
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
34 then concat($bit,':',translate($tokens[$i + 4],'$',''))
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
35 else $bit
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
36 else ()"/>
f05f0d0ee296 fix false positives
Henry S. Thompson <ht@markup.co.uk>
parents: 18
diff changeset
37 <e:ref c="{@r}" r="{$singles}" rr="{$ranges}" er="{$externals}"/></xsl:if>
17
a874f2a81ed2 default vis pipeline to raw xml, start extracting refs
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
38 </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
39
16bba7a0d0bd one form of refs output, not sure it's what is wanted...
Henry S. Thompson <ht@markup.co.uk>
parents: 17
diff changeset
40 <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
41 </xsl:stylesheet>