summaryrefslogtreecommitdiff
path: root/protocol/protocol.xsl
blob: b2867f0fcc2aae31135696d8387ea163ab313dd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" encoding="UTF-8"/>
<xsl:preserve-space elements="copyright"/>
<xsl:template match="/">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link href="wayland.css" rel="stylesheet" type="text/css" />
    <title>Wayland</title>
  </head>
  <body>
    <h1><img src="wayland.png" alt="Wayland logo" /></h1>
    <h1>Wayland Protocol Specification</h1>

    <!-- Copyright blurb -->
    <xsl:apply-templates select="protocol/copyright"/>

    <!-- TOC -->
    <xsl:apply-templates select="protocol" mode="toc" />

    <!-- Interface descriptions -->
    <xsl:apply-templates select="protocol/interface" mode="interface_description" />

  </body>
</html>
</xsl:template>

<!-- Copyright blurb -->
<xsl:template match="copyright">
  <div>
    <pre class="copyright">
      <xsl:value-of select="." disable-output-escaping="yes"/>
    </pre>
  </div>
</xsl:template>

<!-- TOC -->
<xsl:template match="protocol" mode="toc">
  <div class="toc">
    <h2>Table of Contents</h2>
    <ul>
      <xsl:apply-templates select="interface" mode="toc" />
    </ul>
  </div>
</xsl:template>

<!-- interface in TOC -->
<xsl:template match="interface" mode="toc">
  <li>
    <xsl:call-template name="link">
      <xsl:with-param name="which" select="'href'" />
    </xsl:call-template>

    <!-- request list -->
    <xsl:if test="request">
      <div>
	Requests:
	<ul>
	  <xsl:apply-templates select="request" mode="toc"/>
	</ul>
      </div>
    </xsl:if>

    <!-- event list -->
    <xsl:if test="event">
      <div>
	Events:
	<ul>
	  <xsl:apply-templates select="event" mode="toc"/>
	</ul>
      </div>
    </xsl:if>

    <!-- enum list -->
    <xsl:if test="enum">
      <div>
	Enums:
	<ul>
	  <xsl:apply-templates select="enum" mode="toc"/>
	</ul>
      </div>
    </xsl:if>
  </li>
</xsl:template>

<!--
  Template to create a <a> tag in the form
    #<interfacename>-<request|event>-<request/event name>
  the '#' prefix is added if $which is 'href'
  $which decides which attribute name (href or name) of <a> to set
-->
<xsl:template name="link" >
  <xsl:param name="which" />
  <a>
    <xsl:attribute name="{$which}">
      <xsl:if test="$which = 'href'">#</xsl:if>
      <xsl:value-of select="../@name"/>
      <xsl:text>-</xsl:text> <!-- xsl:text needed to avoid whitespace -->
      <xsl:value-of select="name()"/>
      <xsl:text>-</xsl:text> <!-- xsl:text needed to avoid whitespace -->
      <xsl:value-of select="@name"/></xsl:attribute>
      <!-- only display link text for href links -->
      <xsl:if test="$which = 'href'">
	<span class="mono"><xsl:value-of select="@name"/></span>
	<xsl:if test="description/@summary"> - <xsl:value-of select="description/@summary"/></xsl:if>
      </xsl:if>
  </a>
</xsl:template>

<!-- requests and events in TOC -->
<xsl:template match="request|event|enum" mode="toc">
  <li>
    <xsl:call-template name="link">
      <xsl:with-param name="which" select="'href'" />
    </xsl:call-template>
  </li>
</xsl:template>

<!-- Interface descriptions -->
<xsl:template match="protocol/interface" mode="interface_description">
  <div class="interface">
    <xsl:call-template name="link">
      <xsl:with-param name="which" select="'name'" />
    </xsl:call-template>
    <h1>
      <span class="mono"><xsl:value-of select="@name" /></span>
      <!-- only show summary if it exists -->
      <xsl:if test="description/@summary">
	- <xsl:value-of select="description/@summary" />
      </xsl:if>
    </h1>
    <p class="version">Version: <xsl:value-of select="@version" /></p>
    <p><xsl:value-of select="description"/></p>
    <xsl:if test="request">
      <div class="requests">
	<h2>Requests</h2>
	<!-- Request list -->
	<xsl:apply-templates select="request" mode="interface_description" />
      </div>
    </xsl:if>

    <xsl:if test="event">
      <div class="events">
	<h2>Events</h2>
	<!-- Event list -->
	<xsl:apply-templates select="event" mode="interface_description" />
      </div>
    </xsl:if>

    <xsl:if test="enum">
      <div class="enums">
	<h2>Enums</h2>
	<!-- enum list -->
	<xsl:apply-templates select="enum" mode="interface_description"/>
      </div>
    </xsl:if>
  </div>
</xsl:template>

<!-- table contents for request/event arguments or enum values -->
<xsl:template match="arg|entry">
  <tr>
    <td class="arg_name"><xsl:value-of select="@name"/></td>
    <xsl:if test="name() = 'arg'" >
      <td class="arg_type"><xsl:value-of select="@type"/></td>
    </xsl:if>
    <xsl:if test="name() = 'entry'" >
      <td class="arg_value"><xsl:value-of select="@value"/></td>
    </xsl:if>
    <td class="arg_desc"><xsl:value-of select="@summary"/></td>
  </tr>
</xsl:template>

<!-- Request/event list -->
<xsl:template match="request|event|enum" mode="interface_description">
  <div>
    <xsl:call-template name="link">
      <xsl:with-param name="which" select="'name'" />
    </xsl:call-template>
    <h3>
      <span class="mono"><xsl:value-of select="../@name"/>::<xsl:value-of select="@name" /></span>
      <xsl:if test="description/@summary">
	- <xsl:value-of select="description/@summary" />
      </xsl:if>
    </h3>
    <p><xsl:value-of select="description"/></p>
    <xsl:if test="arg">
      Arguments:
      <table>
	<xsl:apply-templates select="arg"/>
      </table>
    </xsl:if>
    <xsl:if test="entry">
      Values:
      <table>
	<xsl:apply-templates select="entry"/>
      </table>
    </xsl:if>
  </div>
</xsl:template>
</xsl:stylesheet>

<!-- vim: set expandtab shiftwidth=2: -->