forked from Fermium/AltiumTemplates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnvReportHTML.xsl
649 lines (547 loc) · 22.3 KB
/
EnvReportHTML.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version = '2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="report">
<html>
<head>
<style type="text/css">
h1, h2, h3, h4, h5, h6 {
font-family : segoe ui;
color : black;
background-color : #EDE7D9;
padding: 0.3em;
}
h1 {
font-size: 1.2em;
}
h2 {
font-size: 1.2em;
}
body {
font-family : segoe ui;
}
td, th {
padding: 0.5em;
text-align : left;
width: 10em;
}
th {
background-color : #EEEEEE;
}
th.column1, td.column1 {
text-align: left;
width : auto;
}
table {
width : 100%;
font-size: 0.9em;
}
.Diff_summary_header {
padding-bottom : 0.1em;
border : 0px solid black;
width: 100%;
align: left;
}
.Diff_summary_header_col1,
.Diff_summary_header_col2,
.Diff_summary_header_col3 {
color : black;
font-size:100%;
padding : 0em;
padding-top : 0.2em;
padding-bottom 0.2em;
border : 0px solid black;
vertical-align: top;
text-align: left;
}
.Diff_summary_header_col1 {
font-weight: bold;
width: 8em;
}
.Diff_summary_header_col2 {
width: 0.1em;
}
.Diff_summary_header_col3{
width : auto;
}
.header_holder{
Width = 100%;
border = 0px solid green;
padding = 0;
}
.front_matter, .front_matter_column1, .front_matter_column2, .front_matter_column3
{
left:0;
top:0;
padding: 0em;
padding-top : 0.1em;
border : 0px solid black;
width : 100%;
vertical-align: top;
text-align: left;
}
.front_matter_column1 {
width : 8em;
font-weight: bold;
}
.front_matter_column2 {
width: 0.1em;
}
.front_matter_column3 {
width : auto;
}
.total_column1, .total_column {
font-weight : bold;
}
.total_column1 {
text-align : left;
}
.warning, .error {
color : red;
font-weight : bold;
}
tr.onmouseout_odd {
background-color : #white;
}
tr.onmouseout_even {
background-color : #FAFAFA;
}
tr.onmouseover_odd, tr.onmouseover_even {
background-color : #EEEEEE;
}
a:link, a:visited, .q a:link,.q a:active,.q {
color: #21489e;
}
a:link.callback, a:visited.callback {
color: #21489e;
}
p.contents_level1 {
font-weight : bold;
font-size : 110%;
margin : 0.5em;
}
p.contents_level2 {
position : relative;
left : 20px;
margin : 0.5em;
}
</style>
<script type="text/javascript">
function coordToMils(coord) {
var number = coord / 10000;
if (number != number.toFixed(3))
number = number.toFixed(3);
return number + 'mil'
}
function coordToMM(coord) {
var number = 0.0254 * coord / 10000;
if (number != number.toFixed(4))
number = number.toFixed(4);
return number + 'mm'
}
function convertCoord(coordNode, units) {
for (var i = 0; i < coordNode.childNodes.length; i++) {
coordNode.removeChild(coordNode.childNodes[i]);
}
var coord = coordNode.getAttribute('value');
if (coord != null) {
if (units == 'mm') {
textNode = document.createTextNode(coordToMM(coord));
coordNode.appendChild(textNode);
} else if (units == 'mil') {
textNode = document.createTextNode(coordToMils(coord));
coordNode.appendChild(textNode);
}
}
}
function convertUnits(unitNode, units) {
for (var i = 0; i < unitNode.childNodes.length; i++) {
unitNode.removeChild(unitNode.childNodes[i]);
}
textNode = document.createTextNode(units);
unitNode.appendChild(textNode);
}
function changeUnits(radio_input, units) {
if (radio_input.checked) {
var elements = document.getElementsByName('coordinate');
if (elements) {
for (var i = 0; i < elements.length; i++) {
convertCoord(elements[i], units);
}
}
var elements = document.getElementsByName('units');
if (elements) {
for (var i = 0; i < elements.length; i++) {
convertUnits(elements[i], units);
}
}
}
}
</script>
</head>
<body onload="">
<xsl:if test="/report//coordinate">
<xsl:attribute name="onload">
<xsl:choose>
<xsl:when test="//units/@default = 'mm'">document.getElementById('radio_mm').click()</xsl:when>
<xsl:otherwise>document.getElementById('radio_mil').click()</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="process_body"/>
</body>
</html>
</xsl:template>
<xsl:template name="process_body">
<img ALT="Altium">
<xsl:attribute name="src">
file://<xsl:value-of select="//resource_path"/>AD_logo.png
</xsl:attribute>
</img>
<h1><xsl:apply-templates select="title"/></h1>
<table class="header_holder">
<td class="column1">
<table class="front_matter">
<xsl:if test="date">
<tr class="front_matter">
<td class="front_matter_column1">Date:</td>
<td class="front_matter_column2"></td>
<td class="front_matter_column3"><xsl:apply-templates select="date"/></td>
</tr>
</xsl:if>
<xsl:if test="time">
<tr class="front_matter">
<td class="front_matter_column1">Time:</td>
<td class="front_matter_column2"></td>
<td class="front_matter_column3"><xsl:apply-templates select="time"/></td>
</tr>
</xsl:if>
<xsl:if test="elapsed_time">
<tr class="front_matter">
<td class="front_matter_column1">Elapsed Time:</td>
<td class="front_matter_column2"></td>
<td class="front_matter_column3"><xsl:apply-templates select="elapsed_time"/></td>
</tr>
</xsl:if>
<xsl:if test="filename">
<tr class="front_matter">
<td class="front_matter_column1">Filename:</td>
<td class="front_matter_column2"></td>
<td class="front_matter_column3"><xsl:apply-templates select="filename"/></td>
</tr>
</xsl:if>
<xsl:if test="FileName">
<tr class="front_matter">
<td class="front_matter_column1">Filename:</td>
<td class="front_matter_column2"></td>
<td class="front_matter_column3"><xsl:apply-templates select="FileName"/></td>
</tr>
</xsl:if>
<xsl:if test="/report//coordinate">
<tr class="front_matter">
<td class="front_matter_column1">Units</td>
<td class="front_matter_column2">:</td>
<td class="front_matter_column3">
<form>
<input type="radio" name="radio_units" id="radio_mm" onclick="changeUnits(this, 'mm')"/>mm<!--br/-->
<input type="radio" name="radio_units" id="radio_mil" onclick="changeUnits(this, 'mil')"/>mils<!--br/-->
</form>
</td>
</tr>
</xsl:if>
<xsl:for-each select="/report/frontmatter">
<tr class="front_matter">
<td class="front_matter_column1"><xsl:apply-templates select="name"/></td>
<td class="front_matter_column2">:</td>
<td class="front_matter_column3"><xsl:apply-templates select="*[not(name()='name')]"/></td>
</tr>
</xsl:for-each>
</table>
</td>
<td class="column2">
<table class="Diff_summary_header">
<xsl:for-each select="section/summary_table">
<tr>
<td class="Diff_summary_header_col1"><xsl:value-of select="title"/>:</td>
<td class="Diff_summary_header_col2"></td>
<xsl:for-each select="columns/column">
<xsl:variable name="column_type" select="attribute::type"/>
<xsl:variable name="problemCount" select="count(ancestor::report//table[type = $column_type]/row)" />
<xsl:choose>
<xsl:when test="$problemCount > 0"><td class="Diff_summary_header_col3" style="color : red"> <xsl:value-of select="$problemCount"/></td></xsl:when>
<xsl:otherwise><td class="Diff_summary_header_col3"><xsl:value-of select="$problemCount"/></td></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</td>
</table>
<xsl:apply-templates select="error"/>
<xsl:apply-templates select="section"/>
<xsl:apply-templates select="*[not(name()='title') and
not(name()='error') and
not(name()='filename') and
not(name()='FileName') and
not(name()='date') and
not(name()='time') and
not(name()='elapsed_time') and
not(name()='section') and
not(name()='resource_path') and
not(name()='frontmatter')]"/>
</xsl:template>
<xsl:template match="file">
<xsl:element name="a">
<xsl:attribute name="href">file:///<xsl:value-of select="@filename"/></xsl:attribute>
<xsl:attribute name="class">file</xsl:attribute>
<acronym>
<xsl:attribute name="title"><xsl:value-of select="@filename"/></xsl:attribute>
<xsl:apply-templates select="text()|*"/>
</acronym>
</xsl:element>
</xsl:template>
<xsl:template match="File">
<xsl:element name="a"><xsl:value-of select="@filename"/></xsl:element>
</xsl:template>
<xsl:template match="callback">
<xsl:variable name="url">dxpprocess://<xsl:value-of select="@process"/>?<xsl:if test="@document">document=<xsl:value-of select="@document"/>;</xsl:if><xsl:if test="@viewname">viewname=<xsl:value-of select="@viewname"/>;</xsl:if><xsl:value-of select="@parameters"/></xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
<xsl:attribute name="class">callback</xsl:attribute>
<acronym>
<xsl:attribute name="title"><xsl:value-of select="$url"/></xsl:attribute>
<xsl:apply-templates select="text()|*"/>
</acronym>
</xsl:element>
</xsl:template>
<xsl:template match="list">
<ul>
<xsl:apply-templates select="*"/>
</ul>
</xsl:template>
<xsl:template match="space"><xsl:text disable-output-escaping="yes"> &nbsp;</xsl:text></xsl:template>
<xsl:template match="listelement">
<li>
<xsl:apply-templates select="*"/>
</li>
</xsl:template>
<xsl:template match="report/error">
<p class="error">ERROR : <xsl:apply-templates select="text()"/></p>
</xsl:template>
<xsl:template match="linebreak">
<br/>
</xsl:template>
<xsl:template match="report/summary">
<h2><xsl:apply-templates select="title"/></h2>
<xsl:apply-templates select="summary_table"/>
</xsl:template>
<xsl:template match="report/section">
<xsl:if test="*[not(name()='title')]">
<a>
<xsl:attribute name="name"><xsl:value-of select="generate-id(.)"/></xsl:attribute>
<h2><xsl:apply-templates select="title"/></h2>
</a>
<xsl:apply-templates select="*[not(name()='title')]"/>
</xsl:if>
</xsl:template>
<xsl:template name="process_table_for_contents">
<a>
<xsl:attribute name="href">#<xsl:value-of select="generate-id(.)" /></xsl:attribute>
<xsl:apply-templates select="title"/><br/>
</a>
</xsl:template>
<xsl:template match="contents">
<xsl:for-each select="/report/section">
<xsl:if test="*[not(name()='title')]">
<p>
<xsl:attribute name="class">contents_level1</xsl:attribute>
<a>
<xsl:attribute name="href">#<xsl:value-of select="generate-id(.)"/></xsl:attribute>
<xsl:apply-templates select="title"/>
</a>
</p>
<xsl:for-each select="table">
<p>
<xsl:attribute name="class">contents_level2</xsl:attribute>
<xsl:call-template name="process_table_for_contents"/>
</p>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<xsl:if test="/report/table">
<br/>
<xsl:for-each select="/report/table">
<p>
<xsl:attribute name="class">contents_level2</xsl:attribute>
<xsl:call-template name="process_table_for_contents"/>
</p>
</xsl:for-each>
</xsl:if>
<br/>
</xsl:template>
<xsl:template match="summary_table">
<table>
<tr>
<xsl:element name="th">
<xsl:attribute name="class">column1</xsl:attribute>
<xsl:apply-templates select="title"/>
</xsl:element>
<xsl:for-each select="columns/column">
<xsl:element name="th">
<xsl:attribute name="class"><xsl:value-of select="concat('column',position() + 1)"/></xsl:attribute>
<xsl:apply-templates select="text()"/>
</xsl:element>
</xsl:for-each>
</tr>
<xsl:for-each select="columns/column">
<xsl:variable name="column_type" select="attribute::type"/>
<xsl:for-each select="ancestor::report//table">
<xsl:if test="type=$column_type">
<xsl:element name="tr">
<xsl:call-template name="classify_row_even_or_odd"/>
<xsl:element name="td">
<xsl:call-template name="apply_column_index_attribute">
<xsl:with-param name="index">1</xsl:with-param>
</xsl:call-template>
<xsl:element name="a">
<xsl:attribute name="href">#<xsl:value-of select="generate-id(.)" /></xsl:attribute>
<xsl:apply-templates select="title"/>
</xsl:element>
</xsl:element>
<xsl:element name="td">
<xsl:call-template name="apply_column_index_attribute">
<xsl:with-param name="index">2</xsl:with-param>
</xsl:call-template>
<xsl:value-of select="count(row)"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="columns/column">
<xsl:variable name="column_type" select="attribute::type"/>
<tr>
<td style="font-weight : bold; text-align : right">
<xsl:call-template name="apply_column_index_attribute">
<xsl:with-param name="index">1</xsl:with-param>
</xsl:call-template>Total</td>
<td style="font-weight : bold">
<xsl:call-template name="apply_column_index_attribute">
<xsl:with-param name="index">2</xsl:with-param>
</xsl:call-template>
<xsl:value-of select="count(ancestor::report//table[type = $column_type]/row)"/></td>
</tr>
</xsl:for-each>
</table>
<br/>
<!--hr/-->
</xsl:template>
<xsl:template match="html">
<xsl:apply-templates select="."/>
</xsl:template>
<xsl:template match="table">
<xsl:if test = "count(row) > 0">
<xsl:if test="not(@suppress_title)">
<h2><xsl:value-of select="title"/></h2>
</xsl:if>
<xsl:if test="columns">
<xsl:variable name="table_type"><xsl:value-of select="type"/></xsl:variable>
<xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="generate-id(.)" /></xsl:attribute>
<xsl:element name="table">
<xsl:element name="tr">
<xsl:choose>
<xsl:when test="columns/@use='title'">
<xsl:element name="th">
<xsl:attribute name="style">text-align : left</xsl:attribute>
<xsl:attribute name="colspan">
<xsl:value-of select="count(row[1]/cell)"/>
</xsl:attribute>
<xsl:if test="not($table_type) = ''">
<xsl:attribute name="class"><xsl:value-of select="$table_type"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="title"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="columns/column" >
<xsl:element name="th">
<xsl:attribute name="class">
<xsl:value-of select="concat('column',position())"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="position() = 1" >
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:for-each select="row">
<xsl:call-template name="process_row"/>
</xsl:for-each>
<xsl:if test="@numeric_totals and not(@numeric_totals='false') and not(columns/@use='title')">
<tr>
<td style="font-weight : bold; text-align : right" class="column1">Total</td>
<xsl:for-each select="columns/column">
<xsl:variable name="column_position" select="position()"/>
<xsl:if test="not($column_position = 1)">
<td style="font-weight : bold">
<xsl:call-template name="apply_column_index_attribute"/>
<xsl:if test="@data_type='number'">
<xsl:value-of select="sum(ancestor::table/row/cell[$column_position])"/>
</xsl:if>
</td>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:if>
<hr color="#EEEEEE"/>
<a href="#top" style="font-size: 0.9em">Back to top</a><br/><br/>
</xsl:if>
</xsl:template>
<xsl:template name="apply_column_index_attribute">
<xsl:param name="index"><xsl:value-of select="position()"/></xsl:param>
<xsl:attribute name="class">
<xsl:value-of select="concat('column', $index)"/>
</xsl:attribute>
</xsl:template>
<xsl:template name="classify_row_even_or_odd">
<xsl:param name="row_offset">0</xsl:param>
<xsl:choose>
<xsl:when test="(position() + $row_offset) mod 2 = 0">
<xsl:attribute name="class">onmouseout_even</xsl:attribute>
<xsl:attribute name="onmouseover">className = 'onmouseover_even'</xsl:attribute>
<xsl:attribute name="onmouseout">className = 'onmouseout_even'</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">onmouseout_odd</xsl:attribute>
<xsl:attribute name="onmouseover">className = 'onmouseover_odd'</xsl:attribute>
<xsl:attribute name="onmouseout">className = 'onmouseout_odd'</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process_row">
<xsl:element name="tr">
<xsl:call-template name="classify_row_even_or_odd"/>
<xsl:for-each select="cell">
<xsl:element name="td">
<xsl:if test="@html_style">
<xsl:attribute name="style"><xsl:value-of select="@html_style"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="class">
<xsl:value-of select="concat('column',position())"/>
</xsl:attribute>
<xsl:apply-templates select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>