forked from Fermium/AltiumTemplates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_drc.xsl
140 lines (121 loc) · 5.08 KB
/
report_drc.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
<?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">drc</xsl:param>
<xsl:output method="text" version="1.0" encoding="iso-8859-1"/>
<xsl:template match="report">
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="filename"/>
<xsl:apply-templates select="date"/>
<xsl:apply-templates select="time"/>
<xsl:apply-templates select="error"/>
<xsl:call-template name="new_line"/>
<xsl:apply-templates select="//table"/>
<xsl:call-template name="new_line"/>
<xsl:call-template name="total_violation_count"/>
<xsl:call-template name="total_waived_violation_count"/>
<xsl:call-template name="total_health_issues_count"/>
<xsl:apply-templates select="elapsed_time"/>
</xsl:template>
<xsl:template name="new_line">
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template name="total_violation_count">
Violations Detected : <xsl:value-of select="count(//table[type='rule']//row)"/>
</xsl:template>
<xsl:template name="total_waived_violation_count">
Waived Violations : <xsl:value-of select="count(//table[type='waived']//row)"/>
</xsl:template>
<xsl:template name="total_health_issues_count">
<xsl:if test="//summary_table[title='PCB Health Issues']">
PCB Health Issues : <xsl:value-of select="count(//table[type='health']//row)"/>
</xsl:if>
</xsl:template>
<xsl:template name="space">
<xsl:param name="n" select="1"/>
<xsl:text> </xsl:text>
<xsl:if test="$n != 1">
<xsl:call-template name="space">
<xsl:with-param name="n" select="$n - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="leading_space">
<xsl:text>    </xsl:text>
</xsl:template>
<xsl:template match="table">
<xsl:call-template name="new_line"/>
<xsl:if test="not(@suppress_title)"><xsl:apply-templates select="title"/></xsl:if>
<xsl:if test="type='warning'">WARNING: </xsl:if>
<xsl:if test="type='rule'">Processing Rule : </xsl:if>
<xsl:if test="type='waived'">Waived Violations Of Rule : </xsl:if>
<xsl:if test="type='health'">PCB Health Issue Category : </xsl:if>
<xsl:apply-templates select="columns"/>
<xsl:call-template name="new_line"/>
<xsl:variable name="headerRow">
<xsl:choose>
<xsl:when test="type='rule'">Violation between </xsl:when>
<xsl:when test="type='waived'">Waived Violation between </xsl:when>
<xsl:when test="type='health'"></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="rows">
<xsl:with-param name="hRow" select="$headerRow"/>
</xsl:call-template>
<xsl:if test="type='rule'">Rule Violations :<xsl:value-of select="count(row)"/><xsl:call-template name="new_line"/></xsl:if>
<xsl:if test="type='waived'">Waived Violations :<xsl:value-of select="count(row)"/><xsl:call-template name="new_line"/></xsl:if>
<xsl:if test="type='health'">Issues :<xsl:value-of select="count(row)"/><xsl:call-template name="new_line"/></xsl:if>
</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 name="rows">
<xsl:param name="hRow"/>
<xsl:for-each select="row">
<xsl:call-template name="space"><xsl:with-param name="n" select="3"/></xsl:call-template>
<xsl:value-of select="$hRow"/>
<xsl:for-each select="cell">
<xsl:if test="not(position() = 1)"><xsl:call-template name="new_line"/><xsl:call-template name="space"><xsl:with-param name="n" select="21"/></xsl:call-template></xsl:if>
<xsl:apply-templates select="."/><xsl:if test="not(count(parent::*/cell) = position())"> and </xsl:if>
</xsl:for-each>
<xsl:call-template name="new_line"/>
</xsl:for-each>
</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 match="report/filename">
PCB File : <xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="date">
Date : <xsl:value-of select="text()"/>
</xsl:template>
<xsl:template match="report/title">Protel Design System Design Rule Check</xsl:template>
<xsl:template match="time">
Time : <xsl:value-of select="text()"/>
</xsl:template>
<xsl:template match="elapsed_time">
Time Elapsed : <xsl:value-of select="text()"/>
</xsl:template>
<xsl:template match="error">
<xsl:call-template name="new_line"/>
ERROR : <xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>