Ticket #217: participant_list_2.ptl.xsl

File participant_list_2.ptl.xsl, 7.6 KB (added by Roberto Adinolfi, 10 years ago)
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
4<!--
5
6****************************************************************************************
7Participant list template 2.0 by SCDBob
8
9Changelog:
10-center align for competition name and title
11-added row number column (first column in the table)
12-added new param "print_all_custom_pilot_attribute": when 1 (default) prints all custom pilot attribute; when 0 prints only FS default pilot attribute
13-added a generic colum "note"
14-table width 100%
15-code cleaning
16
17*****************************************************************************************
18
19 -->
20
21  <!--  To see the input used for this xslt, check the "Create source.xml file
22        when creating report" menu item under the "Reports" menu in FsComp.
23        When checked a .source.xml file is created each time you create a report.
24        It shows the actual xml input to the xslt processor.
25        This is helpfull if you like to modify this file.
26  -->
27
28  <xsl:output method="html" encoding="utf-8" indent="yes" />
29
30  <!--  Set the decimal separator to be used (. or ,) when decimal data is displayed.
31        All decimal data in the source is with . and will be displayed with . unless
32        formated otherwise using format-number() function.
33  -->
34  <xsl:variable name="decimal_separator" select="','"/>
35  <xsl:decimal-format decimal-separator=',' grouping-separator=' ' />
36  <!-- note! make sure both above use same, ie either . or ,!! -->
37
38  <!--  All <xsl:param ... elements will show as a field in a report dialog in
39        FS when creating reports. This means you can define param elements here
40        with a default value and set the value from FS when creating report.
41        Some is used simply to display text at the top of the report (ie status),
42        others is used to filter the results (ie women_only, nation, ...).
43        If you add filter params you must of course also change the "filter"
44        definition below so that the filter params is applied.
45  -->
46  <xsl:param name="Heading">Pilot List</xsl:param>
47  <!-- filter params -->
48  <!-- sort_on possible values: name, id, CIVLID -->
49  <xsl:param name="sort_on">id</xsl:param>
50 
51  <xsl:param name="women_only">0</xsl:param>
52  <xsl:param name="nation"></xsl:param>
53  <xsl:param name="custom_pilot_attribute_name"></xsl:param>
54  <xsl:param name="custom_pilot_attribute_value"></xsl:param>
55  <xsl:param name="print_all_custom_pilot_attribute">1</xsl:param>
56
57  <!--  The node-set that this variable returns is what is used
58        to create the result list.
59        Here some of the params above is used.
60  -->
61  <xsl:variable name="filter" select="
62      /Fs/FsCompetition/FsParticipants/FsParticipant[
63        ($women_only=0 or @female=1)
64        and ($nation='' or @nat_code_3166_a3=$nation)
65        and ($custom_pilot_attribute_name='' or
66          FsCustomAttributes/FsCustomAttribute/@name=$custom_pilot_attribute_name
67          and FsCustomAttributes/FsCustomAttribute/@value=$custom_pilot_attribute_value)
68      ]
69    "/>
70
71  <!-- record template, used for each pilot in the ranked list of pilots -->
72  <xsl:template name="record">
73        <xsl:variable name="pilot_id" select="@id"/>
74    <tr>
75          <td style="text-align:right">
76                <xsl:value-of select="position()"/>
77          </td>
78      <td>
79        <xsl:value-of select="@id"/>
80      </td>
81      <td>
82        <xsl:value-of select="@CIVLID"/>
83      </td>
84      <td>
85        <xsl:value-of select="@name"/>
86      </td>
87      <td>
88        <xsl:choose>
89          <xsl:when test="@female=1">F</xsl:when>
90          <xsl:otherwise>M</xsl:otherwise>
91        </xsl:choose>
92      </td>
93      <td>
94        <xsl:value-of select="@nat_code_3166_a3"/>
95      </td>
96      <td>
97        <xsl:value-of select="@glider"/>
98      </td>
99      <td>
100        <xsl:value-of select="@sponsor"/>
101      </td>
102          <xsl:if test="$print_all_custom_pilot_attribute=1">
103          <xsl:for-each select="/Fs/FsCompetition[1]/FsParticipants[1]/FsParticipant[@id=$pilot_id]/FsCustomAttributes/FsCustomAttribute">
104                <td>
105                        <xsl:value-of select="@value"/>
106                </td>
107          </xsl:for-each>
108          </xsl:if>
109      <td>
110        <xsl:text>&#160;</xsl:text>
111      </td>
112    </tr>
113  </xsl:template>
114
115  <xsl:template match="/">
116    <html>
117      <head>
118        <style>
119          tr:hover {background: yellow;}
120          body {
121          font-family: Verdana, Arial, Helvetica, sans-serif;
122          font-size: xx-small;
123          }
124          table
125          {
126          border:solid 1px gray;
127          border-collapse:collapse;
128          font-size: xx-small;
129          }
130          td
131          {
132          border:solid 1px gray;
133          vertical-align:top;
134          padding:5px;
135          }
136          th
137          {
138          border:solid 1px gray;
139          vertical-align:center;
140          }
141        </style>
142      </head>
143      <body>
144        <div style="width:100%;font-size: xx-small;text-align:right;" >
145          <i>
146            Report created: <xsl:value-of select="/Fs/FsCompetition/FsParticipants/@ts"/>
147          </i>
148        </div>
149               
150                <div style="width:100%;text-align:center;">
151        <h1>
152          <xsl:value-of select="/Fs/FsCompetition/@name"/>
153        </h1>
154        <p style="font-size:xx-small">
155          <xsl:value-of select="/Fs/FsCompetition/@from"/> to <xsl:value-of select="/Fs/FsCompetition/@to"/>
156        </p>
157        <h2>
158          <xsl:value-of select="$Heading"/>
159        </h2>
160                </div>
161        <br/>
162        <table style="width:100%;white-space:nowrap;">
163          <thead>
164            <tr>
165                          <th>#</th>
166              <th>Id</th>
167              <th>CIVLID</th>
168              <th>Name</th>
169              <th></th>
170              <th>Nat</th>
171              <th>Glider</th>
172              <th>Sponsor</th>
173                         
174                          <xsl:if test="$print_all_custom_pilot_attribute=1">
175                           <xsl:for-each select="/Fs/FsCompetition[1]/FsParticipants[1]/FsParticipant[1]/FsCustomAttributes/FsCustomAttribute">
176                                <th><xsl:value-of select="@name"/></th>
177              </xsl:for-each>
178                          </xsl:if>
179                         
180              <th style="width:100%">Note</th>
181            </tr>
182          </thead>
183          <!-- for each participant sorted on name -->
184          <xsl:choose>
185            <xsl:when test="$sort_on = 'id' or $sort_on = 'Id' or $sort_on = 'ID'">
186              <xsl:for-each select="$filter">
187                <xsl:sort select="@id" data-type="number" order="ascending"/>
188                <!-- participant rows -->
189                <xsl:call-template name="record" />
190              </xsl:for-each>
191            </xsl:when>
192            <xsl:when test="$sort_on = 'CIVLID' or $sort_on = 'civlid' or $sort_on = 'Civlid'">
193              <xsl:for-each select="$filter">
194                <xsl:sort select="@CIVLID" data-type="number" order="ascending"/>
195                <!-- participant rows -->
196                <xsl:call-template name="record"/>
197              </xsl:for-each>
198            </xsl:when>
199            <xsl:otherwise>
200              <xsl:for-each select="$filter">
201                <xsl:sort select="@name" data-type="text" order="ascending"/>
202                <!-- participant rows -->
203                <xsl:call-template name="record"/>
204              </xsl:for-each>
205            </xsl:otherwise>
206          </xsl:choose>
207        </table>
208                <p>
209                        <div style="text-align:center; font-size:xxxx-small;">
210                                Competition scored with <a href="http://fs.fai.org/">FS</a><br/>
211                                Template powered by SCDBob
212                        </div>
213                </p>
214      </body>
215    </html>
216  </xsl:template>
217</xsl:stylesheet>