forked from Fermium/AltiumTemplates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DRCReport.xsl
102 lines (88 loc) · 4.22 KB
/
DRCReport.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version = '2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:param name="file_extension">txt</xsl:param>
<xsl:output method="text" version="1.0" encoding="iso-8859-1"/>
<xsl:template match="report">
<xsl:call-template name="total_warning_count"/>
<xsl:call-template name="total_violation_count"/>
<xsl:if test="count(//table[type='waived']//row)>0"><xsl:call-template name="total_waived_violation_count"/></xsl:if>
<xsl:call-template name="new_line"/>
<xsl:apply-templates select="//table[type='warning']"/>
<xsl:call-template name="warning_total"/>
<xsl:apply-templates select="//table[type='rule']"/>
<xsl:call-template name="violation_total"/>
<xsl:apply-templates select="//table[type='waived']"/>
<xsl:if test="count(//table[type='waived']//row)>0"><xsl:call-template name="waived_violation_total"/></xsl:if>
<xsl:apply-templates select="//row"/>
</xsl:template>
<xsl:template name="new_line">
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="table">
<xsl:if test="not(@suppress_title)"><xsl:apply-templates select="title"/></xsl:if>
<xsl:if test="type='warning'">Warnings|</xsl:if>
<xsl:if test="type='rule'">Rule Violations|</xsl:if>
<xsl:if test="type='waived'">Waived Violations|</xsl:if>
<xsl:apply-templates select="columns"/>
<xsl:if test="type='rule' or type='waived' or type='warning'">|<xsl:value-of select="count(row)"/></xsl:if>
<xsl:call-template name="new_line"/>
</xsl:template>
<xsl:template match="columns">
<xsl:variable name="html_class"><xsl:value-of select="parent::*/table/@html_class"/></xsl:variable>
<xsl:choose>
<xsl:when test="@use='title'">
<xsl:if test="not($html_class='')"><xsl:value-of select="$html_class"/>: </xsl:if><xsl:apply-templates select="parent::*/title"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="column">
<xsl:if test="position()=1" >
<xsl:if test="not($html_class='')"><xsl:value-of select="$html_class"/>:</xsl:if>
</xsl:if>
<xsl:apply-templates select="."/>
<xsl:if test="not(count(parent::*/column) = position())">, </xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="row">
<xsl:if test="parent::*/type='rule' or parent::*/type='waived'">
<xsl:value-of select="parent::*/title"/>
<xsl:choose>
<xsl:when test="count(cell) = 1">|||</xsl:when>
<xsl:when test="count(cell) = 2">||||</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="parent::*/type='warning'"><xsl:value-of select="parent::*/title"/>|||</xsl:if>
<xsl:for-each select="cell">
<xsl:apply-templates select="."/><xsl:if test="not(count(parent::*/cell) = position())">|</xsl:if>
</xsl:for-each>
<xsl:call-template name="new_line"/>
</xsl:template>
<xsl:template match="coordinate">
<xsl:choose>
<xsl:when test="//units/@default = 'mm'"><xsl:value-of select="format-number(0.0254 * text() div 10000, '0.####')"/>mm</xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(text() div 10000, '0.###')"/>mils</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="total_warning_count">
Warnings|Total|<xsl:value-of select="count(//table[type='warning']//row)"/>
</xsl:template>
<xsl:template name="total_violation_count">
Violations|Total|<xsl:value-of select="count(//table[type='rule']//row)"/>
</xsl:template>
<xsl:template name="total_waived_violation_count">
Waived Violations|Total|<xsl:value-of select="count(//table[type='waived']//row)"/>
</xsl:template>
<xsl:template name="warning_total">
Warnings|Total|<xsl:value-of select="count(//table[type='warning']//row)"/>
<xsl:call-template name="new_line"/>
</xsl:template>
<xsl:template name="violation_total">
Rule Violations|Total|<xsl:value-of select="count(//table[type='rule']//row)"/>
<xsl:call-template name="new_line"/>
</xsl:template>
<xsl:template name="waived_violation_total">
Waived Violations|Total|<xsl:value-of select="count(//table[type='waived']//row)"/>
<xsl:call-template name="new_line"/>
</xsl:template>
</xsl:stylesheet>