-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathto_form.xslt
More file actions
executable file
·2626 lines (1939 loc) · 79.6 KB
/
to_form.xslt
File metadata and controls
executable file
·2626 lines (1939 loc) · 79.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<!-- to_form
Copyright Deakin University 2005,2006,2008
Written by Adam Zammit - adam.zammit@deakin.edu.au
For the Deakin Computer Assisted Research Facility: http://www.deakin.edu.au/dcarf/
This file is part of queXML.
queXML is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
queXML is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Converts queXML to XSL:FO.
XSL:FO is best rendered to PDF using the renderx toolkit (see http://www.renderx.com)
This form design attempts to follow the guidelines and principles in
Barnett, Robert "The Form Designer's Quick Reference Guide" 1994
Including:
Using white boxes on a light coloured background (grey)
Ideal box size being 4-5mm squared
Ideal line weight being 0.2 to 0.5 points
Using a serif font of at least 12 points
Using "Eye guides" to determine what responses need to be selected
Using "dotted" delimiters for filling out specific width text fields
This form also attempts to be useful for the Teleform form recognition program by:
Using "Guides" (the black corners on each page) to allow the page to be aligned
Using barcodes in a format that Teleform can recognise
Using a unique barcode on each page to allow for automatic page ordering
-->
<!-- This is the main stylesheet -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:dcarf="http://www.deakin.edu.au/dcarf">
<xsl:import href="to_form_page_layout.xslt"/>
<xsl:import href="to_form_property_sets.xslt"/>
<xsl:template match="questionnaire">
<xsl:apply-templates/>
</xsl:template>
<!-- The first page that isn't the cover -->
<xsl:template name="firstpage">
<!-- 'during' the survey (first page) info -->
<!-- <xsl:if test="count(/questionnaire/questionnaireInfo[position='during' and administration='self'])>=1">
<fo:block-container xsl:use-attribute-sets="questionnaireInfoBeforeContainer">
<xsl:for-each select="/questionnaire/questionnaireInfo[position='during' and administration='self']">
<xsl:call-template name="questionnaireInfoBefore"/>
</xsl:for-each>
</fo:block-container>
</xsl:if>-->
</xsl:template>
<!-- template for images -->
<xsl:template match="//image">
<fo:block>
<fo:external-graphic>
<!--<xsl:attribute name ="content-height"><xsl:value-of select="@height"/></xsl:attribute>-->
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</xsl:template>
<!-- template for text -->
<xsl:template match="//text/bold">
<fo:inline font-weight="bold">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="//text[@indent='true']">
<fo:block margin-left="3mm">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="//text[(@indent = 'false' or not(@indent)) and (@title = 'false' or not(@title))]">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="//text[(@indent = 'false' or not(@indent)) and (@title = 'false' or not(@title))]" mode="information_symbol">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- The Front Page -->
<xsl:template name="coverpage">
<!-- The page title -->
<fo:block-container xsl:use-attribute-sets="titleContainer">
<fo:block xsl:use-attribute-sets="titleFont">
<xsl:value-of select="/questionnaire/title"/>
</fo:block>
</fo:block-container>
<xsl:if test="$logo != 'false'">
<!-- The Main logo - this can be FIXED POSITION -->
<fo:block-container xsl:use-attribute-sets="logoContainer">
<fo:block>
<fo:external-graphic
content-height="25mm">
<xsl:attribute name="src"><xsl:value-of select="$logo"/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:block-container>
</xsl:if>
<!-- Another logo -->
<xsl:if test="$logo2 != 'false'">
<fo:block-container xsl:use-attribute-sets="logo2Container">
<fo:block>
<fo:external-graphic
content-height="25mm">
<xsl:attribute name="src"><xsl:value-of select="$logo2"/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:block-container>
</xsl:if>
<!-- The data collector organisation -->
<fo:block-container xsl:use-attribute-sets="organisationContainer">
<fo:block xsl:use-attribute-sets="organisationFont">
Deakin Computer Assisted Research Facility DCARF
</fo:block>
</fo:block-container>
<!-- The return box -->
<fo:block-container xsl:use-attribute-sets="returnContainer">
<fo:block xsl:use-attribute-sets="returnHeadingFont">
Return
</fo:block>
<fo:block xsl:use-attribute-sets="returnFont">
Please return your completed questionnaire to:
</fo:block>
<fo:block xsl:use-attribute-sets="returnFont" margin-top="8mm">
<xsl:value-of select="/questionnaire/dataCollector/name/salutation"/><xsl:text> </xsl:text>
<xsl:value-of select="/questionnaire/dataCollector/name/firstName"/><xsl:text> </xsl:text>
<xsl:value-of select="/questionnaire/dataCollector/name/lastName"/>
</fo:block>
<fo:block xsl:use-attribute-sets="returnFont">
<xsl:value-of select="/questionnaire/dataCollector/organisation"/>
</fo:block>
<fo:block xsl:use-attribute-sets="returnFont">
<xsl:value-of select="/questionnaire/dataCollector/address/street"/>
</fo:block>
<fo:block xsl:use-attribute-sets="returnFont">
<xsl:value-of select="/questionnaire/dataCollector/address/suburb"/><xsl:text> </xsl:text>
<xsl:value-of select="/questionnaire/dataCollector/address/postcode"/><xsl:text> </xsl:text>
<xsl:value-of select="/questionnaire/dataCollector/address/country"/>
</fo:block>
</fo:block-container>
<!-- Optional web link -->
<xsl:if test="count(/questionnaire/investigator/website)=1">
<fo:block-container xsl:use-attribute-sets="webContainer">
<fo:block xsl:use-attribute-sets="webHeadingFont">
Optional Web Completion
</fo:block>
<fo:block xsl:use-attribute-sets="webFont">
If you would prefer to complete this questionnaire online
</fo:block>
<fo:block xsl:use-attribute-sets="webFont">
please go to the following website:
</fo:block>
<fo:block xsl:use-attribute-sets="webFont" margin-top="8mm">
<xsl:value-of select="/questionnaire/investigator/website"/><xsl:text> </xsl:text>
</fo:block>
</fo:block-container>
</xsl:if>
<fo:block-container xsl:use-attribute-sets="instructionsContainer">
<fo:block xsl:use-attribute-sets="instructionsHeadingFont">
Instructions
</fo:block>
<fo:block xsl:use-attribute-sets="instructionsFont">
Please cross the single most appropriate box like this: <xsl:call-template name="drawboxcrossed"/>
</fo:block>
</fo:block-container>
<!-- temporary images on front page -->
<!--
<fo:block-container top="190mm" left="25mm" absolute-position="fixed" width="150mm">
<fo:block>
<fo:table inline-progression-dimension="100%" table-layout="fixed">
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="center"><fo:block><fo:external-graphic content-height="25mm" src="url(file://mnt/iss/tmp/walk.png)"/></fo:block></fo:table-cell>
<fo:table-cell text-align="center"><fo:block><fo:external-graphic content-height="25mm" src="url(file://mnt/iss/tmp/crossing.png)"/></fo:block></fo:table-cell>
<fo:table-cell text-align="center"><fo:block><fo:external-graphic content-height="25mm" src="url(file://mnt/iss/tmp/drive.png)"/></fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:block-container>
-->
<xsl:if test="count(/questionnaire/investigator/phoneNumber)>=1">
<!-- The help box -->
<fo:block-container xsl:use-attribute-sets="helpContainer">
<fo:block xsl:use-attribute-sets="helpHeadingFont">
Help Available
</fo:block>
<fo:block xsl:use-attribute-sets="helpFont">
If you need any help to answer the questions
</fo:block>
<fo:block xsl:use-attribute-sets="helpFont">
please phone:
</fo:block>
<fo:block xsl:use-attribute-sets="helpFont" margin-top="8mm">
<xsl:value-of select="/questionnaire/investigator/name/salutation"/><xsl:text> </xsl:text>
<xsl:value-of select="/questionnaire/investigator/name/firstName"/><xsl:text> </xsl:text>
<xsl:value-of select="/questionnaire/investigator/name/lastName"/>
</fo:block>
<fo:block xsl:use-attribute-sets="helpFont">
<xsl:value-of select="/questionnaire/investigator/phoneNumber"/>
</fo:block>
</fo:block-container>
</xsl:if>
</xsl:template>
<!-- For each section ... -->
<xsl:template name="sections">
<!-- start of the survey info -->
<xsl:if test="count(/questionnaire/questionnaireInfo[position='before' and administration='self'])>=1">
<fo:block-container xsl:use-attribute-sets="questionnaireInfoAfterContainer">
<xsl:for-each select="/questionnaire/questionnaireInfo[position='before' and administration='self']">
<xsl:call-template name="questionnaireInfoAfter"/>
</xsl:for-each>
</fo:block-container>
</xsl:if>
<xsl:apply-templates select="/questionnaire/section[@last = 'false' or not(@last)]"/>
<!-- end of the survey info -->
<xsl:if test="count(/questionnaire/questionnaireInfo[position='after' and administration='self'])>=1">
<fo:block-container xsl:use-attribute-sets="questionnaireInfoAfterContainer">
<xsl:for-each select="/questionnaire/questionnaireInfo[position='after' and administration='self']">
<xsl:call-template name="questionnaireInfoAfter"/>
</xsl:for-each>
</fo:block-container>
</xsl:if>
<!-- If this is the "last" section, then put it on a new page -->
<xsl:if test="count(questionnaire/section[@last = 'true'])>0">
<fo:block-container break-before="page">
<xsl:apply-templates select="/questionnaire/section[@last = 'true']"/>
</fo:block-container>
</xsl:if>
<!-- appendix - on a new page too -->
<xsl:if test="count(questionnaire/questionnaireInfo[position='appendix'])>=1">
<fo:block-container break-before="page">
<xsl:apply-templates select="/questionnaire/questionnaireInfo[position='appendix']"/>
</fo:block-container>
</xsl:if>
</xsl:template>
<!-- Draw up a box with the questionnaire info text centered -->
<xsl:template name="questionnaireInfoAfter">
<fo:block xsl:use-attribute-sets="questionnaireInfoAfterFont">
<xsl:apply-templates select="image"/>
<xsl:apply-templates select="text"/>
</fo:block>
</xsl:template>
<!-- Draw up a box with the questionnaire info text centered -->
<xsl:template name="questionnaireInfoBefore">
<xsl:apply-templates select="image"/>
<fo:block xsl:use-attribute-sets="questionnaireInfoBeforeFont">
<xsl:apply-templates select="text"/>
</fo:block>
</xsl:template>
<xsl:template match="/questionnaire/questionnaireInfo/text[@title='true']">
<fo:block-container xsl:use-attribute-sets="section_info_beforeContainer">
<fo:block xsl:use-attribute-sets="section_info_beforeFont">
<xsl:value-of select="."/>
</fo:block>
</fo:block-container>
</xsl:template>
<xsl:template match="/questionnaire/questionnaireInfo[position='appendix']">
<fo:block-container xsl:use-attribute-sets="sectionContainer">
<fo:block xsl:use-attribute-sets="sectionFont sectiontextContainer">
<!-- Show the appendix title -->
Appendix <xsl:value-of select="position()"/>
</fo:block>
<xsl:apply-templates select="text[@title='true']"/>
</fo:block-container>
<fo:block xsl:use-attribute-sets="questionnaireInfoAppendixFont">
<xsl:apply-templates select="text[@title='false' or not(@title)]"/>
</fo:block>
</xsl:template>
<!-- In each section... -->
<xsl:template match="/questionnaire/section">
<!-- This must be terminated by the first question in the section so that the section
and the first question will always remain on the same page -->
<fo:block-container xsl:use-attribute-sets="firstQuestionContainer">
<fo:block-container xsl:use-attribute-sets="sectionContainer">
<fo:block xsl:use-attribute-sets="sectionFont sectiontextContainer">
<!-- This is an option not to display the section title -->
<xsl:if test="$show_section_title='true'">
Section <xsl:number count="section" level="any" format="A"/>
</xsl:if>
<xsl:for-each select="sectionInfo[position='title' and administration='self']">
<xsl:call-template name="sectionInfoTitle"/>
</xsl:for-each>
</fo:block>
<xsl:for-each select="sectionInfo">
<xsl:choose>
<xsl:when test="position='before' and administration='self'">
<xsl:call-template name="sectionInfoBefore"/>
</xsl:when>
<xsl:when test="position='during' and administration='self'">
<xsl:call-template name="sectionInfoDuring"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</fo:block-container>
<xsl:apply-templates select="question[position()=1]"/>
</fo:block-container>
<xsl:apply-templates select="question[position()>1]"/>
<xsl:for-each select="sectionInfo[position='after' and administration='self']">
<xsl:call-template name="sectionInfoAfter"/>
</xsl:for-each>
</xsl:template>
<!-- Draws the question qualifier (inline) -->
<xsl:template match="/questionnaire/section/question/qualifier">
<fo:inline xsl:use-attribute-sets="questionQualifierFont">
<xsl:value-of select="."/>
</fo:inline>
</xsl:template>
<!-- Draws the question specifier (new block) -->
<xsl:template match="/questionnaire/section/question/specifier">
<!--<fo:block-container xsl:use-attribute-sets="questionTextContainer">-->
<fo:block xsl:use-attribute-sets="questionSpecifierFont">
<fo:external-graphic content-height="3mm" src="url(file://mnt/iss/quexml/information.svg)"/>
<xsl:value-of select="."/>
</fo:block>
<!--</fo:block-container>-->
</xsl:template>
<!-- Draws the question information -->
<xsl:template match="/questionnaire/section/question">
<fo:block-container xsl:use-attribute-sets="questionContainer">
<!-- If there is a before directive -->
<xsl:for-each select="directive[position = 'before' and administration = 'self']">
<fo:block xsl:use-attribute-sets="directive_beforeFont">
<xsl:choose>
<xsl:when test="$show_information_symbol='true'">
<xsl:apply-templates select="text" mode="information_symbol"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="text"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</xsl:for-each>
<!-- The question text in a "list" -->
<fo:block xsl:use-attribute-sets="questionTextContainer">
<!-- If there is a skip to this question, then the font should be bigger -->
<fo:list-block provisional-label-separation="2mm" provisional-distance-between-starts="11mm">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<!-- This is an option not to display the section number-->
<xsl:if test="$show_section_number='true'">
<fo:block xsl:use-attribute-sets="questionNumberFont">
<xsl:if test="$show_question_letter='true'">
<xsl:number count="section" level="any" format="A"/>
</xsl:if>
<xsl:number count="question" level="single" format="1. "/>
</fo:block>
</xsl:if>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()" end-indent="45mm">
<xsl:for-each select="text">
<fo:block xsl:use-attribute-sets="questionFont">
<xsl:value-of select="."/>
<xsl:if test="position() = last()">
<xsl:apply-templates select="../qualifier"/>
</xsl:if>
</fo:block>
</xsl:for-each>
<!-- If there is a specifier -->
<xsl:apply-templates select="specifier"/>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
<!-- If there is a during directive -->
<xsl:for-each select="directive[position = 'during' and administration = 'self']">
<fo:block xsl:use-attribute-sets="directive_duringFont">
<xsl:choose>
<xsl:when test="$show_information_symbol='true'">
<xsl:apply-templates select="text" mode="information_symbol"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="text"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</xsl:for-each>
<!-- The response choices - matrix, fixed or free -->
<xsl:choose>
<xsl:when test="count(subQuestion)>=1 and count(response/fixed)>=1">
<!-- matrix -->
<xsl:choose>
<xsl:when test="response/fixed/@rotate='true'">
<xsl:call-template name="matrixRotate"/>
</xsl:when>
<xsl:when test="count(response/fixed/category)>=15">
<xsl:call-template name="matrixRotate"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="matrix"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="count(subQuestion)>=1 and count(response/free)>=1">
<!-- matrix of free -->
<xsl:call-template name="matrixFree"/>
</xsl:when>
<xsl:when test="count(subQuestion)>=1 and count(response/vas)>=1">
<!-- matrix of VAS -->
<xsl:call-template name="matrixvas"/>
</xsl:when>
<xsl:when test="count(subQuestion)=0">
<!-- non matrix - apply normal response template -->
<xsl:apply-templates select="response"/>
</xsl:when>
</xsl:choose>
<!-- If there is an after directive -->
<xsl:for-each select="directive[position = 'after' and administration = 'self']">
<fo:block xsl:use-attribute-sets="directive_afterFont">
<xsl:choose>
<xsl:when test="$show_information_symbol='true'">
<xsl:apply-templates select="text" mode="information_symbol"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="text"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</xsl:for-each>
</fo:block-container>
</xsl:template>
<!-- Handles responses -->
<xsl:template match="/questionnaire/section/question/response">
<!-- apply either the free or fixed response template -->
<xsl:choose>
<xsl:when test="$show_variables = 'true'">
<fo:block-container xsl:use-attribute-sets="responseContainer"
border="solid"
border-width="1mm">
<fo:block>
<xsl:value-of select="@varName"/>
</fo:block>
<xsl:choose>
<xsl:when test="count(free)=1">
<xsl:apply-templates select="free"/>
</xsl:when>
<xsl:when test="count(fixed)=1">
<xsl:apply-templates select="fixed"/>
</xsl:when>
</xsl:choose>
</fo:block-container>
</xsl:when>
<xsl:otherwise>
<fo:block-container xsl:use-attribute-sets="responseContainer">
<xsl:choose>
<xsl:when test="count(free)=1">
<xsl:apply-templates select="free"/>
</xsl:when>
<xsl:when test="count(fixed)=1">
<xsl:apply-templates select="fixed"/>
</xsl:when>
<xsl:when test="count(vas)=1">
<xsl:apply-templates select="vas"/>
</xsl:when>
<xsl:when test="count(dvas)=1">
<xsl:apply-templates select="dvas"/>
</xsl:when>
</xsl:choose>
</fo:block-container>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Handle fixed responses that are not rotated-->
<xsl:template match="/questionnaire/section/question/response/fixed[@rotate = 'false' or not(@rotate)]">
<!-- Draw a vertical table of category labels and response boxes -->
<fo:table inline-progression-dimension="100%" table-layout="fixed" width="100%">
<xsl:choose>
<xsl:when test="$leftalign = 'false'">
<fo:table-column column-width="proportional-column-width(1)"/> <!-- for the text -->
<fo:table-column xsl:use-attribute-sets="fixedResponseColumn"/> <!-- for the response boxes -->
<fo:table-column xsl:use-attribute-sets="skipColumn"/> <!-- for the empty space after -->
</xsl:when>
<xsl:otherwise>
<fo:table-column xsl:use-attribute-sets="skipColumn"/>
<fo:table-column xsl:use-attribute-sets="fixedResponseColumn"/>
<fo:table-column column-width="proportional-column-width(1)"/> <!-- for the text -->
</xsl:otherwise>
</xsl:choose>
<fo:table-body>
<xsl:for-each select="category">
<fo:table-row xsl:use-attribute-sets="tableRow">
<xsl:choose>
<xsl:when test="$leftalign = 'false'">
<fo:table-cell padding="0">
<fo:block-container xsl:use-attribute-sets="category_labelContainer">
<xsl:apply-templates select="image"/>
<fo:block xsl:use-attribute-sets="category_labelFont">
<xsl:value-of select="label"/>
</fo:block>
</fo:block-container>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<!-- If there is a question to skip to -->
<xsl:choose>
<xsl:when test="count(skipTo)=1">
<fo:table-cell>
<xsl:call-template name="drawSkipTo">
<xsl:with-param name="variableName" select="skipTo"/>
</xsl:call-template>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell><fo:block> </fo:block></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<fo:table-cell padding="0">
<fo:block-container xsl:use-attribute-sets="category_boxContainer">
<fo:block>
<xsl:choose>
<xsl:when test="(position()=1 and position()=last()) and (count(contingentQuestion)=1)">
<xsl:call-template name="drawboxarrowbottom"/>
</xsl:when>
<xsl:when test="position()=1 and position()=last()">
<xsl:call-template name="drawbox"/>
</xsl:when>
<xsl:when test="position()=1">
<xsl:call-template name="drawboxlinebottom"/>
</xsl:when>
<xsl:when test="(position()=last()) and (count(contingentQuestion)=1)">
<xsl:call-template name="drawboxlinetoparrowbottom"/>
</xsl:when>
<xsl:when test="position()=last()">
<xsl:call-template name="drawboxlinetop"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="drawboxlinevertical"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:block-container>
</fo:table-cell>
<xsl:choose>
<xsl:when test="$leftalign = 'false'">
<!-- If there is a question to skip to -->
<xsl:choose>
<xsl:when test="count(skipTo)=1">
<fo:table-cell>
<xsl:call-template name="drawSkipTo">
<xsl:with-param name="variableName" select="skipTo"/>
</xsl:call-template>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell><fo:block> </fo:block></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:table-cell padding="0">
<fo:block-container xsl:use-attribute-sets="category_labelContainer">
<xsl:apply-templates select="image"/>
<fo:block xsl:use-attribute-sets="category_labelFont">
<xsl:value-of select="label"/>
</fo:block>
</fo:block-container>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
<!-- Check for contingent questions -->
<xsl:apply-templates select="category/contingentQuestion"/>
</xsl:template>
<!-- Handle fixed responses that ARE rotated-->
<xsl:template match="/questionnaire/section/question/response/fixed[@rotate = 'true']">
<!-- Draw a HORIZONTAL table of category labels and response boxes -->
<fo:table inline-progression-dimension="100%" table-layout="fixed" table-omit-header-at-break="false" width="100%">
<xsl:choose>
<xsl:when test="$leftalign = 'false'">
<fo:table-column column-width="proportional-column-width(1)"/> <!-- the empty cell -->
<xsl:choose>
<xsl:when test="count(category)>10">
<xsl:for-each select="category">
<fo:table-column column-width="11mm"/>
</xsl:for-each>
<fo:table-column xsl:use-attribute-sets="skipColumn"/> <!-- The empty space cell for skips -->
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="category">
<fo:table-column xsl:use-attribute-sets="matrixResponseColumn"/>
</xsl:for-each>
<fo:table-column xsl:use-attribute-sets="matrixSkipColumn"/> <!-- The empty space cell for skips -->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:table-column xsl:use-attribute-sets="matrixSkipColumn"/> <!-- The empty space cell for skips -->
<xsl:for-each select="category">
<fo:table-column xsl:use-attribute-sets="matrixResponseColumn"/>
</xsl:for-each>
<fo:table-column column-width="proportional-column-width(1)"/> <!-- the empty cell -->
</xsl:otherwise>
</xsl:choose>
<fo:table-header>
<fo:table-row>
<fo:table-cell><fo:block> </fo:block></fo:table-cell> <!-- the empty corner cell -->
<!-- draw in the category labels -->
<xsl:for-each select="category">
<fo:table-cell>
<fo:block-container xsl:use-attribute-sets="labelContainer">
<xsl:apply-templates select="image"/>
<fo:block xsl:use-attribute-sets="labelFont">
<xsl:value-of select="label"/>
</fo:block>
</fo:block-container>
</fo:table-cell>
</xsl:for-each>
<fo:table-cell><fo:block> </fo:block></fo:table-cell> <!-- the empty corner cell -->
</fo:table-row>
</fo:table-header>
<fo:table-body>
<!-- Now draw the response boxes-->
<fo:table-row xsl:use-attribute-sets="tableRow">
<xsl:choose>
<xsl:when test="$leftalign = 'false'">
<fo:table-cell><fo:block> </fo:block></fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell><fo:block> </fo:block></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<!-- When there is only one category - no lines are needed -->
<xsl:choose>
<xsl:when test="count(category)=1">
<!-- Draw the response boxes -->
<xsl:for-each select="category">
<fo:table-cell>
<fo:block xsl:use-attribute-sets="subquestionboxContainer">
<xsl:call-template name="drawbox"/>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</xsl:when>
<xsl:when test="count(category)>10">
<!-- Draw the response boxes -->
<xsl:for-each select="category">
<fo:table-cell>
<fo:block xsl:use-attribute-sets="subquestionboxContainer">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:call-template name="drawboxlineaftershort"/>
</xsl:when>
<!--<xsl:when test="(position()=last()) and (count(contingentQuestion)=1)">
<xsl:call-template name="drawboxarrowbottom"/>
</xsl:when>-->
<xsl:when test="position()=last()">
<xsl:call-template name="drawboxlinebeforeshort"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="drawboxlineshort"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!-- Draw the response boxes -->
<xsl:for-each select="category">
<fo:table-cell>
<fo:block xsl:use-attribute-sets="subquestionboxContainer">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:call-template name="drawboxlineafter"/>
</xsl:when>
<!--<xsl:when test="(position()=last()) and (count(contingentQuestion)=1)">
<xsl:call-template name="drawboxarrowbottom"/>
</xsl:when>-->
<xsl:when test="position()=last()">
<xsl:call-template name="drawboxlinebefore"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="drawboxline"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$leftalign = 'false'">
<fo:table-cell><fo:block> </fo:block></fo:table-cell>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
<!-- Loop template (recursive loop) for free response length -->
<xsl:template name="drawFreeResponseLoop">
<xsl:param name="repeat">0</xsl:param>
<xsl:param name="last">0</xsl:param>
<xsl:param name="format">none</xsl:param>
<xsl:if test="number($repeat) >= 1">
<!-- Draw a delimiter box in a table cell -->
<fo:table-cell >
<fo:block xsl:use-attribute-sets="category_labelContainer">
<!-- If this is the first ...etc-->
<xsl:choose>
<xsl:when test="$repeat=$last and $repeat = 1">
<xsl:call-template name="drawDelimiterSingle"/>
</xsl:when>
<xsl:when test="$repeat=1">
<xsl:call-template name="drawDelimiterAfter"/>
</xsl:when>
<xsl:when test="$repeat=$last">
<xsl:call-template name="drawDelimiterBefore"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$format = 'currency' and (($repeat mod 3) = 0)">
<xsl:call-template name="drawDelimiterMiddleComma"/>