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 similar to Wireshark. See
5 https://wiki.wireshark.org/PDML how to generate such a HTML file from PDML.
6 For questions contact Dirk Jagdmann (doj@cubic.org).
10 Wireshark - Network traffic analyzer
11 By Gerald Combs <gerald@wireshark.org>
12 Copyright 1998 Gerald Combs
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License
16 as published by the Free Software Foundation; either version 2
17 of the License, or (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 <!-- set parameters of the HTML output -->
30 <xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" indent="yes"/>
32 <!-- this matches the "field" tag -->
33 <xsl:template match="field">
34     <!-- indent with 3 non-breaking spaces -->
36 <!-- output either the "showname" or "show" attribute -->
38 <xsl:when test="string-length(@showname)>0">
39 <xsl:value-of select="@showname"/><br/>
42 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select="@show"/><br/>
46 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
49 <!-- this matches the "packet" tag -->
50 <xsl:template match="packet">
52 <!-- declare some variables for later use -->
53 <xsl:variable name="frame_num" select="proto[@name='frame']/field[@name='frame.number']/@show"/>
54 <xsl:variable name="frame_id" select="concat('f',$frame_num)"/>
55 <xsl:variable name="frame_c" select="concat($frame_id,'c')"/>
57 <!-- the "title" bar of the frame -->
58 <div width="100%" id="{$frame_id}">
59 <a href="javascript:toggle_node('{$frame_c}')">⇒</a> <!-- #8658 is a "rArr" (double right arrow) character -->
60 Frame <xsl:value-of select="$frame_num"/>:
61 <xsl:for-each select="proto[@name!='geninfo']">
62 <xsl:value-of select="@name"/>,
64 <small><a href="javascript:hide_node('{$frame_id}')">[X]</a></small>
67 <!-- the frame contents are stored in a div, so we can toggle it -->
68 <div width="100%" id="{$frame_c}" style="display:none">
69 <!-- loop through all proto tags, but skip the "geninfo" one -->
70 <xsl:for-each select="proto[@name!='geninfo']">
72 <xsl:variable name="proto" select="concat($frame_id,@name,count(preceding-sibling::proto)+1)"/>
74 <!-- the "title" bar of the proto -->
75 <div width="100%" style="background-color:#e5e5e5; margin-bottom: 2px">
76  <a href="javascript:toggle_node('{$proto}')">⇒</a> <xsl:value-of select="@showname"/>
78 <!-- print "proto" details inside another div -->
79 <div width="100%" id="{$proto}" style="display:none">
80 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
86 <!-- use the javascript function set_node_color() to set the color
87 of the frame title bar. Defer colorization until the full page has
88 been loaded. If the browser would support the XPath function
89 replace() we could simply set the class attribute of the title bar div,
90 but for now we're stuck with class names from Wireshark's colorfilters
91 that contain spaces and we can't handle them in CSS. -->
92 <script type="text/javascript">
93 dojo.addOnLoad(function(){
95 '<xsl:value-of select="$frame_id"/>',
96 '<xsl:value-of select="proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
102 <xsl:template match="pdml">
103 Capture Filename: <b><xsl:value-of select="@capture_file"/></b>
104 PDML created: <b><xsl:value-of select="@time"/></b>
106 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
110 <!-- this block matches the start of the PDML file -->
111 <xsl:template match="/">
114 <title>poor man's Wireshark</title>
115 <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" type="text/javascript"></script>
116 <script type="text/javascript">
117 function set_node(node, str)
119 if(dojo.isString(node))
120 node = dojo.byId(node);
122 node.style.display = str;
124 function toggle_node(node)
126 if(dojo.isString(node))
127 node = dojo.byId(node);
129 set_node(node, (node.style.display != 'none') ? 'none' : 'block');
131 function hide_node(node)
133 set_node(node, 'none');
135 // this function was generated by colorfilters2js.pl
136 function set_node_color(node,colorname)
138 if(dojo.isString(node))
139 node = dojo.byId(node);
143 if(colorname == 'Bad TCP') {
147 if(colorname == 'HSRP State Change') {
151 if(colorname == 'Spanning Tree Topology Change') {
155 if(colorname == 'OSPF State Change') {
159 if(colorname == 'ICMP errors') {
163 if(colorname == 'ARP') {
167 if(colorname == 'ICMP') {
171 if(colorname == 'TCP RST') {
175 if(colorname == 'TTL low or unexpected') {
179 if(colorname == 'Checksum Errors') {
183 if(colorname == 'SMB') {
187 if(colorname == 'HTTP') {
191 if(colorname == 'IPX') {
195 if(colorname == 'DCERPC') {
199 if(colorname == 'Routing') {
203 if(colorname == 'TCP SYN/FIN') {
207 if(colorname == 'TCP') {
211 if(colorname == 'UDP') {
215 if(colorname == 'Broadcast') {
220 node.style.color = fg;
222 node.style.background = bg;
227 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->