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://gitlab.com/wireshark/wireshark/-/wikis/PDML for information
6 on how to generate such a HTML file from PDML.
7 For questions contact Dirk Jagdmann (doj@cubic.org).
11 Wireshark - Network traffic analyzer
12 By Gerald Combs <gerald@wireshark.org>
13 Copyright 1998 Gerald Combs
15 SPDX-License-Identifier: GPL-2.0-or-later
18 <!-- set parameters of the HTML output -->
19 <xsl:output method=
"html" encoding=
"UTF-8" omit-xml-declaration=
"no" standalone=
"yes" indent=
"yes"/>
21 <!-- this matches the "field" tag -->
22 <xsl:template match=
"field">
23     <!-- indent with 3 non-breaking spaces -->
25 <!-- output either the "showname" or "show" attribute -->
27 <xsl:when test=
"string-length(@showname)>0">
28 <xsl:value-of select=
"@showname"/><br/>
31 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select=
"@show"/><br/>
35 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
38 <!-- this matches the "packet" tag -->
39 <xsl:template match=
"packet">
41 <!-- declare some variables for later use -->
42 <xsl:variable name=
"frame_num" select=
"proto[@name='frame']/field[@name='frame.number']/@show"/>
43 <xsl:variable name=
"frame_id" select=
"concat('f',$frame_num)"/>
44 <xsl:variable name=
"frame_c" select=
"concat($frame_id,'c')"/>
46 <!-- the "title" bar of the frame -->
47 <div width=
"100%" id=
"{$frame_id}">
48 <a href=
"javascript:toggle_node('{$frame_c}')">⇒</a> <!-- #8658 is a "rArr" (double right arrow) character -->
49 Frame
<xsl:value-of select=
"$frame_num"/>:
50 <xsl:for-each select=
"proto[@name!='geninfo']">
51 <xsl:value-of select=
"@name"/>,
53 <small><a href=
"javascript:hide_node('{$frame_id}')">[X]
</a></small>
56 <!-- the frame contents are stored in a div, so we can toggle it -->
57 <div width=
"100%" id=
"{$frame_c}" style=
"display:none">
58 <!-- loop through all proto tags, but skip the "geninfo" one -->
59 <xsl:for-each select=
"proto[@name!='geninfo']">
61 <xsl:variable name=
"proto" select=
"concat($frame_id,@name,count(preceding-sibling::proto)+1)"/>
63 <!-- the "title" bar of the proto -->
64 <div width=
"100%" style=
"background-color:#e5e5e5; margin-bottom: 2px">
65  <a href=
"javascript:toggle_node('{$proto}')">⇒</a> <xsl:value-of select=
"@showname"/>
67 <!-- print "proto" details inside another div -->
68 <div width=
"100%" id=
"{$proto}" style=
"display:none">
69 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
75 <!-- use the javascript function set_node_color() to set the color
76 of the frame title bar. Defer colorization until the full page has
77 been loaded. If the browser would support the XPath function
78 replace() we could simply set the class attribute of the title bar div,
79 but for now we're stuck with class names from Wireshark's colorfilters
80 that contain spaces and we can't handle them in CSS. -->
81 <script type=
"text/javascript">
82 dojo.addOnLoad(function(){
84 '
<xsl:value-of select=
"$frame_id"/>',
85 '
<xsl:value-of select=
"proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
91 <xsl:template match=
"pdml">
92 Capture Filename:
<b><xsl:value-of select=
"@capture_file"/></b>
93 PDML created:
<b><xsl:value-of select=
"@time"/></b>
95 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
99 <!-- this block matches the start of the PDML file -->
100 <xsl:template match=
"/">
103 <title>poor man's Wireshark
</title>
104 <script src=
"https://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" type=
"text/javascript"></script>
105 <script type=
"text/javascript">
106 function set_node(node, str)
108 if(dojo.isString(node))
109 node = dojo.byId(node);
111 node.style.display = str;
113 function toggle_node(node)
115 if(dojo.isString(node))
116 node = dojo.byId(node);
118 set_node(node, (node.style.display != 'none') ? 'none' : 'block');
120 function hide_node(node)
122 set_node(node, 'none');
124 // this function was generated by colorfilters2js.pl
125 function set_node_color(node,colorname)
127 if(dojo.isString(node))
128 node = dojo.byId(node);
132 if(colorname == 'Bad TCP') {
136 if(colorname == 'HSRP State Change') {
140 if(colorname == 'Spanning Tree Topology Change') {
144 if(colorname == 'OSPF State Change') {
148 if(colorname == 'ICMP errors') {
152 if(colorname == 'ARP') {
156 if(colorname == 'ICMP') {
160 if(colorname == 'TCP RST') {
164 if(colorname == 'TTL low or unexpected') {
168 if(colorname == 'Checksum Errors') {
172 if(colorname == 'SMB') {
176 if(colorname == 'HTTP') {
180 if(colorname == 'IPX') {
184 if(colorname == 'DCERPC') {
188 if(colorname == 'Routing') {
192 if(colorname == 'TCP SYN/FIN') {
196 if(colorname == 'TCP') {
200 if(colorname == 'UDP') {
204 if(colorname == 'Broadcast') {
209 node.style.color = fg;
211 node.style.background = bg;
216 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->