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).
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.
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     <!-- indent with 3 non-breaking spaces -->
34 <!-- output either the "showname" or "show" attribute -->
36 <xsl:when test=
"string-length(@showname)>0">
37 <xsl:value-of select=
"@showname"/><br/>
40 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select=
"@show"/><br/>
44 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
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}')">⇒</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"/>,
62 <small><a href=
"javascript:hide_node('{$frame_id}')">[X]
</a></small>
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  <a href=
"javascript:toggle_node('{$proto}')">⇒</a> <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 -->
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(){
93 '
<xsl:value-of select=
"$frame_id"/>',
94 '
<xsl:value-of select=
"proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
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>
104 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
108 <!-- this block matches the start of the PDML file -->
109 <xsl:template match=
"/">
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);
120 node.style.display = str;
122 function toggle_node(node)
124 if(dojo.isString(node))
125 node = dojo.byId(node);
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);
141 if(colorname == 'Bad TCP') {
145 if(colorname == 'HSRP State Change') {
149 if(colorname == 'Spanning Tree Topology Change') {
153 if(colorname == 'OSPF State Change') {
157 if(colorname == 'ICMP errors') {
161 if(colorname == 'ARP') {
165 if(colorname == 'ICMP') {
169 if(colorname == 'TCP RST') {
173 if(colorname == 'TTL low or unexpected') {
177 if(colorname == 'Checksum Errors') {
181 if(colorname == 'SMB') {
185 if(colorname == 'HTTP') {
189 if(colorname == 'IPX') {
193 if(colorname == 'DCERPC') {
197 if(colorname == 'Routing') {
201 if(colorname == 'TCP SYN/FIN') {
205 if(colorname == 'TCP') {
209 if(colorname == 'UDP') {
213 if(colorname == 'Broadcast') {
218 node.style.color = fg;
220 node.style.background = bg;
225 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->