source: sasview/src/sas/sasview/test/1d_data/cansas1d.xsl @ e6d309c

magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249unittest-saveload
Last change on this file since e6d309c was e6d309c, checked in by smk78, 6 years ago

Add example 1d data with dQ to \test\1d_data

  • Property mode set to 100644
File size: 14.7 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4########### SVN repository information ###################
5# $Date$
6# $Author$
7# $Revision$
8# $HeadURL$
9# $Id$
10########### SVN repository information ###################
11
12Purpose:
13        This stylesheet is used to translate cansas1d:1.1
14        XML data files into a display form for viewing
15        in a web browser such as Firefox or Internet Explorer
16        that supports client-side XSLT formatting.
17
18Usage:
19        xsltproc cansas1d.xsl datafile.xml > datafile.html
20        (or include it as indicated at the documentation site
21        http://www.cansas.org/wgwiki/index.php/cansas1d_documentation)
22
23Copyright (c) 2013, UChicago Argonne, LLC
24This file is distributed subject to a Software License Agreement found
25in the file LICENSE that is included with this distribution.
26-->
27
28<xsl:stylesheet version="1.1"
29        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
30        xmlns:cs="urn:cansas1d:1.1"
31        xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
32        >
33
34        <xsl:template match="/">
35<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->
36                <html>
37                        <head>
38                                <title>SAS data in canSAS 1-D format</title>
39                        </head>
40                        <body>
41                                <h1>SAS data in canSAS 1-D format</h1>
42                                <small>generated using <TT>cansas1d.xsl</TT> from canSAS</small>
43                                <BR />
44                                <table border="2">
45                                        <tr>
46                                                <th bgcolor="lavender">canSAS 1-D XML version:</th>
47                                                <td><xsl:value-of select="cs:SASroot/@version" /></td>
48                                        </tr>
49                                        <tr>
50                                                <th bgcolor="lavender">number of entries:</th>
51                                                <td><xsl:value-of select="count(cs:SASroot/cs:SASentry)" /></td>
52                                        </tr>
53                                        <xsl:if test="count(/cs:SASroot//cs:SASentry)>1">
54                                                <!-- if more than one SASentry, make a table of contents -->
55                                                <xsl:for-each select="/cs:SASroot//cs:SASentry">
56                                                        <tr>
57                                                                <th bgcolor="lavender">SASentry-<xsl:value-of select="position()" /></th>
58                                                                <td>
59                                                                        <a href="#SASentry-{generate-id(.)}">
60                                                                                <xsl:if test="@name!=''">(<xsl:value-of select="@name" />)</xsl:if>
61                                                                                <xsl:value-of select="cs:Title" />
62                                                                        </a>
63                                                                </td>
64                                                                <xsl:if test="count(cs:SASdata)>1">
65                                                                        <td>
66                                                                                <!-- if more than one SASdata, make a local table of contents -->
67                                                                                <xsl:for-each select="cs:SASdata">
68                                                                                        <xsl:if test="position()>1">
69                                                                                                <xsl:text> | </xsl:text>
70                                                                                        </xsl:if>
71                                                                                        <a href="#SASdata-{generate-id(.)}">
72                                                                                                <xsl:choose>
73                                                                                                        <xsl:when test="cs:name!=''">
74                                                                                                                <xsl:value-of select="cs:name" />
75                                                                                                        </xsl:when>
76                                                                                                        <xsl:when test="@name!=''">
77                                                                                                                <xsl:value-of select="@name" />
78                                                                                                        </xsl:when>
79                                                                                                        <xsl:otherwise>
80                                                                                                                SASdata<xsl:value-of select="position()" />
81                                                                                                        </xsl:otherwise>
82                                                                                                </xsl:choose>
83                                                                                        </a>
84                                                                                </xsl:for-each>
85                                                                        </td>
86                                                                </xsl:if>
87                                                        </tr>
88                                                </xsl:for-each>
89                                        </xsl:if>
90                                </table>
91                                <xsl:apply-templates  />
92                                <hr />
93                                <small><center>$Id$</center></small>
94                        </body>
95                </html>
96        </xsl:template>
97
98        <xsl:template match="cs:SASroot">
99                <xsl:for-each select="cs:SASentry">
100                        <hr />
101                        <br />
102                        <a id="#SASentry-{generate-id(.)}"  name="SASentry-{generate-id(.)}" />
103                        <h1>SASentry<xsl:value-of select="position()" />:<xsl:if 
104                                test="@name!=''">(<xsl:value-of select="@name" />)</xsl:if>
105                                <xsl:value-of select="cs:Title" /></h1>
106                        <xsl:if test="count(cs:SASdata)>1">
107                                <table border="2">
108                                        <caption>SASdata contents</caption>
109                                        <xsl:for-each select="cs:SASdata">
110                                                <tr>
111                                                        <th>SASdata-<xsl:value-of select="position()" /></th>
112                                                        <td>
113                                                                <a href="#SASdata-{generate-id(.)}">
114                                                                        <xsl:choose>
115                                                                        <xsl:when test="@name!=''">
116                                                                                        <xsl:value-of select="@name" />
117                                                                                </xsl:when>
118                                                                                <xsl:otherwise>
119                                                                                        SASdata<xsl:value-of select="position()" />
120                                                                                </xsl:otherwise>
121                                                                        </xsl:choose>
122                                                                </a>
123                                                        </td>
124                                                </tr>
125                                        </xsl:for-each>
126                                </table>
127                        </xsl:if>
128                        <br />
129                        <table border="2">
130                                <tr>
131                                        <th>SAS data</th>
132                                        <xsl:for-each select="cs:SAStransmission_spectrum"><th>transmission spectrum: <xsl:value-of select="@name" /></th></xsl:for-each>
133                                        <th>Selected Metadata</th>
134                                </tr>
135                                <tr>
136                                        <td valign="top"><xsl:apply-templates  select="cs:SASdata" /></td>
137                                        <xsl:apply-templates  select="cs:SAStransmission_spectrum" />
138                                        <td valign="top">
139                                                <table border="2">
140                                                        <tr bgcolor="lavender">
141                                                                <th>name</th>
142                                                                <th>value</th>
143                                                                <th>unit</th>
144                                                        </tr>
145                                                        <tr>
146                                                                <td>Title</td>
147                                                                <td><xsl:value-of select="cs:Title" /></td>
148                                                                <td />
149                                                        </tr>
150                                                        <tr>
151                                                                <td>Run</td>
152                                                                <td><xsl:value-of select="cs:Run" /></td>
153                                                                <td />
154                                                        </tr>
155                                                        <tr><xsl:apply-templates  select="run" /></tr>
156                                                        <xsl:apply-templates  select="cs:SASsample" />
157                                                        <xsl:apply-templates  select="cs:SASinstrument" />
158                                                        <xsl:apply-templates  select="cs:SASprocess" />
159                                                        <xsl:apply-templates  select="cs:SASnote" />
160                                                </table>
161                                        </td>
162                                </tr>
163                        </table>
164                </xsl:for-each>
165        </xsl:template>
166
167        <xsl:template match="cs:SAStransmission_spectrum">
168                <td valign="top">
169                    <table border="2">
170                        <caption><xsl:if 
171                                test="@name!=''"><xsl:value-of select="@name" /></xsl:if> (<xsl:value-of 
172                                select="count(cs:Tdata)" /> points)
173                                <a id="#Tdata-{generate-id(.)}"  name="Tdata-{generate-id(.)}" />
174                        </caption>
175                        <tr bgcolor="lavender">
176                                <xsl:for-each select="cs:Tdata[1]/*">
177                                        <th>
178                                                <xsl:value-of select="name()" /> 
179                                                <xsl:if test="@unit!=''"> (<xsl:value-of select="@unit" />)</xsl:if>
180                                        </th>
181                                </xsl:for-each>
182                        </tr>
183                        <xsl:for-each select="cs:Tdata">
184                                        <tr>
185                                                <xsl:for-each select="*">
186                                                        <xsl:call-template name="td-value"/>
187                                                </xsl:for-each>
188                                        </tr>
189                                </xsl:for-each>
190                        </table>
191                </td>
192        </xsl:template>
193
194        <xsl:template match="cs:SASdata">
195                <a id="#SASdata-{generate-id(.)}"  name="SASdata-{generate-id(.)}" />
196                <table border="2">
197                        <caption><xsl:if 
198                                test="@name!=''"><xsl:value-of select="@name" /></xsl:if> (<xsl:value-of 
199                                select="count(cs:Idata)" /> points)</caption>
200                        <tr bgcolor="lavender">
201                                <xsl:for-each select="cs:Idata[1]/*">
202                                        <th>
203                                                <xsl:value-of select="name()" /> 
204                                                <xsl:if test="@unit!=''"> (<xsl:value-of select="@unit" />)</xsl:if>
205                                        </th>
206                                </xsl:for-each>
207                        </tr>
208                        <xsl:for-each select="cs:Idata">
209                                <tr>
210                                        <xsl:for-each select="*">
211                                                <xsl:call-template name="td-value"/>
212                                        </xsl:for-each>
213                                </tr>
214                        </xsl:for-each>
215                </table>
216        </xsl:template>
217
218        <xsl:template match="cs:SASsample">
219                <tr>
220                        <td>SASsample</td>
221                        <td><xsl:value-of select="@name" /></td>
222                        <td />
223                </tr>
224                <xsl:for-each select="*">
225                        <xsl:choose>
226                                <xsl:when test="name()='position'">
227                                        <xsl:apply-templates select="." />
228                                </xsl:when>
229                                <xsl:when test="name()='orientation'">
230                                        <xsl:apply-templates select="." />
231                                </xsl:when>
232                                <xsl:otherwise>
233                                        <xsl:call-template name="tr-parent-value-units"/>
234                                </xsl:otherwise>
235                        </xsl:choose>
236                </xsl:for-each>
237        </xsl:template>
238
239        <xsl:template match="cs:SASinstrument">
240                <tr>
241                        <td>SASinstrument</td>
242                        <td><xsl:value-of select="cs:name" /></td>
243                        <td><xsl:value-of select="@name" /></td>
244                </tr>
245                <xsl:for-each select="*">
246                        <xsl:choose>
247                                <xsl:when test="name()='SASsource'"><xsl:apply-templates select="." /></xsl:when>
248                                <xsl:when test="name()='SAScollimation'"><xsl:apply-templates select="." /></xsl:when>
249                                <xsl:when test="name()='SASdetector'"><xsl:apply-templates select="." /></xsl:when>
250                                <xsl:when test="name()='name'" />
251                                <xsl:otherwise>
252                                        <xsl:call-template name="tr-parent-value-units"/>
253                                </xsl:otherwise>
254                        </xsl:choose>
255                </xsl:for-each>
256        </xsl:template>
257
258        <xsl:template match="cs:SASsource">
259                <tr>
260                        <td><xsl:value-of select="name()" /></td>
261                        <td><xsl:value-of select="@name" /></td>
262                        <td />
263                </tr>
264                <xsl:for-each select="*">
265                        <xsl:choose>
266                                <xsl:when test="name()='beam_size'"><xsl:apply-templates select="." /></xsl:when>
267                                <xsl:otherwise>
268                                        <xsl:call-template name="tr-parent-value-units"/>
269                                </xsl:otherwise>
270                        </xsl:choose>
271                </xsl:for-each>
272        </xsl:template>
273
274        <xsl:template match="cs:beam_size">
275                <xsl:call-template name="tr-parent-name"/>
276                <xsl:for-each select="*">
277                        <xsl:call-template name="tr-grandparent-value-units"/>
278                </xsl:for-each>
279        </xsl:template>
280
281        <xsl:template match="cs:SAScollimation">
282                <xsl:for-each select="*">
283                        <xsl:choose>
284                                <xsl:when test="name()='aperture'"><xsl:apply-templates select="." /></xsl:when>
285                                <xsl:otherwise>
286                                        <xsl:call-template name="tr-parent-value-units"/>
287                                </xsl:otherwise>
288                        </xsl:choose>
289                </xsl:for-each>
290        </xsl:template>
291
292        <xsl:template match="cs:aperture">
293                <tr>
294                        <td><xsl:value-of select="name(..)" />_<xsl:value-of select="name()" /></td>
295                        <td><xsl:value-of select="@name" /></td>
296                        <td><xsl:value-of select="@type" /></td>
297                </tr>
298                <xsl:for-each select="*">
299                        <xsl:choose>
300                                <xsl:when test="name()='size'"><xsl:apply-templates select="." /></xsl:when>
301                                <xsl:otherwise>
302                                        <xsl:call-template name="tr-grandparent-value-units"/>
303                                </xsl:otherwise>
304                        </xsl:choose>
305                </xsl:for-each>
306        </xsl:template>
307
308        <xsl:template match="cs:size">
309                <tr>
310                        <xsl:call-template name="td-grandparent"/>
311                        <td><xsl:value-of select="@name" /></td>
312                        <td />
313                </tr>
314                <xsl:for-each select="*">
315                        <tr>
316                                <xsl:call-template name="td-greatgrandparent"/>
317                                <xsl:call-template name="td-value"/>
318                                <xsl:call-template name="td-unit"/>
319                        </tr>
320                </xsl:for-each>
321        </xsl:template>
322
323        <xsl:template match="cs:SASdetector">
324                <tr>
325                        <td><xsl:value-of select="name()" /></td>
326                        <td><xsl:value-of select="cs:name" /></td>
327                        <td><xsl:value-of select="@name" /></td>
328                </tr>
329                <xsl:for-each select="*">
330                        <xsl:choose>
331                                <xsl:when test="name()='name'" />
332                                <xsl:when test="name()='offset'"><xsl:apply-templates select="." /></xsl:when>
333                                <xsl:when test="name()='orientation'"><xsl:apply-templates select="." /></xsl:when>
334                                <xsl:when test="name()='beam_center'"><xsl:apply-templates select="." /></xsl:when>
335                                <xsl:when test="name()='pixel_size'"><xsl:apply-templates select="." /></xsl:when>
336                                <xsl:otherwise>
337                                        <xsl:call-template name="tr-parent-value-units"/>
338                                </xsl:otherwise>
339                        </xsl:choose>
340                </xsl:for-each>
341        </xsl:template>
342
343        <xsl:template match="cs:orientation">
344                <xsl:call-template name="tr-parent-name"/>
345                <xsl:for-each select="*">
346                        <xsl:call-template name="tr-grandparent-value-units"/>
347                </xsl:for-each>
348        </xsl:template>
349
350        <xsl:template match="cs:position">
351                <xsl:call-template name="tr-parent-name"/>
352                <xsl:for-each select="*">
353                        <xsl:call-template name="tr-grandparent-value-units"/>
354                </xsl:for-each>
355        </xsl:template>
356
357        <xsl:template match="cs:offset">
358                <xsl:call-template name="tr-parent-name"/>
359                <xsl:for-each select="*">
360                        <xsl:call-template name="tr-grandparent-value-units"/>
361                </xsl:for-each>
362        </xsl:template>
363
364        <xsl:template match="cs:beam_center">
365                <xsl:call-template name="tr-parent-name"/>
366                <xsl:for-each select="*">
367                        <xsl:call-template name="tr-grandparent-value-units"/>
368                </xsl:for-each>
369        </xsl:template>
370
371        <xsl:template match="cs:pixel_size">
372                <xsl:call-template name="tr-parent-name"/>
373                <xsl:for-each select="*">
374                        <xsl:call-template name="tr-grandparent-value-units"/>
375                </xsl:for-each>
376        </xsl:template>
377
378        <xsl:template match="cs:term">
379                <tr>
380                        <td><xsl:value-of select="@name" /></td>
381                        <xsl:call-template name="td-value"/>
382                        <xsl:call-template name="td-unit"/>
383                </tr>
384        </xsl:template>
385
386        <xsl:template match="cs:SASprocessnote" mode="standard">
387                <tr>
388                        <td><xsl:value-of select="name()" /></td>
389                        <xsl:call-template name="td-value"/>
390                        <td><xsl:value-of select="@name" /></td>
391                </tr>
392        </xsl:template>
393       
394        <xsl:template match="cs:SASprocessnote" mode="Indra">
395                <!--
396                        Customization for APS USAXS metadata
397                        These will be IgorPro wavenote variables
398                -->
399                <xsl:for-each select="cs:APS_USAXS">
400                        <!-- ignore any other elements at this point -->
401                        <tr>
402                                <td bgcolor="lightgrey"><xsl:value-of select="name(..)" /></td>
403                                <td bgcolor="lightgrey"><xsl:value-of select="name()" /></td>
404                                <td bgcolor="lightgrey"><xsl:value-of select="@name" /></td>
405                        </tr>
406                        <xsl:for-each select="*">
407                                <tr>
408                                        <td><xsl:value-of select="name()" /></td>
409                                        <xsl:call-template name="td-value"/>
410                                        <td><xsl:value-of select="@name" /></td>
411                                </tr>
412                        </xsl:for-each>
413                </xsl:for-each>
414        </xsl:template>
415       
416        <xsl:template match="cs:SASprocess">
417                <tr>
418                        <td><xsl:value-of select="name()" /></td>
419                        <td><xsl:value-of select="cs:name" /></td>
420                        <td><xsl:value-of select="@name" /></td>
421                </tr>
422                <xsl:for-each select="*">
423                        <xsl:choose>
424                                <xsl:when test="name()='name'" />
425                                <xsl:when test="name()='term'"><xsl:apply-templates select="." /></xsl:when>
426                                <xsl:when test="name()='SASprocessnote'">
427                                        <xsl:choose>
428                                                <xsl:when test="../@name='Indra'"><xsl:apply-templates select="." mode="Indra"/></xsl:when>
429                                                <xsl:otherwise><xsl:apply-templates select="." mode="standard"/></xsl:otherwise>
430                                        </xsl:choose>
431                                </xsl:when>
432                                <xsl:otherwise>
433                                        <tr>
434                                                <xsl:call-template name="td-grandparent"/>
435                                                <xsl:call-template name="td-value"/>
436                                                <td />
437                                        </tr>
438                                </xsl:otherwise>
439                        </xsl:choose>
440                </xsl:for-each>
441        </xsl:template>
442
443        <xsl:template match="cs:SASnote">
444                <xsl:if test="@name!=''">
445                        <tr>
446                                <td><xsl:value-of select="name()" /></td>
447                                <xsl:call-template name="td-value"/>
448                                <td><xsl:value-of select="@name" /></td>
449                        </tr>
450                </xsl:if>
451        </xsl:template>
452       
453        <!-- =============== convenience routines =============== -->
454       
455        <xsl:template name="tr-parent-value-units">
456                <tr>
457                        <xsl:call-template name="td-parent"/>
458                        <xsl:call-template name="td-value"/>
459                        <xsl:call-template name="td-unit"/>
460                </tr>
461        </xsl:template>
462       
463        <xsl:template name="tr-grandparent-value-units">
464                <tr>
465                        <xsl:call-template name="td-grandparent"/>
466                        <xsl:call-template name="td-value"/>
467                        <xsl:call-template name="td-unit"/>
468                </tr>
469        </xsl:template>
470       
471        <xsl:template name="tr-parent-name">
472                <tr>
473                        <xsl:call-template name="td-parent"/>
474                        <td><xsl:value-of select="@name" /></td>
475                        <td />
476                </tr>
477        </xsl:template>
478       
479        <xsl:template name="td-value">
480                <td><xsl:value-of select="." /></td>
481        </xsl:template>
482       
483        <xsl:template name="td-parent">
484                <td><xsl:value-of select="name(..)" 
485                        />_<xsl:value-of select="name()" 
486                        /></td>
487        </xsl:template>
488       
489        <xsl:template name="td-grandparent">
490                <td><xsl:value-of select="name(../..)" 
491                        />_<xsl:value-of select="name(..)" 
492                        />_<xsl:value-of select="name()" 
493                        /></td>
494        </xsl:template>
495       
496        <xsl:template name="td-greatgrandparent">
497                <td><xsl:value-of select="name(../../..)" 
498                        />_<xsl:value-of select="name(../..)" 
499                        />_<xsl:value-of select="name(..)" 
500                        />_<xsl:value-of select="name()" 
501                        /></td>
502        </xsl:template>
503       
504        <xsl:template name="td-unit">
505                <td><xsl:value-of select="@unit" /></td>
506        </xsl:template>
507
508</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.