Witness: set col_info for interfaceInfo_state
[wireshark-wip.git] / pdml2html.xsl
blob3e24613c8060ac7083dd2f2a8745bb49168d7c3f
1 <?xml version="1.0"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <!-- This XSLT will convert a PDML file, saved by Wireshark, into
4 HTML. The HTML page should look like Wireshark. For questions contact
5 Dirk Jagdmann (doj@cubic.org).
6 Version: 2010-06-09
8 Wireshark - Network traffic analyzer
9 By Gerald Combs <gerald@wireshark.org>
10 Copyright 1998 Gerald Combs
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 -->
27 <!-- set parameters of the HTML output -->
28 <xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" indent="yes"/>
30 <!-- this matches the "field" tag -->
31 <xsl:template match="field">
32 &#160;&#160;&#160; <!-- indent with 3 non-breaking spaces -->
34 <!-- output either the "showname" or "show" attribute -->
35 <xsl:choose>
36 <xsl:when test="string-length(@showname)>0">
37 <xsl:value-of select="@showname"/><br/>
38 </xsl:when>
39 <xsl:otherwise>
40 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select="@show"/><br/>
41 </xsl:otherwise>
42 </xsl:choose>
44 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
45 </xsl:template>
47 <!-- this matches the "packet" tag -->
48 <xsl:template match="packet">
50 <!-- declare some variables for later use -->
51 <xsl:variable name="frame_num" select="proto[@name='frame']/field[@name='frame.number']/@show"/>
52 <xsl:variable name="frame_id" select="concat('f',$frame_num)"/>
53 <xsl:variable name="frame_c" select="concat($frame_id,'c')"/>
55 <!-- the "title" bar of the frame -->
56 <div width="100%" id="{$frame_id}">
57 <a href="javascript:toggle_node('{$frame_c}')">&#8658;</a> <!-- #8658 is a "rArr" (double right arrow) character -->
58 Frame <xsl:value-of select="$frame_num"/>:
59 <xsl:for-each select="proto[@name!='geninfo']">
60 <xsl:value-of select="@name"/>,
61 </xsl:for-each>
62 <small><a href="javascript:hide_node('{$frame_id}')">[X]</a></small>
63 </div>
65 <!-- the frame contents are stored in a div, so we can toggle it -->
66 <div width="100%" id="{$frame_c}" style="display:none">
67 <!-- loop trough all proto tags, but skip the "geninfo" one -->
68 <xsl:for-each select="proto[@name!='geninfo']">
70 <xsl:variable name="proto" select="concat($frame_id,@name)"/>
72 <!-- the "title" bar of the proto -->
73 <div width="100%" style="background-color:#e5e5e5; margin-bottom: 2px">
74 &#160;<a href="javascript:toggle_node('{$proto}')">&#8658;</a>&#160;<xsl:value-of select="@showname"/>
76 <!-- print "proto" details inside another div -->
77 <div width="100%" id="{$proto}" style="display:none">
78 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
79 </div>
80 </div>
81 </xsl:for-each>
82 </div>
84 <!-- use the javascript function set_node_color() to set the color
85 of the frame title bar. Defer colorization until the full page has
86 been loaded. If the browser would support the XPath function
87 replace() we could simply set the class attribute of the title bar div,
88 but for now we're stuck with class names from Wireshark's colorfilters
89 that contain spaces and we can't handle them in CSS. -->
90 <script type="text/javascript">
91 dojo.addOnLoad(function(){
92 set_node_color(
93 '<xsl:value-of select="$frame_id"/>',
94 '<xsl:value-of select="proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
96 });
97 </script>
98 </xsl:template>
100 <xsl:template match="pdml">
101 Capture Filename: <b><xsl:value-of select="@capture_file"/></b>
102 PDML created: <b><xsl:value-of select="@time"/></b>
103 <tt>
104 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
105 </tt>
106 </xsl:template>
108 <!-- this block matches the start of the PDML file -->
109 <xsl:template match="/">
110 <html>
111 <head>
112 <title>poor man's Wireshark</title>
113 <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" type="text/javascript"></script>
114 <script type="text/javascript">
115 function set_node(node, str)
117 if(dojo.isString(node))
118 node = dojo.byId(node);
119 if(!node) return;
120 node.style.display = str;
122 function toggle_node(node)
124 if(dojo.isString(node))
125 node = dojo.byId(node);
126 if(!node) return;
127 set_node(node, (node.style.display != 'none') ? 'none' : 'block');
129 function hide_node(node)
131 set_node(node, 'none');
133 // this function was generated by colorfilters2js.pl
134 function set_node_color(node,colorname)
136 if(dojo.isString(node))
137 node = dojo.byId(node);
138 if(!node) return;
139 var fg;
140 var bg;
141 if(colorname == 'Bad TCP') {
142 bg='#000000';
143 fg='#ff5f5f';
145 if(colorname == 'HSRP State Change') {
146 bg='#000000';
147 fg='#fff600';
149 if(colorname == 'Spanning Tree Topology Change') {
150 bg='#000000';
151 fg='#fff600';
153 if(colorname == 'OSPF State Change') {
154 bg='#000000';
155 fg='#fff600';
157 if(colorname == 'ICMP errors') {
158 bg='#000000';
159 fg='#00ff0e';
161 if(colorname == 'ARP') {
162 bg='#d6e8ff';
163 fg='#000000';
165 if(colorname == 'ICMP') {
166 bg='#c2c2ff';
167 fg='#000000';
169 if(colorname == 'TCP RST') {
170 bg='#900000';
171 fg='#fff680';
173 if(colorname == 'TTL low or unexpected') {
174 bg='#900000';
175 fg='#ffffff';
177 if(colorname == 'Checksum Errors') {
178 bg='#000000';
179 fg='#ff5f5f';
181 if(colorname == 'SMB') {
182 bg='#fffa99';
183 fg='#000000';
185 if(colorname == 'HTTP') {
186 bg='#8dff7f';
187 fg='#000000';
189 if(colorname == 'IPX') {
190 bg='#ffe3e5';
191 fg='#000000';
193 if(colorname == 'DCERPC') {
194 bg='#c797ff';
195 fg='#000000';
197 if(colorname == 'Routing') {
198 bg='#fff3d6';
199 fg='#000000';
201 if(colorname == 'TCP SYN/FIN') {
202 bg='#a0a0a0';
203 fg='#000000';
205 if(colorname == 'TCP') {
206 bg='#e7e6ff';
207 fg='#000000';
209 if(colorname == 'UDP') {
210 bg='#70e0ff';
211 fg='#000000';
213 if(colorname == 'Broadcast') {
214 bg='#ffffff';
215 fg='#808080';
217 if(fg.length > 0)
218 node.style.color = fg;
219 if(bg.length > 0)
220 node.style.background = bg;
222 </script>
223 </head>
224 <body>
225 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->
226 </body>
227 </html>
228 </xsl:template>
230 </xsl:stylesheet>