fabulator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +41 -0
  3. data/README.rdoc +61 -0
  4. data/Rakefile +54 -0
  5. data/lib/fabulator.rb +5 -0
  6. data/lib/fabulator/action.rb +46 -0
  7. data/lib/fabulator/action_lib.rb +438 -0
  8. data/lib/fabulator/context.rb +39 -0
  9. data/lib/fabulator/core.rb +8 -0
  10. data/lib/fabulator/core/actions.rb +514 -0
  11. data/lib/fabulator/core/actions/choose.rb +167 -0
  12. data/lib/fabulator/core/actions/for_each.rb +105 -0
  13. data/lib/fabulator/core/actions/variables.rb +52 -0
  14. data/lib/fabulator/core/constraint.rb +117 -0
  15. data/lib/fabulator/core/filter.rb +41 -0
  16. data/lib/fabulator/core/group.rb +123 -0
  17. data/lib/fabulator/core/parameter.rb +128 -0
  18. data/lib/fabulator/core/state.rb +91 -0
  19. data/lib/fabulator/core/state_machine.rb +153 -0
  20. data/lib/fabulator/core/transition.rb +164 -0
  21. data/lib/fabulator/expr.rb +37 -0
  22. data/lib/fabulator/expr/axis.rb +133 -0
  23. data/lib/fabulator/expr/axis_descendent_or_self.rb +26 -0
  24. data/lib/fabulator/expr/bin_expr.rb +178 -0
  25. data/lib/fabulator/expr/context.rb +368 -0
  26. data/lib/fabulator/expr/for_expr.rb +74 -0
  27. data/lib/fabulator/expr/function.rb +52 -0
  28. data/lib/fabulator/expr/if_expr.rb +22 -0
  29. data/lib/fabulator/expr/let_expr.rb +17 -0
  30. data/lib/fabulator/expr/literal.rb +39 -0
  31. data/lib/fabulator/expr/node.rb +216 -0
  32. data/lib/fabulator/expr/node_logic.rb +99 -0
  33. data/lib/fabulator/expr/parser.rb +1470 -0
  34. data/lib/fabulator/expr/path_expr.rb +49 -0
  35. data/lib/fabulator/expr/predicates.rb +45 -0
  36. data/lib/fabulator/expr/statement_list.rb +96 -0
  37. data/lib/fabulator/expr/step.rb +43 -0
  38. data/lib/fabulator/expr/unary_expr.rb +30 -0
  39. data/lib/fabulator/expr/union_expr.rb +21 -0
  40. data/lib/fabulator/template.rb +9 -0
  41. data/lib/fabulator/template/context.rb +51 -0
  42. data/lib/fabulator/template/parse_result.rb +153 -0
  43. data/lib/fabulator/template/parser.rb +17 -0
  44. data/lib/fabulator/template/standard_tags.rb +95 -0
  45. data/lib/fabulator/template/taggable.rb +88 -0
  46. data/lib/fabulator/version.rb +14 -0
  47. data/test/test_fabulator.rb +17 -0
  48. data/test/test_helper.rb +24 -0
  49. data/xslt/form.xsl +2161 -0
  50. metadata +182 -0
@@ -0,0 +1,17 @@
1
+ module Fabulator::Template
2
+ class Parser
3
+ include Fabulator::Template::Taggable
4
+ include Fabulator::Template::StandardTags
5
+
6
+ def parse(context, text)
7
+ if !@context
8
+ @context = Context.new(self)
9
+ end
10
+ if !@parser
11
+ @parser = Radius::Parser.new(@context, :tag_prefix => 'r')
12
+ end
13
+ @context.globals.context = context
14
+ Fabulator::Template::ParseResult.new(@parser.parse(text))
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,95 @@
1
+ module Fabulator::Template
2
+ module StandardTags
3
+ include Fabulator::Template::Taggable
4
+
5
+ desc %{
6
+ Iterates through a set of data nodes.
7
+
8
+ *Usage:*
9
+
10
+ <pre><code><r:for-each select="./foo">...</r:for-each></code></pre>
11
+ }
12
+ tag 'for-each' do |tag|
13
+ selection = tag.attr['select']
14
+ c = tag.locals.context || tag.globals.context
15
+ # ns = get_fabulator_ns(tag)
16
+ items = c.nil? ? [] : c.eval_expression(selection, ns)
17
+ sort_by = tag.attr['sort']
18
+ sort_dir = tag.attr['order'] || 'asc'
19
+
20
+ if !sort_by.nil? && sort_by != ''
21
+ parser = Fabulator::Expr::Parser.new
22
+ sort_by_f = parser.parse(sort_by, ns)
23
+ items = items.sort_by { |i| i.eval_expression(sort_by, ns).first.value }
24
+ if sort_dir == 'desc'
25
+ items.reverse!
26
+ end
27
+ end
28
+ res = ''
29
+ #Rails.logger.info("Found #{items.size} items for for-each")
30
+ items.each do |i|
31
+ next if i.empty?
32
+ tag.locals.context = i
33
+ res = res + tag.expand
34
+ end
35
+ res
36
+ end
37
+
38
+ desc %{
39
+ Selects the value and returns it in HTML.
40
+ TODO: allow escaping of HTML special characters
41
+
42
+ *Usage:*
43
+
44
+ <pre><code><r:value select="./foo" /></code></pre>
45
+ }
46
+ tag 'value' do |tag|
47
+ selection = tag.attr['select']
48
+ c = tag.locals.context || tag.globals.context
49
+ items = c.nil? ? [] : c.eval_expression(selection, get_fabulator_ns(tag))
50
+ items.collect{|i| i.to([Fabulator::FAB_NS, 'html']).value }.join('')
51
+ end
52
+
53
+ desc %{
54
+ Chooses the first test which returns content. Otherwise,
55
+ uses the 'otherwise' tag.
56
+ }
57
+ tag 'choose' do |tag|
58
+ @chosen ||= [ ]
59
+ @chosen.unshift false
60
+ ret = tag.expand
61
+ @chosen.shift
62
+ ret
63
+ end
64
+
65
+ desc %{
66
+ Renders the enclosed content if the test passes.
67
+ }
68
+ tag 'choose:when' do |tag|
69
+ return '' if @chosen.first
70
+ selection = tag.attr['test']
71
+ c = tag.locals.context || tag.globals.context
72
+ items = c.nil? ? [] : c.eval_expression(selection)
73
+ if items.is_a?(Array)
74
+ if items.empty? || items.select { |v| !!v.value }.size == 0
75
+ return ''
76
+ else
77
+ @chosen[0] = true
78
+ return tag.expand
79
+ end
80
+ elsif items
81
+ @chosen[0] = true
82
+ return tag.expand
83
+ end
84
+ return ''
85
+ end
86
+
87
+ desc %{
88
+ Renders the enclosed content.
89
+ }
90
+ tag 'choose:otherwise' do |tag|
91
+ return '' if @chosen.first
92
+ tag.expand
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,88 @@
1
+ # based on the version from Radiant
2
+ require 'redcloth'
3
+
4
+ module Fabulator::Template::Taggable
5
+ def self.tag_descriptions
6
+ @@tag_descriptions
7
+ end
8
+
9
+ def self.last_description
10
+ @@last_description
11
+ end
12
+
13
+ def self.last_description=(l)
14
+ @@last_description = l
15
+ end
16
+
17
+ @@tag_descriptions = {}
18
+
19
+ def self.included(base)
20
+ base.extend(ClassMethods)
21
+ base.module_eval do
22
+ def self.included(new_base)
23
+ super
24
+ new_base.tag_descriptions.merge! self.tag_descriptions
25
+ end
26
+ end
27
+ end
28
+
29
+ def render_tag(name, tag_binding)
30
+ send "tag:#{name}", tag_binding
31
+ end
32
+
33
+ def tags
34
+ Util.tags_in_array(methods)
35
+ end
36
+
37
+ def tag_descriptions(hash=nil)
38
+ self.class.tag_descriptions hash
39
+ end
40
+
41
+ module ClassMethods
42
+ def inherited(subclass)
43
+ subclass.tag_descriptions.reverse_merge! self.tag_descriptions
44
+ super
45
+ end
46
+
47
+ def tag_descriptions(hash = nil)
48
+ Fabulator::Template::Taggable.tag_descriptions[self.name] ||= (hash ||{})
49
+ end
50
+
51
+ def desc(text)
52
+ Fabulator::Template::Taggable.last_description = RedCloth.new(Util.strip_leading_whitespace(text)).to_html
53
+ end
54
+
55
+ def tag(name, &block)
56
+ self.tag_descriptions[name] = Fabulator::Template::Taggable.last_description if Fabulator::Template::Taggable.last_description
57
+ Fabulator::Template::Taggable.last_description = nil
58
+ define_method("tag:#{name}", &block)
59
+ end
60
+
61
+ def tags
62
+ Util.tags_in_array(self.instance_methods)
63
+ end
64
+
65
+ end
66
+
67
+ module Util
68
+ def self.tags_in_array(array)
69
+ array.grep(/^tag:/).map { |name| name[4..-1] }.sort
70
+ end
71
+
72
+ def self.strip_leading_whitespace(text)
73
+ text = text.dup
74
+ text.gsub!("\t", " ")
75
+ lines = text.split("\n")
76
+ leading = lines.map do |line|
77
+ unless line =~ /^\s*$/
78
+ line.match(/^(\s*)/)[0].length
79
+ else
80
+ nil
81
+ end
82
+ end.compact.min
83
+ lines.inject([]) {|ary, line| ary << line.sub(/^[ ]{#{leading}}/, "")}.join("\n")
84
+ end
85
+
86
+ end
87
+
88
+ end
@@ -0,0 +1,14 @@
1
+ module Fabulator
2
+ module VERSION
3
+ unless defined? MAJOR
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ TINY = 1
7
+ PRE = nil
8
+
9
+ STRING = [MAJOR,MINOR,TINY].compact.join('.') + (PRE.nil? ? '' : PRE)
10
+
11
+ SUMMARY = "fabulator #{STRING}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require 'fabulator'
3
+
4
+ class TestFabulator < Test::Unit::TestCase
5
+
6
+ def setup
7
+ end
8
+
9
+ test 'compile trivial application' do
10
+ doc = LibXML::XML::Document.string('<f:application xmlns:f="http://dh.tamu.edu/ns/fabulator/1.0#" />')
11
+ sm = Fabulator::Core::StateMachine.new.compile_xml(doc)
12
+ assert_equal sm.states.keys.size, 1, "No states defined automatically"
13
+ assert_equal sm.states.keys.first, 'start', "Default state is not 'start'"
14
+ start = sm.states.values.first
15
+ assert_equal start.name, "start", "Default state object doesn't know itself as 'start'"
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require 'xml/libxml'
4
+ #require 'fabulator'
5
+
6
+ # already required by Rakefile
7
+ #require File.dirname(__FILE__) + '/../lib/fabulator'
8
+
9
+ class Test::Unit::TestCase
10
+
11
+ def self.test(name, &block)
12
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
13
+ defined = instance_method(test_name) rescue false
14
+ raise "#{test_name} is already defined in #{self}" if defined
15
+ if block_given?
16
+ define_method(test_name, &block)
17
+ else
18
+ define_method(test_name) do
19
+ flunk "No implementation provided for #{name}"
20
+ end
21
+ end
22
+ end
23
+
24
+ end
data/xslt/form.xsl ADDED
@@ -0,0 +1,2161 @@
1
+ <?xml version="1.0" ?>
2
+
3
+ <xsl:stylesheet
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
+ version="1.0"
6
+ >
7
+
8
+ <xsl:output
9
+ method="html"
10
+ indent="yes"
11
+ />
12
+ <!--
13
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
14
+ doctype-system="DTD/xhtml1-strict.dtd"
15
+ / -->
16
+
17
+ <xsl:variable name="admon.graphics" select="0"/>
18
+ <xsl:variable name="admon.style" select="''"/>
19
+ <xsl:variable name="admon.textlabel" select="0"/>
20
+
21
+ <xsl:template match="/">
22
+ <xsl:apply-templates select="view|error"/>
23
+ </xsl:template>
24
+
25
+ <xsl:template match="/view">
26
+ <xsl:choose>
27
+ <xsl:when test="count(//container[@id and not(ancestor::container[@id] | ancestor::form)] | //form[not(ancestor::container[@id] | ancestor::form)]) > 1">
28
+ <form>
29
+ <xsl:attribute name="method">
30
+ <xsl:choose>
31
+ <xsl:when test="@method = 'POST'">POST</xsl:when>
32
+ <xsl:when test=".//asset">POST</xsl:when>
33
+ <xsl:when test=".//textbox">POST</xsl:when>
34
+ <xsl:when test=".//editbox">POST</xsl:when>
35
+ <xsl:otherwise>POST</xsl:otherwise>
36
+ </xsl:choose>
37
+ </xsl:attribute>
38
+ <xsl:if test=".//asset">
39
+ <xsl:attribute name="type">application/x-multipart</xsl:attribute>
40
+ </xsl:if>
41
+ <xsl:call-template name="view-body"/>
42
+ </form>
43
+ </xsl:when>
44
+ <xsl:otherwise>
45
+ <xsl:call-template name="view-body"/>
46
+ </xsl:otherwise>
47
+ </xsl:choose>
48
+ </xsl:template>
49
+
50
+ <xsl:template name="view-body">
51
+ <div class="fabulator-content">
52
+ <xsl:apply-templates select="*"/>
53
+ </div>
54
+ </xsl:template>
55
+
56
+ <xsl:template match="container">
57
+ <xsl:choose>
58
+ <xsl:when test="@id and count(//container[@id and not(ancestor::container[@id] | ancestor::form)] | //form[not(ancestor::container[@id] | ancestor::form)]) > 1">
59
+ <xsl:call-template name="container"/>
60
+ </xsl:when>
61
+ <xsl:otherwise>
62
+ <form>
63
+ <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute></xsl:if>
64
+ <xsl:attribute name="method">
65
+ <xsl:choose>
66
+ <xsl:when test="@method = 'POST'">POST</xsl:when>
67
+ <xsl:when test=".//asset">POST</xsl:when>
68
+ <xsl:when test=".//textbox">POST</xsl:when>
69
+ <xsl:when test=".//editbox">POST</xsl:when>
70
+ <xsl:otherwise>POST</xsl:otherwise>
71
+ </xsl:choose>
72
+ </xsl:attribute>
73
+ <xsl:if test=".//asset">
74
+ <xsl:attribute name="type">application/x-multipart</xsl:attribute>
75
+ </xsl:if>
76
+ <xsl:call-template name="container"/>
77
+ </form>
78
+ </xsl:otherwise>
79
+ </xsl:choose>
80
+ </xsl:template>
81
+
82
+ <xsl:template name="container">
83
+ <!-- allowed to have rows="" and cols="" -->
84
+ <div class="container">
85
+ <xsl:if test="not(@id = '_embedded')">
86
+ <div class="container-title">
87
+ <xsl:value-of select=".//title"/>
88
+ </div>
89
+ </xsl:if>
90
+ <xsl:if test="navigation[@type='main']">
91
+ <div class="container-main-navigation">
92
+ <xsl:apply-templates select="navigation[@type='main']"/>
93
+ </div>
94
+ </xsl:if>
95
+ <xsl:for-each select="navigation[@type='sub']">
96
+ <div class="container-sub-navigation">
97
+ <!--
98
+ <td width="95%" valign="top" bgcolor="#3f3f7f" colspan="2" class="container-sub-navigation">
99
+ -->
100
+ <xsl:apply-templates/>
101
+ </div>
102
+ </xsl:for-each>
103
+ <xsl:for-each select="head"> <!-- class="container-head"> -->
104
+ <div class="container-head">
105
+ <xsl:apply-templates/>
106
+ </div>
107
+ </xsl:for-each>
108
+ <div class="container-content">
109
+ <xsl:apply-templates select="content"/>
110
+ </div>
111
+ <xsl:for-each select="foot">
112
+ <div class="container-foot">
113
+ <xsl:apply-templates/>
114
+ </div>
115
+ </xsl:for-each>
116
+ </div>
117
+ </xsl:template>
118
+
119
+ <!--
120
+ ** Misc. structure elements
121
+ -->
122
+
123
+ <xsl:template match="content">
124
+ <xsl:if test="not(.//container)">
125
+ <xsl:if test=".//section">
126
+ <a name="toc">
127
+ <xsl:apply-templates select=".//section" mode="toc"/>
128
+ </a>
129
+ </xsl:if>
130
+ </xsl:if>
131
+ <xsl:apply-templates/>
132
+ <xsl:if test=".//footnote">
133
+ <h2 class="section">Endnotes</h2>
134
+ <xsl:apply-templates select=".//footnote" mode="endnotes"/>
135
+ </xsl:if>
136
+ </xsl:template>
137
+ <xsl:template match="content//error//title"/>
138
+
139
+
140
+ <xsl:template match="containers">
141
+ <!-- need to figure out how to stream -->
142
+ <!-- stream="horizontal|vertical"
143
+ cols="number of columns" -->
144
+ <xsl:choose>
145
+ <xsl:when test="0 and @cols > 1">
146
+ <xsl:variable name="cols_available"><xsl:value-of select="@cols"/></xsl:variable>
147
+ <table>
148
+ <tr>
149
+ <xsl:choose>
150
+ <xsl:when test="@stream = 'vertical'">
151
+ </xsl:when>
152
+ <xsl:otherwise> <!-- horizontal -->
153
+ <xsl:for-each select="container">
154
+ <!-- need to have a tmp var holding current cols
155
+ when we are going to exceed it, emit </tr><tr>
156
+ -->
157
+ <xsl:variable name="cur_pos"><xsl:value-of select="position()"/></xsl:variable>
158
+ <xsl:variable name="prev_cols"><xsl:value-of select="../container[$cur_pos - 1]/@cols"/></xsl:variable>
159
+ <xsl:variable name="full_width"><xsl:value-of select="sum(../container[$cur_pos >= position()]/@cols)"/></xsl:variable>
160
+ <xsl:variable name="last_cols_width"><xsl:value-of select="sum(../container[$cur_pos >= position() and position() > $cur_pos - $cols_available]/@cols)"/></xsl:variable>
161
+ <xsl:if test="position() > 1">
162
+ <xsl:choose>
163
+ <xsl:when test="@cols + $prev_cols >= $cols_available and $cols_available > $prev_cols">
164
+ <![CDATA[</tr><tr>]]>
165
+ </xsl:when>
166
+ <!--
167
+ <xsl:when test="(($full_width - @cols) mod $cols_available) > ($full_width mod $cols_available)">
168
+ <![CDATA[</tr><tr>]]>
169
+ </xsl:when>
170
+ -->
171
+ </xsl:choose>
172
+ </xsl:if>
173
+ <td valign="top">
174
+ <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
175
+ <xsl:call-template name="container"/>
176
+ </td>
177
+ <!-- we need better logic than this... maybe -->
178
+ <xsl:if test="last() > position()">
179
+ <xsl:choose>
180
+ <xsl:when test="@cols >= $cols_available">
181
+ <![CDATA[</tr><tr>]]>
182
+ </xsl:when>
183
+ <!-- -->
184
+ <xsl:when test="(($full_width - @cols) mod $cols_available) > ($full_width mod $cols_available)">
185
+ <![CDATA[</tr><tr>]]>
186
+ </xsl:when>
187
+ <!-- -->
188
+ </xsl:choose>
189
+ </xsl:if>
190
+ </xsl:for-each>
191
+ </xsl:otherwise>
192
+ </xsl:choose>
193
+ </tr>
194
+ </table>
195
+ </xsl:when>
196
+
197
+ <xsl:otherwise> <!-- simple stream them out without an enclosing table -->
198
+ <xsl:apply-templates/>
199
+ </xsl:otherwise>
200
+ </xsl:choose>
201
+ </xsl:template>
202
+
203
+ <!-- doc elements -->
204
+
205
+ <xsl:template match="abbrev">
206
+ <xsl:apply-templates/>
207
+ </xsl:template>
208
+
209
+ <xsl:template match="abstract">
210
+ <div class="abstract">
211
+ <xsl:apply-templates/>
212
+ </div>
213
+ </xsl:template>
214
+
215
+ <xsl:template match="accel">
216
+ <span style="text-decoration: underline"><xsl:apply-templates/></span>
217
+ </xsl:template>
218
+
219
+ <xsl:template match="akno">
220
+ <div class="akno">
221
+ <xsl:apply-templates/>
222
+ </div>
223
+ </xsl:template>
224
+
225
+ <xsl:template match="acronym">
226
+ <xsl:apply-templates/>
227
+ </xsl:template>
228
+
229
+ <xsl:template match="action">
230
+ <span class="action">
231
+ <xsl:apply-templates/>
232
+ </span>
233
+ </xsl:template>
234
+
235
+ <xsl:template match="address">
236
+ <div class="address">
237
+ <xsl:apply-templates/>
238
+ </div>
239
+ </xsl:template>
240
+
241
+ <xsl:template match="affiliation">
242
+ <xsl:apply-templates/>
243
+ </xsl:template>
244
+
245
+ <xsl:template match="authorblurb">
246
+ <xsl:apply-templates/>
247
+ </xsl:template>
248
+
249
+ <xsl:template match="blockquote">
250
+ <blockquote><xsl:apply-templates/></blockquote>
251
+ </xsl:template>
252
+
253
+ <xsl:template match="city">
254
+ <xsl:apply-templates/>
255
+ </xsl:template>
256
+
257
+ <xsl:template match="contrib">
258
+ <xsl:apply-templates/>
259
+ </xsl:template>
260
+
261
+ <xsl:template match="country">
262
+ <xsl:apply-templates/>
263
+ </xsl:template>
264
+
265
+ <xsl:template match="email">
266
+ <a><xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute>&lt;<xsl:value-of select="."/>&gt;</a>
267
+ </xsl:template>
268
+
269
+ <xsl:template match="emphasis">
270
+ <em class="emphasis">
271
+ <xsl:apply-templates/>
272
+ </em>
273
+ </xsl:template>
274
+
275
+ <xsl:template match="emphasis/emphasis">
276
+ <span style="font-style: normal">
277
+ <xsl:apply-templates/>
278
+ </span>
279
+ </xsl:template>
280
+
281
+ <xsl:template match="fax">
282
+ <xsl:apply-templates/>
283
+ </xsl:template>
284
+
285
+ <xsl:template match="figure">
286
+ <xsl:variable name="place">
287
+ <xsl:choose>
288
+ <xsl:when test="count(preceding::figure) mod 2 = 0">left</xsl:when>
289
+ <xsl:otherwise>right</xsl:otherwise>
290
+ </xsl:choose>
291
+ </xsl:variable>
292
+ <div class="figure-{$place}">
293
+ <xsl:apply-templates/>
294
+ <xsl:apply-templates select="caption" mode="caption"/>
295
+ </div>
296
+ </xsl:template>
297
+
298
+ <xsl:template match="figure/caption"/>
299
+
300
+ <xsl:template match="figure/caption" mode="caption">
301
+ <p class="figure-caption">
302
+ <span style="font-weight: bolder">Figure <xsl:value-of select="1 + count(preceding::figure)"/>. </span>
303
+ <xsl:apply-templates/>
304
+ </p>
305
+ </xsl:template>
306
+
307
+ <xsl:template match="firstname">
308
+ <xsl:apply-templates/>
309
+ </xsl:template>
310
+
311
+ <xsl:template match="formalpara">
312
+ <p>
313
+ <xsl:apply-templates/>
314
+ </p>
315
+ </xsl:template>
316
+
317
+ <xsl:template match="formalpara/title">
318
+ <span style="font-weight: bolder"><xsl:apply-templates/>.</span>
319
+ </xsl:template>
320
+
321
+ <xsl:template match="formalpara/para">
322
+ <xsl:apply-templates/>
323
+ </xsl:template>
324
+
325
+ <!-- theme based iconic element -->
326
+ <xsl:template match="icon">
327
+ <img border="0">
328
+ <xsl:attribute name="src">
329
+ <xsl:value-of select="concat('/images/', /view/@theme, '/icons/', @name)"/>
330
+ </xsl:attribute>
331
+ <xsl:if test="caption">
332
+ <xsl:attribute name="alt">
333
+ <xsl:value-of select="caption"/>
334
+ </xsl:attribute>
335
+ </xsl:if>
336
+ </img>
337
+ </xsl:template>
338
+
339
+ <!-- need theme based window dressing -->
340
+
341
+ <xsl:template match="graphic">
342
+ <img border="0">
343
+ <xsl:attribute name="src">
344
+ <xsl:value-of select="@fileref"/>
345
+ </xsl:attribute>
346
+ <xsl:if test="caption">
347
+ <xsl:attribute name="alt">
348
+ <xsl:value-of select="caption"/>
349
+ </xsl:attribute>
350
+ </xsl:if>
351
+ </img>
352
+ </xsl:template>
353
+
354
+ <xsl:template match="honorific">
355
+ <xsl:apply-templates/>
356
+ </xsl:template>
357
+
358
+ <xsl:template name="admon.graphic.width">
359
+ <xsl:param name="node" select="."/>
360
+ <xsl:text>25</xsl:text>
361
+ </xsl:template>
362
+
363
+ <xsl:template match="note|important|warning|caution|tip">
364
+ <xsl:choose>
365
+ <xsl:when test="$admon.graphics != 0">
366
+ <xsl:call-template name="graphical.admonition"/>
367
+ </xsl:when>
368
+ <xsl:otherwise>
369
+ <xsl:call-template name="nongraphical.admonition"/>
370
+ </xsl:otherwise>
371
+ </xsl:choose>
372
+ </xsl:template>
373
+
374
+ <xsl:template name="admon.graphic">
375
+ <xsl:param name="node" select="."/>
376
+ <xsl:value-of select="$admon.graphics.path"/>
377
+ <xsl:choose>
378
+ <xsl:when test="local-name($node)='note'">note</xsl:when>
379
+ <xsl:when test="local-name($node)='warning'">warning</xsl:when>
380
+ <xsl:when test="local-name($node)='caution'">caution</xsl:when>
381
+ <xsl:when test="local-name($node)='tip'">tip</xsl:when>
382
+ <xsl:when test="local-name($node)='important'">important</xsl:when>
383
+ <xsl:otherwise>note</xsl:otherwise>
384
+ </xsl:choose>
385
+ <xsl:value-of select="$admon.graphics.extension"/>
386
+ </xsl:template>
387
+
388
+ <xsl:template name="graphical.admonition">
389
+ <xsl:variable name="admon.type">
390
+ <xsl:choose>
391
+ <xsl:when test="local-name(.)='note'">Note</xsl:when>
392
+ <xsl:when test="local-name(.)='warning'">Warning</xsl:when>
393
+ <xsl:when test="local-name(.)='caution'">Caution</xsl:when>
394
+ <xsl:when test="local-name(.)='tip'">Tip</xsl:when>
395
+ <xsl:when test="local-name(.)='important'">Important</xsl:when>
396
+ <xsl:otherwise>Note</xsl:otherwise>
397
+ </xsl:choose>
398
+ </xsl:variable>
399
+
400
+ <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
401
+ <xsl:if test="$admon.style != ''">
402
+ <xsl:attribute name="style">
403
+ <xsl:value-of select="$admon.style"/>
404
+ </xsl:attribute>
405
+ </xsl:if>
406
+
407
+ <table border="0">
408
+ <xsl:attribute name="summary">
409
+ <xsl:value-of select="$admon.type"/>
410
+ <xsl:if test="title">
411
+ <xsl:text>: </xsl:text>
412
+ <xsl:value-of select="title"/>
413
+ </xsl:if>
414
+ </xsl:attribute>
415
+ <tr>
416
+ <td rowspan="2" align="center" valign="top">
417
+ <xsl:attribute name="width">
418
+ <xsl:call-template name="admon.graphic.width"/>
419
+ </xsl:attribute>
420
+ <img alt="[{$admon.type}]">
421
+ <xsl:attribute name="src">
422
+ <xsl:call-template name="admon.graphic"/>
423
+ </xsl:attribute>
424
+ </img>
425
+ </td>
426
+ <th align="left">
427
+ <xsl:call-template name="anchor"/>
428
+ <!-- xsl:if test="$admon.textlabel != 0 or title" -->
429
+ <xsl:apply-templates select="title" mode="object.title.markup"/>
430
+ <!-- /xsl:if -->
431
+ </th>
432
+ </tr>
433
+ <tr>
434
+ <td colspan="2" align="left" valign="top">
435
+ <xsl:apply-templates/>
436
+ </td>
437
+ </tr>
438
+ </table>
439
+ </div>
440
+ </xsl:template>
441
+
442
+ <xsl:template name="nongraphical.admonition">
443
+ <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
444
+ <xsl:if test="$admon.style">
445
+ <xsl:attribute name="style">
446
+ <xsl:value-of select="$admon.style"/>
447
+ </xsl:attribute>
448
+ </xsl:if>
449
+
450
+ <h3 class="title">
451
+ <!-- xsl:call-template name="anchor"/ -->
452
+ <!-- xsl:if test="$admon.textlabel != 0 or title" -->
453
+ <xsl:apply-templates select="title" mode="object.title.markup"/>
454
+ <!-- /xsl:if -->
455
+ </h3>
456
+
457
+ <xsl:apply-templates/>
458
+ </div>
459
+ </xsl:template>
460
+
461
+ <xsl:template match="note/title"/>
462
+ <xsl:template match="important/title"/>
463
+ <xsl:template match="warning/title"/>
464
+ <xsl:template match="caution/title"/>
465
+ <xsl:template match="tip/title"/>
466
+
467
+
468
+ <xsl:template match="itemizedlist">
469
+ <ul>
470
+ <xsl:apply-templates select="listitem"/>
471
+ </ul>
472
+ </xsl:template>
473
+
474
+ <xsl:template match="lineage">
475
+ <xsl:apply-templates/>
476
+ </xsl:template>
477
+
478
+ <xsl:template match="link">
479
+ <a>
480
+ <xsl:attribute name="href"><xsl:call-template name="format-url"><xsl:with-param name="url"><xsl:value-of select="@url"/></xsl:with-param></xsl:call-template></xsl:attribute>
481
+ <xsl:apply-templates/>
482
+ </a>
483
+ </xsl:template>
484
+
485
+ <xsl:template match="listitem">
486
+ <li>
487
+ <xsl:apply-templates/>
488
+ </li>
489
+ </xsl:template>
490
+
491
+ <xsl:template match="newline">
492
+ <br />
493
+ </xsl:template>
494
+
495
+ <xsl:template match="orderedlist">
496
+ <ol>
497
+ <xsl:apply-templates select="listitem"/>
498
+ </ol>
499
+ </xsl:template>
500
+
501
+ <xsl:template match="otheraddr">
502
+ <xsl:apply-templates/>
503
+ </xsl:template>
504
+
505
+ <xsl:template match="othername">
506
+ <xsl:apply-templates/>
507
+ </xsl:template>
508
+
509
+ <xsl:template match="para">
510
+ <p><xsl:apply-templates/></p>
511
+ </xsl:template>
512
+
513
+ <xsl:template match="phone">
514
+ <xsl:apply-templates/>
515
+ </xsl:template>
516
+
517
+ <xsl:template match="pob">
518
+ <xsl:apply-templates/>
519
+ </xsl:template>
520
+
521
+ <xsl:template match="postcode">
522
+ <xsl:apply-templates/>
523
+ </xsl:template>
524
+
525
+ <xsl:template match="quote">
526
+ ``<xsl:apply-templates/>''
527
+ </xsl:template>
528
+
529
+ <xsl:template match="quote//quote">
530
+ `<xsl:apply-templates/>'
531
+ </xsl:template>
532
+
533
+ <xsl:template match="quote//quote//quote">
534
+ ``<xsl:apply-templates/>''
535
+ </xsl:template>
536
+
537
+ <xsl:template match="quote//quote//quote//quote">
538
+ `<xsl:apply-templates/>'
539
+ </xsl:template>
540
+
541
+ <xsl:template match="screen">
542
+ <pre style="white-space: pre; font-weight: bolder; font-family: monospace;">
543
+ <xsl:apply-templates/>
544
+ </pre>
545
+ </xsl:template>
546
+
547
+ <xsl:template match="state">
548
+ <xsl:apply-templates/>
549
+ </xsl:template>
550
+
551
+ <xsl:template match="street">
552
+ <xsl:apply-templates/>
553
+ </xsl:template>
554
+
555
+ <xsl:template match="surname">
556
+ <xsl:apply-templates/>
557
+ </xsl:template>
558
+
559
+ <xsl:template match="table">
560
+ <div class="table">
561
+ <xsl:apply-templates/>
562
+ <xsl:apply-templates select="title" mode="caption"/>
563
+ </div>
564
+ </xsl:template>
565
+
566
+ <xsl:template match="table/title"/>
567
+
568
+ <xsl:template match="table/title" mode="caption">
569
+ <xsl:variable name="num">
570
+ <xsl:value-of select="1 + count(preceding::table)"/>
571
+ </xsl:variable>
572
+ <p class="table-caption">
573
+ <span style="font-weight: bolder">Table <xsl:value-of select="$num"/>. </span>
574
+ <xsl:apply-templates/>
575
+ </p>
576
+ </xsl:template>
577
+
578
+ <xsl:template match="tgroup">
579
+ <table cellpadding="1" cellspacing="1">
580
+ <xsl:apply-templates select="thead"/>
581
+ <xsl:apply-templates select="row"/>
582
+ </table>
583
+ </xsl:template>
584
+
585
+ <xsl:template match="thead">
586
+ <tr cellpadding="1" style="border: solid black 1px;">
587
+ <xsl:apply-templates select="column"/>
588
+ </tr>
589
+ </xsl:template>
590
+
591
+ <xsl:template match="row">
592
+ <tr>
593
+ <xsl:if test="@class">
594
+ <xsl:attribute name="class"><xsl:text>row-</xsl:text><xsl:value-of select="@class"/></xsl:attribute>
595
+ </xsl:if>
596
+ <xsl:apply-templates select="column"/>
597
+ </tr>
598
+ </xsl:template>
599
+
600
+ <xsl:template match="column">
601
+ <td>
602
+ <xsl:if test="@class">
603
+ <xsl:attribute name="class"><xsl:text>row-</xsl:text><xsl:value-of select="@class"/></xsl:attribute>
604
+ </xsl:if>
605
+ <xsl:apply-templates/>
606
+ </td>
607
+ </xsl:template>
608
+
609
+ <xsl:template match="variable">
610
+ <em><xsl:apply-templates/></em>
611
+ </xsl:template>
612
+
613
+ <xsl:template match="variablelist">
614
+ <dl class="variablelist">
615
+ <xsl:if test="@style = 'compact'">
616
+ <xsl:attribute name="compact"/>
617
+ </xsl:if>
618
+ <xsl:apply-templates select="varlistentry"/>
619
+ </dl>
620
+ </xsl:template>
621
+
622
+ <xsl:template match="varlistentry">
623
+ <dt>
624
+ <xsl:for-each select="term">
625
+ <xsl:apply-templates select="."/>
626
+ <xsl:if test="position() != last()">
627
+ <xsl:text>, </xsl:text>
628
+ </xsl:if>
629
+ </xsl:for-each>
630
+ </dt>
631
+ <xsl:apply-templates select="listitem"/>
632
+ </xsl:template>
633
+
634
+ <xsl:template match="varlistentry/listitem">
635
+ <dd><xsl:apply-templates/></dd>
636
+ </xsl:template>
637
+
638
+ <xsl:template match="footnote">
639
+ <xsl:variable name="num">
640
+ <xsl:value-of select="1 + count(preceding::footnote)"/>
641
+ </xsl:variable>
642
+ <a name="fnref{$num}">
643
+ <a href="#fn{$num}">
644
+ <xsl:text>[</xsl:text>
645
+ <xsl:value-of select="$num"/>
646
+ <xsl:text>]</xsl:text>
647
+ </a>
648
+ </a>
649
+ </xsl:template>
650
+
651
+ <xsl:template match="footnote" mode="endnotes">
652
+ <p class="endnote">
653
+ <xsl:variable name="num">
654
+ <xsl:value-of select="1 + count(preceding::footnote)"/>
655
+ </xsl:variable>
656
+ <a name="fn{$num}">
657
+ <a href="#fnref{$num}">
658
+ <xsl:text>[</xsl:text>
659
+ <xsl:value-of select="$num"/>
660
+ <xsl:text>]</xsl:text>
661
+ </a>
662
+ </a>
663
+ <xsl:apply-templates/>
664
+ </p>
665
+ </xsl:template>
666
+
667
+ <xsl:template match="bibliography|section">
668
+ <xsl:apply-templates/>
669
+ </xsl:template>
670
+
671
+ <xsl:template match="bibliography/title|section/title">
672
+ <xsl:variable name="myid">
673
+ <xsl:value-of select="generate-id()"/>
674
+ </xsl:variable>
675
+ <a name="{$myid}">
676
+ <a href="#toc">
677
+ <xsl:variable name="level">
678
+ <xsl:value-of select="concat('h', 1 + count(ancestor::section|ancestor::bibliography))"/>
679
+ </xsl:variable>
680
+ <xsl:element name="{$level}">
681
+ <xsl:attribute name="class">section</xsl:attribute>
682
+ <xsl:apply-templates/>
683
+ </xsl:element>
684
+ </a>
685
+ </a>
686
+ </xsl:template>
687
+
688
+ <xsl:template match="bibliography/title|section/title" mode="toc">
689
+ <xsl:variable name="myid">
690
+ <xsl:value-of select="generate-id()"/>
691
+ </xsl:variable>
692
+ <a href="#{$myid}">
693
+ <xsl:variable name="level">
694
+ <xsl:value-of select="concat('h', 1 + count(ancestor::section|ancestor::bibliography))"/>
695
+ </xsl:variable>
696
+ <xsl:element name="{$level}">
697
+ <xsl:attribute name="class">toc</xsl:attribute>
698
+ <xsl:apply-templates/>
699
+ </xsl:element>
700
+ </a>
701
+ </xsl:template>
702
+
703
+ <xsl:template match="bibliography|section" mode="toc">
704
+ <a>
705
+ <xsl:apply-templates select="title" mode="toc"/>
706
+ </a>
707
+ </xsl:template>
708
+
709
+ <xsl:template match="biblioentry">
710
+ <p class="biblioentry">
711
+ <xsl:apply-templates/>
712
+ </p>
713
+ </xsl:template>
714
+
715
+
716
+ <!-- forms in the content -->
717
+
718
+ <xsl:template match="form" mode="body">
719
+ <xsl:param name="form_level"/>
720
+ <xsl:call-template name="form-body">
721
+ <xsl:with-param name="form_level" select="$form_level"/>
722
+ </xsl:call-template>
723
+ </xsl:template>
724
+
725
+ <xsl:template name="form-body">
726
+ <xsl:param name="form_level"/>
727
+ <xsl:choose>
728
+ <xsl:when test="ancestor::option">
729
+ <span class="sub-form">
730
+ <xsl:attribute name="relation">
731
+ <xsl:text>rel:</xsl:text><xsl:apply-templates select="ancestor::option[1]" mode="id"/>
732
+ </xsl:attribute>
733
+ <xsl:apply-templates select="text|textline|textbox|editbox|file|grid|password|selection|form|group|textreader|list">
734
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="@id"/></xsl:with-param -->
735
+ <xsl:with-param name="form_level"><value-of select="$form_level"/></xsl:with-param>
736
+ </xsl:apply-templates>
737
+ <xsl:if test="submit|reset">
738
+ <span class="form-buttons">
739
+ <xsl:apply-templates select="submit|reset">
740
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="@id"/></xsl:with-param -->
741
+ </xsl:apply-templates>
742
+ </span>
743
+ </xsl:if>
744
+ <xsl:apply-templates select="stored">
745
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="@id"/></xsl:with-param -->
746
+ </xsl:apply-templates>
747
+ </span>
748
+ </xsl:when>
749
+ <xsl:otherwise>
750
+ <xsl:apply-templates select="text|textline|textbox|editbox|file|grid|password|selection|form|group|textreader|list">
751
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="@id"/></xsl:with-param -->
752
+ <xsl:with-param name="form_level"><value-of select="$form_level"/></xsl:with-param>
753
+ </xsl:apply-templates>
754
+ <xsl:if test="submit|reset">
755
+ <span class="form-buttons">
756
+ <xsl:apply-templates select="submit|reset">
757
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="@id"/></xsl:with-param -->
758
+ </xsl:apply-templates>
759
+ </span>
760
+ </xsl:if>
761
+ <xsl:apply-templates select="stored">
762
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="@id"/></xsl:with-param -->
763
+ </xsl:apply-templates>
764
+ </xsl:otherwise>
765
+ </xsl:choose>
766
+ </xsl:template>
767
+
768
+ <xsl:template match="form">
769
+ <!-- <div align="center"> -->
770
+ <xsl:choose>
771
+ <xsl:when test="count(//container[@id and not(ancestor::container[@id] | ancestor::form)] | //form[not(ancestor::container[@id] | ancestor::form)]) > 1">
772
+ <xsl:if test="./caption">
773
+ <h2 class="form-caption">
774
+ <xsl:apply-templates select="caption"/>
775
+ </h2>
776
+ </xsl:if>
777
+ <span class="form-body">
778
+ <xsl:call-template name="form-body">
779
+ <xsl:with-param name="form_level">3</xsl:with-param>
780
+ </xsl:call-template>
781
+ </span>
782
+ </xsl:when>
783
+ <xsl:otherwise>
784
+ <form>
785
+ <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute></xsl:if>
786
+ <xsl:attribute name="method">
787
+ <xsl:choose>
788
+ <xsl:when test="@method = 'POST'">POST</xsl:when>
789
+ <xsl:when test=".//file">POST</xsl:when>
790
+ <xsl:when test=".//textbox">POST</xsl:when>
791
+ <xsl:when test=".//editbox">POST</xsl:when>
792
+ <xsl:otherwise>POST</xsl:otherwise>
793
+ </xsl:choose>
794
+ </xsl:attribute>
795
+ <xsl:if test=".//file">
796
+ <xsl:attribute name="type">application/x-multipart</xsl:attribute>
797
+ </xsl:if>
798
+ <xsl:if test="./caption">
799
+ <h2 class="form-caption">
800
+ <xsl:apply-templates select="caption"/>
801
+ </h2>
802
+ </xsl:if>
803
+ <span class="form-body">
804
+ <xsl:call-template name="form-body"/>
805
+ </span>
806
+ </form>
807
+ </xsl:otherwise>
808
+ </xsl:choose>
809
+ <!-- </div> -->
810
+ </xsl:template>
811
+
812
+ <xsl:template match="form//caption">
813
+ <span class="form-element-label">
814
+ <xsl:if test="../@required = 1">
815
+ <span class="form-entry-required-marker">*</span>
816
+ </xsl:if>
817
+ <xsl:choose>
818
+ <xsl:when test="../@missing = 1">
819
+ <span class="form-entry-missing"><xsl:apply-templates/></span>
820
+ </xsl:when>
821
+ <xsl:otherwise>
822
+ <xsl:apply-templates/>
823
+ </xsl:otherwise>
824
+ </xsl:choose>
825
+ </span>
826
+ </xsl:template>
827
+
828
+ <xsl:template match="form/list">
829
+ <xsl:param name="form_level"/>
830
+ <xsl:choose>
831
+ <xsl:when test="./caption|./help">
832
+ <fieldset>
833
+ <legend>
834
+ <xsl:attribute name="class">
835
+ <xsl:text>form-list-legend</xsl:text>
836
+ <xsl:value-of select="$form_level"/>
837
+ </xsl:attribute>
838
+ <xsl:apply-templates select="caption"/>
839
+ <xsl:apply-templates select="help"/>
840
+ </legend>
841
+ <xsl:call-template name="form-list">
842
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
843
+ </xsl:call-template>
844
+ </fieldset>
845
+ </xsl:when>
846
+ <xsl:otherwise>
847
+ <xsl:call-template name="form-list">
848
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
849
+ </xsl:call-template>
850
+ </xsl:otherwise>
851
+ </xsl:choose>
852
+ </xsl:template>
853
+
854
+ <xsl:template match="form/form | option/form | option/caption/form">
855
+ <!-- xsl:param name="form_id"/ -->
856
+ <xsl:param name="form_level"/>
857
+ <xsl:choose>
858
+ <xsl:when test="./caption|./help">
859
+ <fieldset>
860
+ <legend>
861
+ <xsl:attribute name="class">
862
+ <xsl:text>form-legend-</xsl:text>
863
+ <xsl:value-of select="$form_level"/>
864
+ </xsl:attribute>
865
+ <xsl:apply-templates select="caption"/>
866
+ <xsl:apply-templates select="help"/>
867
+ </legend>
868
+ <xsl:call-template name="form-body">
869
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
870
+ </xsl:call-template>
871
+ </fieldset>
872
+ </xsl:when>
873
+ <xsl:otherwise>
874
+ <xsl:call-template name="form-body">
875
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
876
+ </xsl:call-template>
877
+ </xsl:otherwise>
878
+ </xsl:choose>
879
+ </xsl:template>
880
+
881
+ <xsl:template match="form/group">
882
+ <!-- xsl:param name="form_id"/ -->
883
+ <xsl:param name="form_level"/>
884
+ <span class="form-group">
885
+ <span class="form-group-caption">
886
+ <xsl:apply-templates select="caption"/>
887
+ <xsl:apply-templates select="help"/>
888
+ </span>
889
+ <span class="form-group-elements">
890
+ <xsl:call-template name="form-body">
891
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
892
+ </xsl:call-template>
893
+ <!--
894
+ <xsl:apply-templates>
895
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
896
+ </xsl:apply-templates>
897
+ -->
898
+ </span>
899
+ </span>
900
+ </xsl:template>
901
+
902
+ <xsl:template match="form/password | form//group/password">
903
+ <!-- xsl:param name="form_id"/ -->
904
+ <span class="form-element">
905
+ <!-- label class="form-element-label">
906
+ <xsl:attribute name="for">
907
+ <xsl:apply-templates select="." mode="id"/>
908
+ </xsl:attribute -->
909
+ <xsl:apply-templates select="caption"/>
910
+ <xsl:apply-templates select="help"/>
911
+ <!-- /label -->
912
+ <xsl:call-template name="field-password"/>
913
+ </span>
914
+ </xsl:template>
915
+
916
+ <xsl:template match="form/textline">
917
+ <!-- xsl:param name="form_id"/ -->
918
+ <span class="form-element">
919
+ <!-- label class="form-element-label">
920
+ <xsl:attribute name="for">
921
+ <xsl:apply-templates select="." mode="id"/>
922
+ </xsl:attribute -->
923
+ <xsl:apply-templates select="caption"/>
924
+ <xsl:apply-templates select="help"/>
925
+ <!-- /label -->
926
+ <xsl:call-template name="field-textline"/>
927
+ </span>
928
+ </xsl:template>
929
+
930
+ <xsl:template match="form//group/textline">
931
+ <!-- xsl:param name="form_id"/ -->
932
+ <xsl:call-template name="field-textline">
933
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
934
+ </xsl:call-template>
935
+ </xsl:template>
936
+
937
+ <xsl:template match="form/textbox|form/editbox">
938
+ <!-- xsl:param name="form_id"/ -->
939
+ <xsl:choose>
940
+ <xsl:when test="caption">
941
+ <fieldset>
942
+ <legend>
943
+ <xsl:apply-templates select="caption"/>
944
+ <xsl:apply-templates select="help"/>
945
+ </legend>
946
+ <xsl:call-template name="field-textbox">
947
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
948
+ </xsl:call-template>
949
+ </fieldset>
950
+ </xsl:when>
951
+ <xsl:otherwise>
952
+ <span class="form-element">
953
+ <xsl:call-template name="field-textbox">
954
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
955
+ <xsl:with-param name="size">2</xsl:with-param>
956
+ </xsl:call-template>
957
+ </span>
958
+ </xsl:otherwise>
959
+ </xsl:choose>
960
+ </xsl:template>
961
+
962
+ <xsl:template match="form//group/textbox | form//group/editbox">
963
+ <!-- xsl:param name="form_id"/ -->
964
+ <xsl:call-template name="field-textbox">
965
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
966
+ </xsl:call-template>
967
+ </xsl:template>
968
+
969
+ <xsl:template match="form/textreader">
970
+ <!-- xsl:param name="form_id"/ -->
971
+ <xsl:choose>
972
+ <xsl:when test="caption">
973
+ <fieldset>
974
+ <legend>
975
+ <xsl:apply-templates select="caption"/>
976
+ <xsl:apply-templates select="help"/>
977
+ </legend>
978
+ <xsl:call-template name="field-textreader">
979
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
980
+ </xsl:call-template>
981
+ </fieldset>
982
+ </xsl:when>
983
+ <xsl:otherwise>
984
+ <span class="form-element">
985
+ <xsl:call-template name="field-textreader">
986
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
987
+ <xsl:with-param name="size">2</xsl:with-param>
988
+ </xsl:call-template>
989
+ </span>
990
+ </xsl:otherwise>
991
+ </xsl:choose>
992
+ </xsl:template>
993
+
994
+ <xsl:template match="form//group/textreader">
995
+ <!-- xsl:param name="form_id"/ -->
996
+ <xsl:call-template name="field-textreader">
997
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
998
+ </xsl:call-template>
999
+ </xsl:template>
1000
+
1001
+ <xsl:template match="form/selection">
1002
+ <!-- xsl:param name="form_id"/ -->
1003
+ <xsl:param name="form_level"/>
1004
+ <xsl:choose>
1005
+ <xsl:when test="./option//form//selection">
1006
+ <span class="form-element">
1007
+ <xsl:apply-templates select="caption"/>
1008
+ <xsl:apply-templates select="help"/>
1009
+ <xsl:call-template name="field-selection">
1010
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1011
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
1012
+ </xsl:call-template>
1013
+ </span>
1014
+ </xsl:when>
1015
+ <xsl:when test="./option//help|./option//form">
1016
+ <span class="form-element">
1017
+ <xsl:apply-templates select="caption"/>
1018
+ <xsl:apply-templates select="help"/>
1019
+ <xsl:call-template name="field-selection">
1020
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1021
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
1022
+ </xsl:call-template>
1023
+ </span>
1024
+ </xsl:when>
1025
+ <xsl:otherwise>
1026
+ <span class="form-element">
1027
+ <!-- label class="form-element-label">
1028
+ <xsl:attribute name="for">
1029
+ <xsl:apply-templates select="." mode="id"/>
1030
+ </xsl:attribute -->
1031
+ <xsl:apply-templates select="caption"/>
1032
+ <xsl:apply-templates select="help"/>
1033
+ <!-- /label -->
1034
+ <xsl:call-template name="field-selection">
1035
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
1036
+ </xsl:call-template>
1037
+ </span>
1038
+ </xsl:otherwise>
1039
+ </xsl:choose>
1040
+ </xsl:template>
1041
+
1042
+ <xsl:template match="form//group/selection">
1043
+ <!-- xsl:param name="form_id"/ -->
1044
+ <xsl:param name="form_level"/>
1045
+ <xsl:apply-templates select="caption"/>
1046
+ <xsl:apply-templates select="help"/>
1047
+ <xsl:call-template name="field-selection">
1048
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1049
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
1050
+ </xsl:call-template>
1051
+ </xsl:template>
1052
+
1053
+ <xsl:template match="form//grid">
1054
+ <xsl:call-template name="field-grid"/>
1055
+ </xsl:template>
1056
+
1057
+ <xsl:template match="form/selection/option|form//group/selection/option">
1058
+ <xsl:param name="style"/>
1059
+ <!-- xsl:param name="form_id"/ -->
1060
+ <xsl:param name="form_level"/>
1061
+ <xsl:choose>
1062
+ <xsl:when test="$style = 'radio'">
1063
+ <span class="form-selection-option">
1064
+ <input>
1065
+ <xsl:attribute name="type"><xsl:value-of select="$style"/></xsl:attribute>
1066
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/></xsl:attribute -->
1067
+ <xsl:attribute name="name"><xsl:apply-templates select="parent::selection[1]" mode="id"/></xsl:attribute>
1068
+ <xsl:attribute name="show">
1069
+ <xsl:choose>
1070
+ <xsl:when test=".//form">
1071
+ <xsl:text>rel:</xsl:text>
1072
+ <xsl:apply-templates select="." mode="id"/>
1073
+ </xsl:when>
1074
+ <xsl:otherwise>
1075
+ <xsl:text>none</xsl:text>
1076
+ </xsl:otherwise>
1077
+ </xsl:choose>
1078
+ </xsl:attribute>
1079
+ <xsl:variable name="myid">
1080
+ <xsl:choose>
1081
+ <xsl:when test="@id">
1082
+ <xsl:value-of select="@id"/>
1083
+ </xsl:when>
1084
+ <xsl:otherwise>
1085
+ <xsl:value-of select="."/>
1086
+ </xsl:otherwise>
1087
+ </xsl:choose>
1088
+ </xsl:variable>
1089
+ <xsl:attribute name="value"><xsl:value-of select="$myid"/></xsl:attribute>
1090
+ <xsl:for-each select="../default">
1091
+ <xsl:if test=". = $myid">
1092
+ <xsl:attribute name="checked"/>
1093
+ </xsl:if>
1094
+ </xsl:for-each>
1095
+ </input>
1096
+ <xsl:choose>
1097
+ <xsl:when test="caption">
1098
+ <xsl:choose>
1099
+ <xsl:when test="caption"><xsl:apply-templates select="caption"/></xsl:when>
1100
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1101
+ </xsl:choose>
1102
+ <xsl:apply-templates select="help"/>
1103
+ <xsl:if test="./form">
1104
+ <xsl:apply-templates select="form" mode="body">
1105
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:with-param -->
1106
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1107
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
1108
+ </xsl:apply-templates>
1109
+ </xsl:if>
1110
+ </xsl:when>
1111
+ <xsl:when test="form">
1112
+ <xsl:if test="form/caption">
1113
+ <xsl:apply-templates select="form/caption"/>
1114
+ <xsl:apply-templates select="form/help"/>
1115
+ </xsl:if>
1116
+ <xsl:apply-templates select="form" mode="body">
1117
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:with-param -->
1118
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1119
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
1120
+ </xsl:apply-templates>
1121
+ </xsl:when>
1122
+ </xsl:choose>
1123
+ </span>
1124
+ </xsl:when>
1125
+ <xsl:when test="$style = 'checkbox'">
1126
+ <span class="form-selection-option">
1127
+ <input>
1128
+ <xsl:attribute name="type"><xsl:value-of select="$style"/></xsl:attribute>
1129
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/></xsl:attribute -->
1130
+ <xsl:attribute name="name"><xsl:apply-templates select="parent::selection[1]" mode="id"/></xsl:attribute>
1131
+ <xsl:attribute name="show">
1132
+ <xsl:choose>
1133
+ <xsl:when test=".//form">
1134
+ <xsl:text>rel:</xsl:text>
1135
+ <xsl:apply-templates select="." mode="id"/>
1136
+ </xsl:when>
1137
+ <xsl:otherwise>
1138
+ <xsl:text>none</xsl:text>
1139
+ </xsl:otherwise>
1140
+ </xsl:choose>
1141
+ </xsl:attribute>
1142
+ <xsl:variable name="myid">
1143
+ <xsl:choose>
1144
+ <xsl:when test="@id">
1145
+ <xsl:value-of select="@id"/>
1146
+ </xsl:when>
1147
+ <xsl:otherwise>
1148
+ <xsl:value-of select="."/>
1149
+ </xsl:otherwise>
1150
+ </xsl:choose>
1151
+ </xsl:variable>
1152
+ <xsl:attribute name="value"><xsl:value-of select="$myid"/></xsl:attribute>
1153
+ <xsl:for-each select="../default">
1154
+ <xsl:if test=". = $myid">
1155
+ <xsl:attribute name="checked"/>
1156
+ </xsl:if>
1157
+ </xsl:for-each>
1158
+ </input>
1159
+ <xsl:choose>
1160
+ <xsl:when test="caption">
1161
+ <xsl:choose>
1162
+ <xsl:when test="caption"><xsl:apply-templates select="caption"/></xsl:when>
1163
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1164
+ </xsl:choose>
1165
+ <xsl:apply-templates select="help"/>
1166
+ <xsl:if test="./form">
1167
+ <xsl:apply-templates select="form" mode="body">
1168
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:with-param -->
1169
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1170
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
1171
+ </xsl:apply-templates>
1172
+ </xsl:if>
1173
+ </xsl:when>
1174
+ <xsl:when test="form">
1175
+ <xsl:if test="form/caption">
1176
+ <xsl:apply-templates select="form/caption"/>
1177
+ <xsl:apply-templates select="form/help"/>
1178
+ </xsl:if>
1179
+ <xsl:apply-templates select="form" mode="body">
1180
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:with-param -->
1181
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1182
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
1183
+ </xsl:apply-templates>
1184
+ </xsl:when>
1185
+ </xsl:choose>
1186
+ </span>
1187
+ </xsl:when>
1188
+ <xsl:otherwise>
1189
+ <option>
1190
+ <xsl:variable name="myid">
1191
+ <xsl:choose>
1192
+ <xsl:when test="@id">
1193
+ <xsl:value-of select="@id"/>
1194
+ </xsl:when>
1195
+ <xsl:otherwise>
1196
+ <xsl:value-of select="."/>
1197
+ </xsl:otherwise>
1198
+ </xsl:choose>
1199
+ </xsl:variable>
1200
+ <xsl:attribute name="value"><xsl:value-of select="$myid"/></xsl:attribute>
1201
+ <xsl:for-each select="../default">
1202
+ <xsl:if test=". = $myid">
1203
+ <xsl:attribute name="selected"/>
1204
+ </xsl:if>
1205
+ </xsl:for-each>
1206
+ <xsl:choose>
1207
+ <xsl:when test="caption">
1208
+ <xsl:value-of select="caption"/>
1209
+ </xsl:when>
1210
+ <xsl:otherwise>
1211
+ <xsl:value-of select="$myid"/>
1212
+ </xsl:otherwise>
1213
+ </xsl:choose>
1214
+ </option>
1215
+ </xsl:otherwise>
1216
+ </xsl:choose>
1217
+ </xsl:template>
1218
+
1219
+ <xsl:template match="form/text">
1220
+ <div class="form-text">
1221
+ <xsl:choose>
1222
+ <xsl:when test="caption">
1223
+ <xsl:value-of select="caption"/>
1224
+ <xsl:apply-templates />
1225
+ </xsl:when>
1226
+ <xsl:otherwise>
1227
+ <xsl:apply-templates />
1228
+ </xsl:otherwise>
1229
+ </xsl:choose>
1230
+ </div>
1231
+ </xsl:template>
1232
+
1233
+ <xsl:template match="text/caption"/>
1234
+
1235
+ <xsl:template match="form/file">
1236
+ <!-- xsl:param name="form_id"/ -->
1237
+ <tr>
1238
+ <td align="right" valign="top"> <!-- width="50%"> -->
1239
+ <xsl:apply-templates select="caption"/>
1240
+ <xsl:apply-templates select="help"/>
1241
+ </td>
1242
+ <td valign="top"> <!-- width="50%"> -->
1243
+ <input type="file">
1244
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:attribute -->
1245
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1246
+ <xsl:if test="@accept">
1247
+ <xsl:attribute name="accept"><xsl:value-of select="@accept"/></xsl:attribute>
1248
+ </xsl:if>
1249
+ </input>
1250
+ </td>
1251
+ </tr>
1252
+ </xsl:template>
1253
+
1254
+ <xsl:template match="form//stored">
1255
+ <!-- xsl:param name="form_id"/ -->
1256
+ <input type="hidden">
1257
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:attribute -->
1258
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1259
+ <xsl:attribute name="value"><xsl:apply-templates/></xsl:attribute>
1260
+ </input>
1261
+ </xsl:template>
1262
+
1263
+ <xsl:template match="form//submit">
1264
+ <!-- xsl:param name="form_id"/ -->
1265
+ <xsl:choose>
1266
+ <xsl:when test="caption/* or (default and caption)">
1267
+ <!-- input type="submit" -->
1268
+ <button type="submit"> <!-- onClick="submit()" -->
1269
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:attribute -->
1270
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1271
+ <xsl:attribute name="value">
1272
+ <xsl:choose>
1273
+ <xsl:when test="default">
1274
+ <xsl:value-of select="default"/>
1275
+ </xsl:when>
1276
+ <xsl:otherwise>
1277
+ <xsl:value-of select="caption"/>
1278
+ </xsl:otherwise>
1279
+ </xsl:choose>
1280
+ </xsl:attribute>
1281
+ <xsl:if test="ancestor::head">
1282
+ <xsl:attribute name="class">head</xsl:attribute>
1283
+ </xsl:if>
1284
+ <xsl:apply-templates select="caption"/>
1285
+ </button>
1286
+ <!-- /input -->
1287
+ </xsl:when>
1288
+ <xsl:otherwise>
1289
+ <input type="submit">
1290
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:attribute -->
1291
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1292
+ <xsl:attribute name="value">
1293
+ <xsl:choose>
1294
+ <xsl:when test="default">
1295
+ <xsl:value-of select="default"/>
1296
+ </xsl:when>
1297
+ <xsl:otherwise>
1298
+ <xsl:value-of select="caption"/>
1299
+ </xsl:otherwise>
1300
+ </xsl:choose>
1301
+ </xsl:attribute>
1302
+ <xsl:if test="ancestor::head">
1303
+ <xsl:attribute name="class">head</xsl:attribute>
1304
+ </xsl:if>
1305
+ </input>
1306
+ </xsl:otherwise>
1307
+ </xsl:choose>
1308
+ </xsl:template>
1309
+
1310
+ <xsl:template match="form//reset">
1311
+ <!-- xsl:param name="form_id"/ -->
1312
+ <xsl:choose>
1313
+ <xsl:when test="caption/*">
1314
+ <button type="reset">
1315
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1316
+ <xsl:apply-templates select="caption"/>
1317
+ </button>
1318
+ </xsl:when>
1319
+ <xsl:otherwise>
1320
+ <input type="reset">
1321
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/>.<xsl:value-of select="@id"/></xsl:attribute -->
1322
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1323
+ </input>
1324
+ </xsl:otherwise>
1325
+ </xsl:choose>
1326
+ </xsl:template>
1327
+
1328
+ <!-- forms in head or foot elements -->
1329
+
1330
+ <xsl:template match="head//form|foot//form">
1331
+ <xsl:choose>
1332
+ <xsl:when test="count(//container[@id and not(ancestor::container[@id] | ancestor::form)] | //form[not(ancestor::container[@id] | ancestor::form)]) > 1">
1333
+ <xsl:if test="./caption">
1334
+ <xsl:apply-templates select="caption"/>
1335
+ <xsl:text>: </xsl:text>
1336
+ </xsl:if>
1337
+ <xsl:apply-templates select="text|grid|textline|textbox|editbox|file|password|selection|form|group|textreader">
1338
+ <!-- xsl:with-param name="form_id">
1339
+ <xsl:if test="@id">
1340
+ <xsl:value-of select="@id"/>
1341
+ </xsl:if>
1342
+ </xsl:with-param -->
1343
+ <xsl:with-param name="form_level">3</xsl:with-param>
1344
+ </xsl:apply-templates>
1345
+ <xsl:if test="submit|reset">
1346
+ <xsl:apply-templates select="submit|reset">
1347
+ <!-- xsl:with-param name="form_id">
1348
+ <xsl:if test="@id">
1349
+ <xsl:value-of select="@id"/>
1350
+ </xsl:if>
1351
+ </xsl:with-param -->
1352
+ </xsl:apply-templates>
1353
+ </xsl:if>
1354
+ <xsl:apply-templates select="stored">
1355
+ <!-- xsl:with-param name="form_id">
1356
+ <xsl:if test="@id">
1357
+ <xsl:value-of select="@id"/>
1358
+ </xsl:if>
1359
+ </xsl:with-param -->
1360
+ </xsl:apply-templates>
1361
+ </xsl:when>
1362
+ <xsl:otherwise>
1363
+ <form>
1364
+ <xsl:if test="@id">
1365
+ <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
1366
+ </xsl:if>
1367
+ <xsl:attribute name="method">
1368
+ <xsl:choose>
1369
+ <xsl:when test="@method = 'POST'">POST</xsl:when>
1370
+ <xsl:when test=".//file">POST</xsl:when>
1371
+ <xsl:when test=".//textbox">POST</xsl:when>
1372
+ <xsl:when test=".//editbox">POST</xsl:when>
1373
+ <xsl:otherwise>POST</xsl:otherwise>
1374
+ </xsl:choose>
1375
+ </xsl:attribute>
1376
+ <xsl:if test="@target">
1377
+ <xsl:attribute name="action"><xsl:value-of select="@target"/></xsl:attribute>
1378
+ </xsl:if>
1379
+ <xsl:if test=".//file">
1380
+ <xsl:attribute name="type">application/x-multipart</xsl:attribute>
1381
+ </xsl:if>
1382
+ <xsl:if test="./caption">
1383
+ <xsl:apply-templates select="caption"/>
1384
+ <xsl:text>: </xsl:text>
1385
+ </xsl:if>
1386
+ <xsl:apply-templates select="text|grid|textline|textbox|editbox|file|password|selection|form|group|textreader">
1387
+ <!-- xsl:with-param name="form_id">
1388
+ <xsl:if test="@id">
1389
+ <xsl:value-of select="@id"/>
1390
+ </xsl:if>
1391
+ </xsl:with-param -->
1392
+ <xsl:with-param name="form_level">3</xsl:with-param>
1393
+ </xsl:apply-templates>
1394
+ <xsl:if test="submit|reset">
1395
+ <xsl:apply-templates select="submit|reset">
1396
+ <!-- xsl:with-param name="form_id">
1397
+ <xsl:if test="@id">
1398
+ <xsl:value-of select="@id"/>
1399
+ </xsl:if>
1400
+ </xsl:with-param -->
1401
+ </xsl:apply-templates>
1402
+ </xsl:if>
1403
+ <xsl:apply-templates select="stored">
1404
+ <!-- xsl:with-param name="form_id">
1405
+ <xsl:if test="@id">
1406
+ <xsl:value-of select="@id"/>
1407
+ </xsl:if>
1408
+ </xsl:with-param -->
1409
+ </xsl:apply-templates>
1410
+ </form>
1411
+ </xsl:otherwise>
1412
+ </xsl:choose>
1413
+ </xsl:template>
1414
+
1415
+ <xsl:template match="head/form/text|foot/form/text">
1416
+ <xsl:apply-templates/>
1417
+ </xsl:template>
1418
+
1419
+ <!-- input fields -->
1420
+
1421
+ <xsl:template match="head/form/password|foot/form/password">
1422
+ <!-- xsl:param name="form_id"/ -->
1423
+ <xsl:apply-templates select="caption"/>
1424
+ <xsl:apply-templates select="help"/>
1425
+ <xsl:call-template name="field-password">
1426
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1427
+ </xsl:call-template>
1428
+ </xsl:template>
1429
+
1430
+ <xsl:template match="head/form/textline|foot/form/textline">
1431
+ <!-- xsl:param name="form_id"/ -->
1432
+ <xsl:apply-templates select="caption"/>
1433
+ <xsl:apply-templates select="help"/>
1434
+ <xsl:call-template name="field-textline">
1435
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1436
+ </xsl:call-template>
1437
+ </xsl:template>
1438
+
1439
+ <xsl:template match="head/form/textbox|foot/form/textbox|head/form/editbox|foot/form/editbox">
1440
+ <!-- xsl:param name="form_id"/ -->
1441
+ <xsl:choose>
1442
+ <xsl:when test="caption">
1443
+ <xsl:apply-templates select="caption"/>
1444
+ <xsl:apply-templates select="help"/>
1445
+ <xsl:call-template name="field-textbox">
1446
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1447
+ </xsl:call-template>
1448
+ </xsl:when>
1449
+ <xsl:otherwise>
1450
+ <xsl:call-template name="field-textbox">
1451
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1452
+ <xsl:with-param name="size">2</xsl:with-param>
1453
+ </xsl:call-template>
1454
+ </xsl:otherwise>
1455
+ </xsl:choose>
1456
+ </xsl:template>
1457
+
1458
+ <xsl:template match="head/form/textreader|foot/form/textreader">
1459
+ <!-- xsl:param name="form_id"/ -->
1460
+ <xsl:apply-templates select="caption"/>
1461
+ <xsl:apply-templates select="help"/>
1462
+ <xsl:call-template name="field-textreader"/>
1463
+ </xsl:template>
1464
+
1465
+ <xsl:template match="head/form/selection|foot/form/selection">
1466
+ <!-- xsl:param name="form_id"/ -->
1467
+ <xsl:param name="form_level"/>
1468
+ <xsl:apply-templates select="caption"/>
1469
+ <xsl:apply-templates select="help"/>
1470
+ <xsl:call-template name="field-selection">
1471
+ <!-- xsl:with-param name="form_id"><xsl:value-of select="$form_id"/></xsl:with-param -->
1472
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level"/></xsl:with-param>
1473
+ </xsl:call-template>
1474
+ </xsl:template>
1475
+
1476
+ <xsl:template match="head/form/selection/option|foot/form/selection/option">
1477
+ <xsl:param name="style"/>
1478
+ <!-- xsl:param name="form_id"/ -->
1479
+ <xsl:param name="form_level"/>
1480
+ <xsl:choose>
1481
+ <xsl:when test="$style = 'radio'">
1482
+ <input>
1483
+ <xsl:attribute name="type"><xsl:value-of select="$style"/></xsl:attribute>
1484
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/></xsl:attribute -->
1485
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1486
+ <xsl:attribute name="show">
1487
+ <xsl:choose>
1488
+ <xsl:when test=".//form">
1489
+ <xsl:text>rel:</xsl:text>
1490
+ <xsl:apply-templates select="." mode="id"/>
1491
+ </xsl:when>
1492
+ <xsl:otherwise>
1493
+ <xsl:text>none</xsl:text>
1494
+ </xsl:otherwise>
1495
+ </xsl:choose>
1496
+ </xsl:attribute>
1497
+ <xsl:variable name="myid">
1498
+ <xsl:choose>
1499
+ <xsl:when test="@id">
1500
+ <xsl:value-of select="@id"/>
1501
+ </xsl:when>
1502
+ <xsl:otherwise>
1503
+ <xsl:value-of select="."/>
1504
+ </xsl:otherwise>
1505
+ </xsl:choose>
1506
+ </xsl:variable>
1507
+ <xsl:attribute name="value"><xsl:value-of select="$myid"/></xsl:attribute>
1508
+ <xsl:for-each select="../default">
1509
+ <xsl:if test=". = $myid">
1510
+ <xsl:attribute name="checked"/>
1511
+ </xsl:if>
1512
+ </xsl:for-each>
1513
+ </input>
1514
+ <xsl:choose>
1515
+ <xsl:when test="caption"><xsl:apply-templates select="caption"/></xsl:when>
1516
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1517
+ </xsl:choose>
1518
+ <xsl:apply-templates select="help"/>
1519
+ <xsl:if test="./form">
1520
+ <xsl:apply-templates select="form">
1521
+ <!-- xsl:with-param name="form_id"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:with-param -->
1522
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
1523
+ </xsl:apply-templates>
1524
+ </xsl:if>
1525
+ </xsl:when>
1526
+ <xsl:when test="$style = 'checkbox'">
1527
+ <span class="form-element">
1528
+ <input>
1529
+ <xsl:attribute name="type"><xsl:value-of select="$style"/></xsl:attribute>
1530
+ <!-- xsl:attribute name="name"><xsl:value-of select="$form_id"/></xsl:attribute -->
1531
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1532
+ <xsl:attribute name="show">
1533
+ <xsl:choose>
1534
+ <xsl:when test=".//form">
1535
+ <xsl:text>rel:</xsl:text>
1536
+ <xsl:apply-templates select="." mode="id"/>
1537
+ </xsl:when>
1538
+ <xsl:otherwise>
1539
+ <xsl:text>none</xsl:text>
1540
+ </xsl:otherwise>
1541
+ </xsl:choose>
1542
+ </xsl:attribute>
1543
+ <xsl:variable name="myid">
1544
+ <xsl:choose>
1545
+ <xsl:when test="@id">
1546
+ <xsl:value-of select="@id"/>
1547
+ </xsl:when>
1548
+ <xsl:otherwise>
1549
+ <xsl:value-of select="."/>
1550
+ </xsl:otherwise>
1551
+ </xsl:choose>
1552
+ </xsl:variable>
1553
+ <xsl:attribute name="value"><xsl:value-of select="$myid"/></xsl:attribute>
1554
+ <xsl:for-each select="../default">
1555
+ <xsl:if test=". = $myid">
1556
+ <xsl:attribute name="checked"/>
1557
+ </xsl:if>
1558
+ </xsl:for-each>
1559
+ </input>
1560
+ <xsl:choose>
1561
+ <xsl:when test="caption"><xsl:apply-templates select="caption"/></xsl:when>
1562
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1563
+ </xsl:choose>
1564
+ <xsl:apply-templates select="help"/>
1565
+ <xsl:if test="./form">
1566
+ <xsl:apply-templates select="form">
1567
+ <!-- xsl:with-param name="form_id"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:with-param -->
1568
+ <xsl:with-param name="form_level"><xsl:value-of select="$form_level+1"/></xsl:with-param>
1569
+ </xsl:apply-templates>
1570
+ </xsl:if>
1571
+ </span>
1572
+ </xsl:when>
1573
+ <xsl:otherwise>
1574
+ <option>
1575
+ <xsl:variable name="myid">
1576
+ <xsl:choose>
1577
+ <xsl:when test="@id">
1578
+ <xsl:value-of select="@id"/>
1579
+ </xsl:when>
1580
+ <xsl:otherwise>
1581
+ <xsl:value-of select="."/>
1582
+ </xsl:otherwise>
1583
+ </xsl:choose>
1584
+ </xsl:variable>
1585
+ <xsl:attribute name="value"><xsl:value-of select="$myid"/></xsl:attribute>
1586
+ <xsl:for-each select="../default">
1587
+ <xsl:if test=". = $myid">
1588
+ <xsl:attribute name="selected"/>
1589
+ </xsl:if>
1590
+ </xsl:for-each>
1591
+ <xsl:apply-templates/>
1592
+ </option>
1593
+ </xsl:otherwise>
1594
+ </xsl:choose>
1595
+ </xsl:template>
1596
+
1597
+ <xsl:template match="head/form/asset|foot/form/asset">
1598
+ <!-- xsl:param name="form_id"/ -->
1599
+ <xsl:apply-templates select="caption"/>
1600
+ <xsl:apply-templates select="help"/>
1601
+ <input type="file">
1602
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1603
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1604
+ <xsl:if test="@accept">
1605
+ <xsl:attribute name="accept"><xsl:value-of select="@accept"/></xsl:attribute>
1606
+ </xsl:if>
1607
+ </input>
1608
+ </xsl:template>
1609
+
1610
+ <xsl:template match="head/form/stored|foot/form/stored">
1611
+ <!-- xsl:param name="form_id"/ -->
1612
+ <input type="hidden">
1613
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1614
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1615
+ <xsl:attribute name="value"><xsl:apply-templates/></xsl:attribute>
1616
+ </input>
1617
+ </xsl:template>
1618
+
1619
+ <xsl:template match="head/form/submit|foot/form/submit">
1620
+ <!-- xsl:param name="form_id"/ -->
1621
+ <xsl:choose>
1622
+ <xsl:when test="caption/*">
1623
+ <button type="submit"> <!-- onClick="submit()" -->
1624
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1625
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1626
+ <xsl:attribute name="value"><xsl:value-of select="caption"/></xsl:attribute>
1627
+ <xsl:if test="ancestor::head">
1628
+ <xsl:attribute name="class">head</xsl:attribute>
1629
+ </xsl:if>
1630
+ <xsl:apply-templates select="caption"/>
1631
+ </button>
1632
+ </xsl:when>
1633
+ <xsl:otherwise>
1634
+ <input type="submit">
1635
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1636
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1637
+ <xsl:attribute name="value"><xsl:value-of select="caption"/></xsl:attribute>
1638
+ <xsl:if test="ancestor::head">
1639
+ <xsl:attribute name="class">head</xsl:attribute>
1640
+ </xsl:if>
1641
+ </input>
1642
+ </xsl:otherwise>
1643
+ </xsl:choose>
1644
+ </xsl:template>
1645
+
1646
+ <xsl:template match="head/form/reset|foot/form/reset">
1647
+ <!-- xsl:param name="form_id"/ -->
1648
+ <xsl:choose>
1649
+ <xsl:when test="caption/*">
1650
+ <button type="reset">
1651
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1652
+ <xsl:if test="ancestor::head">
1653
+ <xsl:attribute name="class">head</xsl:attribute>
1654
+ </xsl:if>
1655
+ <xsl:apply-templates select="caption"/>
1656
+ </button>
1657
+ </xsl:when>
1658
+ <xsl:otherwise>
1659
+ <input type="reset">
1660
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1661
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1662
+ <xsl:if test="ancestor::head">
1663
+ <xsl:attribute name="class">head</xsl:attribute>
1664
+ </xsl:if>
1665
+ </input>
1666
+ </xsl:otherwise>
1667
+ </xsl:choose>
1668
+ </xsl:template>
1669
+
1670
+ <!-- generic methods for outputting actual input element -->
1671
+
1672
+ <xsl:template name="field-password">
1673
+ <!-- xsl:param name="form_id"/ -->
1674
+ <input type="password">
1675
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1676
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1677
+ <xsl:attribute name="value"><xsl:value-of select="default"/></xsl:attribute>
1678
+ <xsl:attribute name="size">
1679
+ <xsl:choose>
1680
+ <xsl:when test="@length > 40">40</xsl:when>
1681
+ <xsl:when test="@length"><xsl:value-of select="@length"/></xsl:when>
1682
+ <xsl:otherwise>12</xsl:otherwise>
1683
+ </xsl:choose>
1684
+ </xsl:attribute>
1685
+ <xsl:if test="ancestor::head">
1686
+ <xsl:attribute name="class">head</xsl:attribute>
1687
+ </xsl:if>
1688
+ </input>
1689
+ </xsl:template>
1690
+
1691
+ <xsl:template name="field-textline">
1692
+ <!-- xsl:param name="form_id"/ -->
1693
+ <input type="text">
1694
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1695
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1696
+ <xsl:attribute name="value"><xsl:value-of select="default"/></xsl:attribute>
1697
+ <xsl:attribute name="size">
1698
+ <xsl:choose>
1699
+ <xsl:when test="@length > 40">40</xsl:when>
1700
+ <xsl:when test="@length"><xsl:value-of select="@length"/></xsl:when>
1701
+ <xsl:otherwise>12</xsl:otherwise>
1702
+ </xsl:choose>
1703
+ </xsl:attribute>
1704
+ <xsl:if test="ancestor::head">
1705
+ <xsl:attribute name="class">head</xsl:attribute>
1706
+ </xsl:if>
1707
+ </input>
1708
+ </xsl:template>
1709
+
1710
+ <xsl:template name="field-textbox">
1711
+ <!-- xsl:param name="form_id"/ -->
1712
+ <xsl:param name="size"/>
1713
+ <textarea wrap="">
1714
+ <xsl:choose>
1715
+ <xsl:when test="name(.) = 'editbox'">
1716
+ <xsl:attribute name="cols">80</xsl:attribute>
1717
+ <xsl:attribute name="rows">30</xsl:attribute>
1718
+ </xsl:when>
1719
+ <xsl:when test="$size=2">
1720
+ <xsl:attribute name="cols">40</xsl:attribute>
1721
+ <xsl:attribute name="rows">10</xsl:attribute>
1722
+ </xsl:when>
1723
+ <xsl:otherwise>
1724
+ <xsl:attribute name="cols">40</xsl:attribute>
1725
+ <xsl:attribute name="rows">10</xsl:attribute>
1726
+ </xsl:otherwise>
1727
+ </xsl:choose>
1728
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1729
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1730
+ <xsl:value-of select="default"/>
1731
+ </textarea>
1732
+ </xsl:template>
1733
+
1734
+ <xsl:template name="field-textreader">
1735
+ <!-- xsl:param name="form_id"/ -->
1736
+ <textarea rows="20" cols="80" wrap="" readonly="">
1737
+ <xsl:value-of select="."/>
1738
+ </textarea>
1739
+ </xsl:template>
1740
+
1741
+ <xsl:template name="field-selection">
1742
+ <!-- xsl:param name="form_id"/ -->
1743
+ <xsl:param name="form_level"/>
1744
+ <xsl:param name="style">
1745
+ <xsl:if test="option//form">
1746
+ <xsl:choose>
1747
+ <xsl:when test="@count = 'multiple'">checkbox</xsl:when>
1748
+ <xsl:otherwise>radio</xsl:otherwise>
1749
+ </xsl:choose>
1750
+ </xsl:if>
1751
+ </xsl:param>
1752
+ <xsl:choose>
1753
+ <xsl:when test="not($style) or $style = ''">
1754
+ <select>
1755
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1756
+ <xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute>
1757
+ <xsl:if test="@count = 'multiple'">
1758
+ <xsl:attribute name="multiple"><xsl:text>1</xsl:text></xsl:attribute>
1759
+ </xsl:if>
1760
+ <xsl:apply-templates select="option">
1761
+ </xsl:apply-templates>
1762
+ </select>
1763
+ </xsl:when>
1764
+ <xsl:otherwise>
1765
+ <!-- select -->
1766
+ <!-- xsl:attribute name="name"><xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/>.</xsl:if><xsl:value-of select="@id"/></xsl:attribute -->
1767
+ <!-- xsl:attribute name="name"><xsl:apply-templates select="." mode="id"/></xsl:attribute -->
1768
+ <!-- xsl:if test="@count = 'multiple'">
1769
+ <xsl:attribute name="multiple"/>
1770
+ </xsl:if -->
1771
+ <span class="form-selection-options">
1772
+ <xsl:apply-templates select="option">
1773
+ <xsl:with-param name="style" select="$style"/>
1774
+ <xsl:with-param name="form_level" select="$form_level"/>
1775
+ <!-- xsl:with-param name="form_id">
1776
+ <xsl:if test="$form_id != ''"><xsl:value-of select="$form_id"/><xsl:text>.</xsl:text></xsl:if>
1777
+ <xsl:value-of select="@id"/>
1778
+ </xsl:with-param -->
1779
+ </xsl:apply-templates>
1780
+ </span>
1781
+ <!-- /select -->
1782
+ </xsl:otherwise>
1783
+ </xsl:choose>
1784
+ </xsl:template>
1785
+
1786
+ <xsl:template name="field-grid">
1787
+ <!-- have <column/>s and <row/>s -->
1788
+ <xsl:variable name="inputtype">
1789
+ <xsl:choose>
1790
+ <xsl:when test="starts-with(@count, 'multiple-') or @count = 'multiple'">
1791
+ <xsl:text>checkbox</xsl:text>
1792
+ </xsl:when>
1793
+ <xsl:otherwise>
1794
+ <xsl:text>radio</xsl:text>
1795
+ </xsl:otherwise>
1796
+ </xsl:choose>
1797
+ </xsl:variable>
1798
+ <!-- naming determines which direction choices are constrained -->
1799
+ <xsl:variable name="nametype">
1800
+ <xsl:choose>
1801
+ <xsl:when test="substring-before(@count, '-by-row')">
1802
+ <xsl:text>row</xsl:text>
1803
+ </xsl:when>
1804
+ <xsl:when test="substring-before(@count, '-by-column')">
1805
+ <xsl:text>col</xsl:text>
1806
+ </xsl:when>
1807
+ <xsl:otherwise>
1808
+ <xsl:text>neither</xsl:text>
1809
+ </xsl:otherwise>
1810
+ </xsl:choose>
1811
+ </xsl:variable>
1812
+
1813
+ <xsl:variable name="grid-id">
1814
+ <xsl:apply-templates select="." mode="id"/>
1815
+ </xsl:variable>
1816
+
1817
+ <table class="grid">
1818
+ <tr>
1819
+ <td/>
1820
+ <xsl:for-each select="column">
1821
+ <td class="grid-column-caption">
1822
+ <xsl:choose>
1823
+ <xsl:when test="caption">
1824
+ <xsl:apply-templates select="caption"/>
1825
+ </xsl:when>
1826
+ <xsl:otherwise>
1827
+ <xsl:value-of select="@id"/>
1828
+ </xsl:otherwise>
1829
+ </xsl:choose>
1830
+ </td>
1831
+ </xsl:for-each>
1832
+ </tr>
1833
+ <xsl:for-each select="row">
1834
+ <xsl:variable name="row-id" select="@id"/>
1835
+ <tr>
1836
+ <td class="grid-row-caption">
1837
+ <xsl:choose>
1838
+ <xsl:when test="caption">
1839
+ <xsl:apply-templates select="caption"/>
1840
+ </xsl:when>
1841
+ <xsl:otherwise>
1842
+ <xsl:value-of select="@id"/>
1843
+ </xsl:otherwise>
1844
+ </xsl:choose>
1845
+ </td>
1846
+ <xsl:for-each select="../column">
1847
+ <td class="grid-cell"><input>
1848
+ <xsl:attribute name="type"><xsl:value-of select="$inputtype"/></xsl:attribute>
1849
+ <xsl:attribute name="name">
1850
+ <xsl:value-of select="$grid-id"/>
1851
+ <xsl:if test="$nametype = 'row'">
1852
+ <xsl:text>.</xsl:text><xsl:value-of select="$row-id"/>
1853
+ </xsl:if>
1854
+ <xsl:if test="$nametype = 'col'">
1855
+ <xsl:text>.</xsl:text><xsl:value-of select="@id"/>
1856
+ </xsl:if>
1857
+ </xsl:attribute>
1858
+ <xsl:attribute name="value">
1859
+ <xsl:choose>
1860
+ <xsl:when test="$nametype = 'row'">
1861
+ <xsl:value-of select="@id"/>
1862
+ </xsl:when>
1863
+ <xsl:when test="$nametype = 'col'">
1864
+ <xsl:value-of select="$row-id"/>
1865
+ </xsl:when>
1866
+ <xsl:otherwise>
1867
+ <xsl:value-of select="$row-id"/><xsl:text>.</xsl:text><xsl:value-of select="@id"/>
1868
+ </xsl:otherwise>
1869
+ </xsl:choose>
1870
+ </xsl:attribute>
1871
+ <!-- need to handle defaults now -->
1872
+ <xsl:if test="
1873
+ ../row[@id = $row-id]/default/text() = @id
1874
+ or ./default/text() = $row-id
1875
+ or ../default/text() = concat($row-id, '.', @id)
1876
+ ">
1877
+ <xsl:attribute name="checked"/>
1878
+ </xsl:if>
1879
+ </input></td>
1880
+ </xsl:for-each>
1881
+ </tr>
1882
+ </xsl:for-each>
1883
+ </table>
1884
+ </xsl:template>
1885
+
1886
+ <!--
1887
+ <list id="wf-id" numbering="yes">
1888
+ <columns>
1889
+ <caption>List Name</caption>
1890
+ <caption>State</caption>
1891
+ <caption>Last Update</caption>
1892
+ </columns>
1893
+ [% FOREACH result IN results %]
1894
+ <listitem id="[% result.id %]">
1895
+ <column>[% result.name | html %]</column>
1896
+ <column>[% result.state | html %]</column>
1897
+ <column>[% result.last_update | html %]</column>
1898
+ </listitem>
1899
+ [% END %]
1900
+ </list>
1901
+ -->
1902
+
1903
+ <xsl:template name="form-list">
1904
+ <xsl:variable name="id">
1905
+ <xsl:apply-templates select="." mode="id"/>
1906
+ </xsl:variable>
1907
+ <table class="list">
1908
+ <thead class="list">
1909
+ <xsl:if test="@numbering">
1910
+ <td><xsl:value-of select="@numbering"/></td>
1911
+ </xsl:if>
1912
+ <xsl:for-each select="columns/caption">
1913
+ <td><xsl:apply-templates/></td>
1914
+ </xsl:for-each>
1915
+ </thead>
1916
+ <tbody>
1917
+ <xsl:variable name="numbering">
1918
+ <xsl:choose>
1919
+ <xsl:when test="@numbering">
1920
+ <xsl:value-of select="1"/>
1921
+ </xsl:when>
1922
+ <xsl:otherwise>
1923
+ <xsl:value-of select="''"/>
1924
+ </xsl:otherwise>
1925
+ </xsl:choose>
1926
+ </xsl:variable>
1927
+ <xsl:variable name="offset">
1928
+ <xsl:choose>
1929
+ <xsl:when test="@start">
1930
+ <xsl:value-of select="@start - 1"/>
1931
+ </xsl:when>
1932
+ <xsl:otherwise>
1933
+ <xsl:value-of select="0"/>
1934
+ </xsl:otherwise>
1935
+ </xsl:choose>
1936
+ </xsl:variable>
1937
+ <xsl:variable name="inputtype">
1938
+ <xsl:choose>
1939
+ <xsl:when test="@count = 'multiple'">
1940
+ <xsl:value-of select="'checkbox'"/>
1941
+ </xsl:when>
1942
+ <xsl:otherwise>
1943
+ <xsl:value-of select="'radio'"/>
1944
+ </xsl:otherwise>
1945
+ </xsl:choose>
1946
+ </xsl:variable>
1947
+ <xsl:for-each select="listitem">
1948
+ <xsl:variable name="base-class">
1949
+ <xsl:choose>
1950
+ <xsl:when test="position() mod 2">
1951
+ <xsl:value-of select="'odd'"/>
1952
+ </xsl:when>
1953
+ <xsl:otherwise>
1954
+ <xsl:value-of select="'even'"/>
1955
+ </xsl:otherwise>
1956
+ </xsl:choose>
1957
+ </xsl:variable>
1958
+ <tr>
1959
+ <xsl:attribute name="class">
1960
+ <xsl:value-of select="concat('list-row-', $base-class)"/>
1961
+ </xsl:attribute>
1962
+ <xsl:if test="$numbering">
1963
+ <td>
1964
+ <xsl:attribute name="class">
1965
+ <xsl:value-of select="concat('list-row-element-', $base-class)"/>
1966
+ </xsl:attribute>
1967
+ <xsl:value-of select="position() + $offset"/>
1968
+ </td>
1969
+ </xsl:if>
1970
+ <xsl:variable name="pos" select="position()"/>
1971
+ <xsl:for-each select="column">
1972
+ <td>
1973
+ <xsl:attribute name="class">
1974
+ <xsl:value-of select="concat('list-row-element-', $base-class)"/>
1975
+ </xsl:attribute>
1976
+ <xsl:if test="position() = 1">
1977
+ <input>
1978
+ <xsl:attribute name="type"><xsl:value-of select="$inputtype"/></xsl:attribute>
1979
+ <xsl:attribute name="name">
1980
+ <xsl:value-of select="$id"/>
1981
+ </xsl:attribute>
1982
+ <xsl:variable name="value">
1983
+ <xsl:choose>
1984
+ <xsl:when test="../@id">
1985
+ <xsl:value-of select="../@id"/>
1986
+ </xsl:when>
1987
+ <xsl:otherwise>
1988
+ <xsl:value-of select="$pos + $offset"/>
1989
+ </xsl:otherwise>
1990
+ </xsl:choose>
1991
+ </xsl:variable>
1992
+ <xsl:attribute name="value">
1993
+ <xsl:value-of select="$value"/>
1994
+ </xsl:attribute>
1995
+ <!-- need to handle defaults now -->
1996
+ <xsl:if test="
1997
+ ../default[text() = $value]
1998
+ ">
1999
+ <xsl:attribute name="checked"/>
2000
+ </xsl:if>
2001
+ </input>
2002
+ </xsl:if>
2003
+ <xsl:apply-templates/>
2004
+ </td>
2005
+ </xsl:for-each>
2006
+ </tr>
2007
+ </xsl:for-each>
2008
+ <xsl:if test="1 > count(listitem)">
2009
+ <tr class="list-row-odd">
2010
+ <xsl:if test="@numbering">
2011
+ <td class="list-row-element-odd">1</td>
2012
+ </xsl:if>
2013
+ <xsl:for-each select="columns/caption">
2014
+ <td class="list-row-element-odd"/>
2015
+ </xsl:for-each>
2016
+ </tr>
2017
+ </xsl:if>
2018
+ <xsl:if test="2 > count(listitem)">
2019
+ <tr class="list-row-even">
2020
+ <xsl:if test="@numbering">
2021
+ <td class="list-row-element-even">2</td>
2022
+ </xsl:if>
2023
+ <xsl:for-each select="columns/caption">
2024
+ <td class="list-row-element-even"/>
2025
+ </xsl:for-each>
2026
+ </tr>
2027
+ </xsl:if>
2028
+ <xsl:if test="3 > count(listitem)">
2029
+ <tr class="list-row-odd">
2030
+ <xsl:if test="@numbering">
2031
+ <td class="list-row-element-odd">3</td>
2032
+ </xsl:if>
2033
+ <xsl:for-each select="columns/caption">
2034
+ <td class="list-row-element-odd"/>
2035
+ </xsl:for-each>
2036
+ </tr>
2037
+ </xsl:if>
2038
+ <xsl:if test="4 > count(listitem)">
2039
+ <tr class="list-row-even">
2040
+ <xsl:if test="@numbering">
2041
+ <td class="list-row-element-even">4</td>
2042
+ </xsl:if>
2043
+ <xsl:for-each select="columns/caption">
2044
+ <td class="list-row-element-even"/>
2045
+ </xsl:for-each>
2046
+ </tr>
2047
+ </xsl:if>
2048
+ <xsl:if test="5 > count(listitem)">
2049
+ <tr class="list-row-odd">
2050
+ <xsl:if test="@numbering">
2051
+ <td class="list-row-element-odd">5</td>
2052
+ </xsl:if>
2053
+ <xsl:for-each select="columns/caption">
2054
+ <td class="list-row-element-odd"/>
2055
+ </xsl:for-each>
2056
+ </tr>
2057
+ </xsl:if>
2058
+ </tbody>
2059
+ </table>
2060
+ </xsl:template>
2061
+
2062
+ <!-- id generation templates -->
2063
+
2064
+ <xsl:template match="container" mode="id">
2065
+ <xsl:value-of select="@id"/>
2066
+ </xsl:template>
2067
+
2068
+ <!-- xsl:template match="form" mode="id">
2069
+ <xsl:choose>
2070
+ <xsl:when test="ancestor::form[@id]">
2071
+ <xsl:apply-templates select="ancestor::form[@id]"/>
2072
+ <xsl:if test="@id">
2073
+ <xsl:text>.</xsl:text><xsl:value-of select="@id"/>
2074
+ </xsl:if>
2075
+ </xsl:when>
2076
+ <xsl:when test="ancestor::container[@id]">
2077
+ <xsl:apply-templates select="ancestor::container[@id]"/>
2078
+ <xsl:if test="@id">
2079
+ <xsl:text>.</xsl:text><xsl:value-of select="@id"/>
2080
+ </xsl:if>
2081
+ </xsl:when>
2082
+ <xsl:otherwise>
2083
+ <xsl:if test="@id">
2084
+ <xsl:value-of select="@id"/>
2085
+ </xsl:if>
2086
+ </xsl:otherwise>
2087
+ </xsl:choose>
2088
+ </xsl:template -->
2089
+
2090
+ <xsl:template match="submit|grid|stored|text|textline|textbox|editbox|asset|password|selection|group|textreader|option|list" mode="id">
2091
+ <!--
2092
+ ancestor::text
2093
+ | ancestor::textline
2094
+ | ancestor::textbox
2095
+ | ancestor::asset
2096
+ | ancestor::password
2097
+ | ancestor::textreader
2098
+ | ancestor::submit
2099
+ | ancestor::stored
2100
+ | ancestor::grid
2101
+ -->
2102
+ <xsl:for-each select="
2103
+ ancestor::option[@id != '']
2104
+ | ancestor::selection[@id != '']
2105
+ | ancestor::group[@id != '']
2106
+ | ancestor::form[@id != '']
2107
+ | ancestor::container[@id != '']
2108
+ | ancestor::list[@id != '']
2109
+ "
2110
+ >
2111
+ <xsl:value-of select="@id"/>
2112
+ <xsl:if test="position() != last()">
2113
+ <xsl:text>.</xsl:text>
2114
+ </xsl:if>
2115
+ </xsl:for-each>
2116
+ <xsl:if test="@id">
2117
+ <xsl:if test="
2118
+ ancestor::option[@id != '']
2119
+ | ancestor::selection[@id != '']
2120
+ | ancestor::group[@id != '']
2121
+ | ancestor::form[@id != '']
2122
+ | ancestor::container[@id != '']
2123
+ | ancestor::list[@id != '']
2124
+ "
2125
+ >
2126
+ <xsl:text>.</xsl:text>
2127
+ </xsl:if>
2128
+ <xsl:value-of select="@id"/>
2129
+ </xsl:if>
2130
+ <xsl:if test="self::selection[@id != '']/option/form">
2131
+ <xsl:text>.value</xsl:text>
2132
+ </xsl:if>
2133
+ </xsl:template>
2134
+
2135
+ <xsl:template name="format-url">
2136
+ <xsl:param name="url"/>
2137
+
2138
+ <xsl:choose>
2139
+ <xsl:when test="/view/@redirect-url and contains($url, '://')">
2140
+ <xsl:value-of select="/view/@redirect-url"/>
2141
+ <xsl:text>?</xsl:text>
2142
+ <xsl:value-of select="$url"/>
2143
+ </xsl:when>
2144
+ <xsl:when test="/view/@redirect-url and /view/@session-id and starts-with($url, '/')">
2145
+ <xsl:text>/</xsl:text>
2146
+ <xsl:value-of select="/view/@session-id"/>
2147
+ <xsl:value-of select="$url"/>
2148
+ </xsl:when>
2149
+ <xsl:otherwise>
2150
+ <xsl:value-of select="$url"/>
2151
+ </xsl:otherwise>
2152
+ </xsl:choose>
2153
+ </xsl:template>
2154
+
2155
+ <!-- some useful entities -->
2156
+
2157
+ <xsl:template match="nbsp">
2158
+ <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
2159
+ </xsl:template>
2160
+
2161
+ </xsl:stylesheet>