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 SPDX-License-Identifier: GPL-2.0-or-later
17 <!-- set parameters of the HTML output -->
18 <xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" indent="yes"/>
20 <!-- this matches the "field" tag -->
21 <xsl:template match="field">
22     <!-- indent with 3 non-breaking spaces -->
24 <!-- output either the "showname" or "show" attribute -->
26 <xsl:when test="string-length(@showname)>0">
27 <xsl:value-of select="@showname"/><br/>
30 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select="@show"/><br/>
34 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
37 <!-- this matches the "packet" tag -->
38 <xsl:template match="packet">
40 <!-- declare some variables for later use -->
41 <xsl:variable name="frame_num" select="proto[@name='frame']/field[@name='frame.number']/@show"/>
42 <xsl:variable name="frame_id" select="concat('f',$frame_num)"/>
43 <xsl:variable name="frame_c" select="concat($frame_id,'c')"/>
45 <!-- the "title" bar of the frame -->
46 <div width="100%" id="{$frame_id}">
47 <a href="javascript:toggle_node('{$frame_c}')">⇒</a> <!-- #8658 is a "rArr" (double right arrow) character -->
48 Frame <xsl:value-of select="$frame_num"/>:
49 <xsl:for-each select="proto[@name!='geninfo']">
50 <xsl:value-of select="@name"/>,
52 <small><a href="javascript:hide_node('{$frame_id}')">[X]</a></small>
55 <!-- the frame contents are stored in a div, so we can toggle it -->
56 <div width="100%" id="{$frame_c}" style="display:none">
57 <!-- loop through all proto tags, but skip the "geninfo" one -->
58 <xsl:for-each select="proto[@name!='geninfo']">
60 <xsl:variable name="proto" select="concat($frame_id,@name,count(preceding-sibling::proto)+1)"/>
62 <!-- the "title" bar of the proto -->
63 <div width="100%" style="background-color:#e5e5e5; margin-bottom: 2px">
64  <a href="javascript:toggle_node('{$proto}')">⇒</a> <xsl:value-of select="@showname"/>
66 <!-- print "proto" details inside another div -->
67 <div width="100%" id="{$proto}" style="display:none">
68 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
74 <!-- use the javascript function set_node_color() to set the color
75 of the frame title bar. Defer colorization until the full page has
76 been loaded. If the browser would support the XPath function
77 replace() we could simply set the class attribute of the title bar div,
78 but for now we're stuck with class names from Wireshark's colorfilters
79 that contain spaces and we can't handle them in CSS. -->
80 <script type="text/javascript">
81 dojo.addOnLoad(function(){
83 '<xsl:value-of select="$frame_id"/>',
84 '<xsl:value-of select="proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
90 <xsl:template match="pdml">
91 Capture Filename: <b><xsl:value-of select="@capture_file"/></b>
92 PDML created: <b><xsl:value-of select="@time"/></b>
94 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
98 <!-- this block matches the start of the PDML file -->
99 <xsl:template match="/">
102 <title>poor man's Wireshark</title>
103 <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" type="text/javascript"></script>
104 <script type="text/javascript">
105 function set_node(node, str)
107 if(dojo.isString(node))
108 node = dojo.byId(node);
110 node.style.display = str;
112 function toggle_node(node)
114 if(dojo.isString(node))
115 node = dojo.byId(node);
117 set_node(node, (node.style.display != 'none') ? 'none' : 'block');
119 function hide_node(node)
121 set_node(node, 'none');
123 // this function was generated by colorfilters2js.pl
124 function set_node_color(node,colorname)
126 if(dojo.isString(node))
127 node = dojo.byId(node);
131 if(colorname == 'Bad TCP') {
135 if(colorname == 'HSRP State Change') {
139 if(colorname == 'Spanning Tree Topology Change') {
143 if(colorname == 'OSPF State Change') {
147 if(colorname == 'ICMP errors') {
151 if(colorname == 'ARP') {
155 if(colorname == 'ICMP') {
159 if(colorname == 'TCP RST') {
163 if(colorname == 'TTL low or unexpected') {
167 if(colorname == 'Checksum Errors') {
171 if(colorname == 'SMB') {
175 if(colorname == 'HTTP') {
179 if(colorname == 'IPX') {
183 if(colorname == 'DCERPC') {
187 if(colorname == 'Routing') {
191 if(colorname == 'TCP SYN/FIN') {
195 if(colorname == 'TCP') {
199 if(colorname == 'UDP') {
203 if(colorname == 'Broadcast') {
208 node.style.color = fg;
210 node.style.background = bg;
215 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->