comparison refs.xsl @ 33:27bffc66ce10

external vars preserved, [0]!... == internal handled, but note that children of ref may not be contiguous by name anymore
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 12 Apr 2017 17:43:54 +0100
parents f4432c1faf7f
children 93fd0d532754
comparison
equal deleted inserted replaced
32:f4432c1faf7f 33:27bffc66ce10
47 $r := $tokens[$i + 1] return 47 $r := $tokens[$i + 1] return
48 if ($t/@nr=8 and 48 if ($t/@nr=8 and
49 not($l[@nr=10 and 49 not($l[@nr=10 and
50 .=(':','!')]) and 50 .=(':','!')]) and
51 not($r[@nr=10 and .=':'])) 51 not($r[@nr=10 and .=':']))
52 then e:single($t) 52 then e:single($t,false())
53 else (), 53 else (),
54 $ranges := for $i in (1 to count($tokens)) return 54 $ranges := for $i in (1 to count($tokens)) return
55 let $t := $tokens[$i] return 55 let $t := $tokens[$i] return
56 if ($t[@nr=10 and .=':' and 56 if ($t[@nr=10 and .=':' and
57 not($i gt 2 and 57 not($i gt 2 and
58 $tokens[$i - 2][@nr=10 and .='!'])]) 58 $tokens[$i - 2][@nr=10 and .='!'])])
59 then let $l := $tokens[$i - 1], 59 then let $l := $tokens[$i - 1],
60 $r := $tokens[$i + 1] 60 $r := $tokens[$i + 1]
61 return e:range(e:single($l), 61 return e:range(e:single($l,false()),
62 e:single($r)) 62 e:single($r,false()))
63 else (), 63 else (),
64 $externals := for $i in (1 to count($tokens)) return 64 $externals := for $i in (1 to count($tokens)) return
65 let $t := $tokens[$i] return 65 let $t := $tokens[$i] return
66 if ($t/@nr=7) 66 if ($t/@nr=7)
67 then 67 then
68 let $ref := e:single($tokens[$i + 2]) return 68 let $ext := $t!='[0]',
69 if ((($i+3) le $n) and 69 $ref := e:single($tokens[$i + 2],
70 $tokens[$i + 3][@nr=10 and .=':']) 70 $ext),
71 then e:external($t,e:range($ref, 71 $res := if ((($i+3) le $n) and
72 e:single($tokens[$i+4]))) 72 $tokens[$i + 3][@nr=10 and .=':'])
73 else e:external($t,$ref) 73 then e:range($ref,
74 e:single($tokens[$i+4],
75 $ext))
76 else $ref return
77 if ($ext)
78 then e:external($t,$res)
79 else $res
74 else () 80 else ()
75 return [($singles,for $a in $recur return $a?1), 81 return [($singles,for $a in $recur return $a?1),
76 ($ranges,for $a in $recur return $a?2), 82 ($ranges,for $a in $recur return $a?2),
77 ($externals,for $a in $recur return $a?3)] 83 ($externals,for $a in $recur return $a?3)]
78 else ()"/> 84 else ()"/>
79 </xsl:function> 85 </xsl:function>
80 86
81 <xsl:function name="e:single" as="element(e:s)"> 87 <xsl:function name="e:single" as="element(*)">
82 <xsl:param name="group" as="element(xf:group)" required="yes"/> 88 <xsl:param name="group" as="element(xf:group)"/>
89 <xsl:param name="external" as="xs:boolean"/>
83 <xsl:variable name="val" select="if ($group/@nr=9) then e:lookup($group) 90 <xsl:variable name="val" select="if ($group/@nr=9) then e:lookup($group)
84 else string($group)"/> 91 else string($group)"/>
85 <s><xsl:value-of select="$val"/></s> 92 <xsl:choose>
93 <xsl:when test="count($val)>0 or not($external)">
94 <s><xsl:value-of select="$val"/></s>
95 </xsl:when>
96 <xsl:otherwise>
97 <v><xsl:value-of select="$group"/></v>
98 </xsl:otherwise>
99 </xsl:choose>
100
86 </xsl:function> 101 </xsl:function>
87 102
88 <xsl:function name="e:range" as="element(e:r)"> 103 <xsl:function name="e:range" as="element(e:r)">
89 <xsl:param name="l" as="element(e:s)" required="yes"/> 104 <xsl:param name="l" as="element(e:s)" required="yes"/>
90 <xsl:param name="r" as="element(e:s)" required="yes"/> 105 <xsl:param name="r" as="element(e:s)" required="yes"/>