Debian Codegraph @

tools/pdml.xsl

raw symbols SCIP
1 <?xml version="1.0" encoding='ISO-8859-1' ?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <!--
4 * Copyright (c) 2012 Joerg Wunsch
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 *
20 * $Id: pdml.xsl 320 2013-01-04 20:41:04Z joerg_wunsch $
21 -->
22 <!--
23 * Extract all the interesting (for us) USB packet details from a
24 * Wireshark "packet detail" XML file (PDML). Can be used to
25 * analyze USB data which have been sniffed by Wireshark. Just
26 * export them in PDML format there, and run this stylesheet across
27 * them.
28 -->
29 <xsl:output method="text"/>
30
31 <xsl:template match="/">
32
33 <xsl:for-each select='//pdml/packet/proto/field'>
34
35 <xsl:if test='@name="frame.time_relative"'>
36 <xsl:value-of select='@show' />
37 <xsl:text>: </xsl:text>
38 </xsl:if>
39
40 <xsl:if test='@name="usb.endpoint_number"'>
41 <xsl:if test='@show!="0x80"'>
42 <!-- ignore the CONTROL endpoint data -->
43 <xsl:value-of select='@show' />
44
45 <xsl:for-each select='field'>
46 <xsl:if test='@name="usb.endpoint_number.direction"'>
47 <xsl:choose>
48 <xsl:when test='@show="1"'>
49 <!-- IN transfer -->
50 <xsl:text> &lt;-- </xsl:text>
51 </xsl:when>
52 <xsl:otherwise>
53 <!-- OUT transver -->
54 <xsl:text> --&gt; </xsl:text>
55 </xsl:otherwise>
56 </xsl:choose>
57 </xsl:if>
58 </xsl:for-each>
59 </xsl:if>
60
61 </xsl:if>
62
63 <xsl:if test='@name="usb.capdata"'>
64 <xsl:call-template name="format-hex">
65 <xsl:with-param name="arg" select="@value" />
66 <xsl:with-param name="count" select="0" />
67 </xsl:call-template>
68 <xsl:text>&#10;</xsl:text>
69 </xsl:if>
70
71 </xsl:for-each>
72
73 </xsl:template>
74
75 <!-- Format a string of hex numbers: start a new line -->
76 <!-- after each 8 hex numbers -->
77 <!-- call with parameter $count = 0, calls itself -->
78 <!-- recursively then until everything has been done -->
79 <xsl:template name="format-hex">
80 <xsl:param name="arg" />
81 <xsl:param name="count" />
82 <xsl:choose>
83 <xsl:when test="string-length($arg) &lt;= 2">
84 <!-- Last element, print it, and leave template. -->
85 <xsl:value-of select="$arg" />
86 </xsl:when>
87 <xsl:otherwise>
88 <!--
89 * More arguments follow, print first value,
90 * followed by a comma, decide whether a space
91 * or a newline needs to be emitted, and recurse
92 * with the remaining part of $arg.
93 -->
94 <xsl:value-of select="substring($arg, 1, 2)" />
95 <xsl:choose>
96 <xsl:when test="$count mod 16 = 15">
97 <xsl:text> &#010; </xsl:text>
98 </xsl:when>
99 <xsl:otherwise>
100 <xsl:text> </xsl:text>
101 </xsl:otherwise>
102 </xsl:choose>
103 <xsl:call-template name="format-hex">
104 <xsl:with-param name="arg" select="substring($arg, 3)" />
105 <xsl:with-param name="count" select="$count + 1" />
106 </xsl:call-template>
107 </xsl:otherwise>
108 </xsl:choose>
109 </xsl:template>
110
111 </xsl:stylesheet>