comparison 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
comparison
equal deleted inserted replaced
20:104ef815b0b0 21:f05f0d0ee296
7 <xsl:template match="/"> 7 <xsl:template match="/">
8 <e:refs><xsl:apply-templates select="//s:c"/></e:refs> 8 <e:refs><xsl:apply-templates select="//s:c"/></e:refs>
9 </xsl:template> 9 </xsl:template>
10 10
11 <xsl:template match="s:c[s:f]"> 11 <xsl:template match="s:c[s:f]">
12 <xsl:variable name="refs" select="analyze-string(.,$pat)/xf:match/xf:group[@nr=8]"/> 12 <xsl:variable name="tokens" select="analyze-string(.,$pat)/xf:match/xf:group"/>
13 <xsl:if test="$refs"><e:ref c="{@r}" r="{for $ref in $refs return translate($ref,'$','')}"/></xsl:if> 13 <xsl:if test="@r='B1'"><xsl:message><xsl:value-of select="$tokens/@nr"/></xsl:message>
14 <xsl:message><xsl:value-of select="$tokens/."/></xsl:message>
15 </xsl:if>
16 <xsl:if test="$tokens[@nr=8]">
17 <xsl:variable name="n" select="count($tokens)"/>
18 <xsl:variable name="singles" select="for $i in (1 to $n)
19 return if ($tokens[$i][@nr=8] and not($tokens[$i - 1][@nr=10 and .=(':','!')]) and not($tokens[$i + 1][@nr=10 and .=':']))
20 then translate($tokens[$i],'$','')
21 else ()"/>
22 <xsl:variable name="ranges" select="for $i in (1 to count($tokens))
23 return if ($tokens[$i][@nr=10 and .=':' and
24 not($i gt 2 and
25 $tokens[$i - 2][@nr=10 and .='!'])])
26 then translate(concat($tokens[$i - 1],':',$tokens[$i + 1]),'$','')
27 else ()"/>
28 <xsl:variable name="externals" select="for $i in (1 to count($tokens))
29 return if ($tokens[$i][@nr=7])
30 then
31 let $bit := concat($tokens[$i],'!',
32 translate($tokens[$i + 2],'$',''))
33 return if ((($i+3) le $n) and $tokens[$i + 3][@nr=10 and .=':'])
34 then concat($bit,':',translate($tokens[$i + 4],'$',''))
35 else $bit
36 else ()"/>
37 <e:ref c="{@r}" r="{$singles}" rr="{$ranges}" er="{$externals}"/></xsl:if>
14 </xsl:template> 38 </xsl:template>
15 39
16 <xsl:template match="s:c"/> 40 <xsl:template match="s:c"/>
17 </xsl:stylesheet> 41 </xsl:stylesheet>