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 <!-- set parameters of the HTML output -->
9 <xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" indent="yes"/>
11 <!-- this matches the "field" tag -->
12 <xsl:template match="field">
13     <!-- indent with 3 non-breaking spaces -->
15 <!-- output either the "showname" or "show" attribute -->
17 <xsl:when test="string-length(@showname)>0">
18 <xsl:value-of select="@showname"/><br/>
21 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select="@show"/><br/>
25 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
28 <!-- this matches the "packet" tag -->
29 <xsl:template match="packet">
31 <!-- declare some variables for later use -->
32 <xsl:variable name="frame_num" select="proto[@name='frame']/field[@name='frame.number']/@show"/>
33 <xsl:variable name="frame_id" select="concat('f',$frame_num)"/>
34 <xsl:variable name="frame_c" select="concat($frame_id,'c')"/>
36 <!-- the "title" bar of the frame -->
37 <div width="100%" id="{$frame_id}">
38 <a href="javascript:toggle_node('{$frame_c}')">⇒</a> <!-- #8658 is a "rArr" (double right arrow) character -->
39 Frame <xsl:value-of select="$frame_num"/>:
40 <xsl:for-each select="proto[@name!='geninfo']">
41 <xsl:value-of select="@name"/>,
43 <small><a href="javascript:hide_node('{$frame_id}')">[X]</a></small>
46 <!-- the frame contents are stored in a div, so we can toggle it -->
47 <div width="100%" id="{$frame_c}" style="display:none">
48 <!-- loop trough all proto tags, but skip the "geninfo" one -->
49 <xsl:for-each select="proto[@name!='geninfo']">
51 <xsl:variable name="proto" select="concat($frame_id,@name)"/>
53 <!-- the "title" bar of the proto -->
54 <div width="100%" style="background-color:#e5e5e5; margin-bottom: 2px">
55  <a href="javascript:toggle_node('{$proto}')">⇒</a> <xsl:value-of select="@showname"/>
57 <!-- print "proto" details inside another div -->
58 <div width="100%" id="{$proto}" style="display:none">
59 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
65 <!-- use the javascript function set_node_color() to set the color
66 of the frame title bar. Defer colorization until the full page has
67 been loaded. If the browser would support the XPath function
68 replace() we could simply set the class attribute of the title bar div,
69 but for now we're stuck with class names from Wireshark's colorfilters
70 that contain spaces and we can't handle them in CSS. -->
71 <script type="text/javascript">
72 dojo.addOnLoad(function(){
74 '<xsl:value-of select="$frame_id"/>',
75 '<xsl:value-of select="proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
81 <xsl:template match="pdml">
82 Capture Filename: <b><xsl:value-of select="@capture_file"/></b>
83 PDML created: <b><xsl:value-of select="@time"/></b>
85 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
89 <!-- this block matches the start of the PDML file -->
90 <xsl:template match="/">
93 <title>poor man's Wireshark</title>
94 <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" type="text/javascript"></script>
95 <script type="text/javascript">
96 function set_node(node, str)
98 if(dojo.isString(node))
99 node = dojo.byId(node);
101 node.style.display = str;
103 function toggle_node(node)
105 if(dojo.isString(node))
106 node = dojo.byId(node);
108 set_node(node, (node.style.display != 'none') ? 'none' : 'block');
110 function hide_node(node)
112 set_node(node, 'none');
114 // this function was generated by colorfilters2js.pl
115 function set_node_color(node,colorname)
117 if(dojo.isString(node))
118 node = dojo.byId(node);
122 if(colorname == 'Bad TCP') {
126 if(colorname == 'HSRP State Change') {
130 if(colorname == 'Spanning Tree Topology Change') {
134 if(colorname == 'OSPF State Change') {
138 if(colorname == 'ICMP errors') {
142 if(colorname == 'ARP') {
146 if(colorname == 'ICMP') {
150 if(colorname == 'TCP RST') {
154 if(colorname == 'TTL low or unexpected') {
158 if(colorname == 'Checksum Errors') {
162 if(colorname == 'SMB') {
166 if(colorname == 'HTTP') {
170 if(colorname == 'IPX') {
174 if(colorname == 'DCERPC') {
178 if(colorname == 'Routing') {
182 if(colorname == 'TCP SYN/FIN') {
186 if(colorname == 'TCP') {
190 if(colorname == 'UDP') {
194 if(colorname == 'Broadcast') {
199 node.style.color = fg;
201 node.style.background = bg;
206 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->