File: innreport-filter.xslt

package info (click to toggle)
inn2 2.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,720 kB
  • ctags: 8,983
  • sloc: ansic: 92,499; sh: 13,509; perl: 12,921; makefile: 2,985; yacc: 842; python: 342; lex: 255
file content (128 lines) | stat: -rw-r--r-- 3,533 bytes parent folder | download | duplicates (6)
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
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
   - $Id: innreport-filter.xslt 8172 2008-11-17 19:49:40Z iulius $
   -
   - This is a filter to copy individual sections from innreport's HTML
   - files.  Actually only news.notice.* files are changed, index.html
   - is not modified.
   -
   - USAGE:
   -   xsltproc -novalid innreport-filter.xslt input.html
   -
   - (Note that option novalid is prefixed by two dashes.)
   -
   - Output is written to standard output, so you need to redirect that.
   -
   - Script written by Alexander Bartolich, 2008.
   -->
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xhtml="http://www.w3.org/1999/xhtml"
   xmlns="http://www.w3.org/1999/xhtml">

<xsl:output method="xml" indent="no"/>
<xsl:strip-space elements="*"/>

<!--
   - This is a list of section IDs.  Only IDs quoted with + are copied.
   - Most nnrpd_XXX invade user's privacy.
   -->
<xsl:variable name="select_id" select="'
   +cnfsstat+
   +innd_connect+
   +innd_control+
   +innd_his+
   +innd_incoming_vol+
   +innd_misc_stat+
   +innd_perl+
   +innd_timer+
   +innfeed_connect+
   +innfeed_shrunk+
   +innfeed_timer+
   +innfeed_volume+
   +inn_flow+
   +inn_unwanted+
   +inn_unwanted_dist+
   +inn_unwanted_group+
   +inn_unwanted_unapp+
   -nnrpd_auth-
   +nnrpd_curious+
   -nnrpd_dom_groups-
   +nnrpd_group+
   -nnrpd_groups-
   +nnrpd_hierarchy+
   +nnrpd_no_permission+
   -nnrpd_resource-
   -nnrpd_timeout-
   +nnrpd_timer+
   -nnrpd_unrecognized-
   -nnrpd_unrecognized2-
   +nocem+
   +prog_type+
   -unrecognize-
'"/>

<!--
   - This is a list of section classes.  Only classes quoted with + are
   - copied.
   -->
<xsl:variable name="select_class" select="'
   +ir-feedTotals+
   +ir-pageFooter+
   +ir-pageTitle+
'"/>

<!--
   - This low-priority rule copies any attribute and any node.
   -->
<xsl:template match="@*|node()"
   ><xsl:copy
     ><xsl:apply-templates select="@*|node()"
   /></xsl:copy
 ></xsl:template>

<!--
   - This template matches the list items in the table of contents.
   - Copy items only if the target ID is found in variable select_id.
   - Function substrings cuts off the leading # in attribute href.
   -->
<xsl:template match="/xhtml:html/xhtml:body/xhtml:ul/xhtml:li"
   ><xsl:if test="contains($select_id,
     concat('+', substring(xhtml:a/@href, 2), '+')
   )"><xsl:copy
       ><xsl:apply-templates select="@*|node()"
     /></xsl:copy
   ></xsl:if
 ></xsl:template>

<!--
   - This template matches report sections.  Copy items if the ID is
   - found in variable select_id or the class is found in variable
   - select_class.
   -->
<xsl:template match="/xhtml:html/xhtml:body/xhtml:div"
   ><xsl:if test="
     contains($select_id, concat('+', @id, '+')) or
     contains($select_class, concat('+', @class, '+'))
   "><xsl:copy
       ><xsl:apply-templates select="@*|node()"
     /></xsl:copy
   ></xsl:if
 ></xsl:template>

<!--
   - Graph sections have no ID and are not part of the report section.
   - Instead we check whether the ID of the preceding report section
   - is found in variable select_id.
   -->
<xsl:template match="/xhtml:html/xhtml:body/xhtml:div[@class = 'ir-reportGraph']"
   ><xsl:variable name="prec" select="preceding-sibling::*"
   /><xsl:variable name="prec-id" select="$prec[count($prec)]/@id"
   /><xsl:if test="contains($select_id, concat('+', $prec-id, '+'))"
   ><xsl:copy
     ><xsl:apply-templates select="@*|node()"
     /></xsl:copy
   ></xsl:if
 ></xsl:template>

</xsl:stylesheet>