packet-ldap: fix regression for SASL handling
[wireshark-sm.git] / pdml2html.xsl
blob37f70e213cbffda83b2dba62d326b4f3959a0a73
1 <?xml version="1.0"?>
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).
9 Version: 2010-06-09
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
16 -->
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 &#160;&#160;&#160; <!-- indent with 3 non-breaking spaces -->
25 <!-- output either the "showname" or "show" attribute -->
26 <xsl:choose>
27 <xsl:when test="string-length(@showname)>0">
28 <xsl:value-of select="@showname"/><br/>
29 </xsl:when>
30 <xsl:otherwise>
31 <!--<xsl:value-of select="@name"/>:--> <xsl:value-of select="@show"/><br/>
32 </xsl:otherwise>
33 </xsl:choose>
35 <xsl:apply-templates/> <!-- we expect to match "field" tags -->
36 </xsl:template>
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}')">&#8658;</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"/>,
52 </xsl:for-each>
53 <small><a href="javascript:hide_node('{$frame_id}')">[X]</a></small>
54 </div>
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 &#160;<a href="javascript:toggle_node('{$proto}')">&#8658;</a>&#160;<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 -->
70 </div>
71 </div>
72 </xsl:for-each>
73 </div>
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(){
83 set_node_color(
84 '<xsl:value-of select="$frame_id"/>',
85 '<xsl:value-of select="proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
87 });
88 </script>
89 </xsl:template>
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>
94 <tt>
95 <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
96 </tt>
97 </xsl:template>
99 <!-- this block matches the start of the PDML file -->
100 <xsl:template match="/">
101 <html>
102 <head>
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);
110 if(!node) return;
111 node.style.display = str;
113 function toggle_node(node)
115 if(dojo.isString(node))
116 node = dojo.byId(node);
117 if(!node) return;
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);
129 if(!node) return;
130 var fg;
131 var bg;
132 if(colorname == 'Bad TCP') {
133 bg='#000000';
134 fg='#ff5f5f';
136 if(colorname == 'HSRP State Change') {
137 bg='#000000';
138 fg='#fff600';
140 if(colorname == 'Spanning Tree Topology Change') {
141 bg='#000000';
142 fg='#fff600';
144 if(colorname == 'OSPF State Change') {
145 bg='#000000';
146 fg='#fff600';
148 if(colorname == 'ICMP errors') {
149 bg='#000000';
150 fg='#00ff0e';
152 if(colorname == 'ARP') {
153 bg='#d6e8ff';
154 fg='#000000';
156 if(colorname == 'ICMP') {
157 bg='#c2c2ff';
158 fg='#000000';
160 if(colorname == 'TCP RST') {
161 bg='#900000';
162 fg='#fff680';
164 if(colorname == 'TTL low or unexpected') {
165 bg='#900000';
166 fg='#ffffff';
168 if(colorname == 'Checksum Errors') {
169 bg='#000000';
170 fg='#ff5f5f';
172 if(colorname == 'SMB') {
173 bg='#fffa99';
174 fg='#000000';
176 if(colorname == 'HTTP') {
177 bg='#8dff7f';
178 fg='#000000';
180 if(colorname == 'IPX') {
181 bg='#ffe3e5';
182 fg='#000000';
184 if(colorname == 'DCERPC') {
185 bg='#c797ff';
186 fg='#000000';
188 if(colorname == 'Routing') {
189 bg='#fff3d6';
190 fg='#000000';
192 if(colorname == 'TCP SYN/FIN') {
193 bg='#a0a0a0';
194 fg='#000000';
196 if(colorname == 'TCP') {
197 bg='#e7e6ff';
198 fg='#000000';
200 if(colorname == 'UDP') {
201 bg='#70e0ff';
202 fg='#000000';
204 if(colorname == 'Broadcast') {
205 bg='#ffffff';
206 fg='#808080';
208 if(fg.length > 0)
209 node.style.color = fg;
210 if(bg.length > 0)
211 node.style.background = bg;
213 </script>
214 </head>
215 <body>
216 <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->
217 </body>
218 </html>
219 </xsl:template>
221 </xsl:stylesheet>