• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" ?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3<xsl:output method="xml" encoding="UTF-8" indent="yes" />
4
5<xsl:template match="/">
6  <!-- insert docbook's DOCTYPE blurb -->
7    <xsl:text disable-output-escaping = "yes"><![CDATA[
8<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
9  <!ENTITY % BOOK_ENTITIES SYSTEM "Wayland.ent">
10%BOOK_ENTITIES;
11]>
12]]></xsl:text>
13
14  <appendix id="appe-Wayland-Protocol">
15    <title>Wayland Protocol Specification</title>
16    <xsl:apply-templates select="protocol/copyright" />
17
18    <xsl:apply-templates select="protocol/interface" />
19  </appendix>
20</xsl:template>
21
22<!-- Break text blocks separated by two new lines into paragraphs -->
23<xsl:template name="break">
24     <xsl:param name="text" />
25     <xsl:param name="linebreak" select="'&#10;&#10;'" />
26     <xsl:choose>
27       <xsl:when test="contains($text,$linebreak)">
28         <para>
29           <xsl:value-of select="substring-before($text,$linebreak)" />
30         </para>
31         <xsl:call-template name="break">
32           <xsl:with-param name="text" select="substring-after($text,$linebreak)" />
33         </xsl:call-template>
34       </xsl:when>
35       <xsl:otherwise>
36         <para><xsl:value-of select="$text" /></para>
37       </xsl:otherwise>
38     </xsl:choose>
39</xsl:template>
40
41<!-- Copyright blurb -->
42<xsl:template match="copyright">
43  <para>
44    <literallayout>
45      <xsl:value-of select="." disable-output-escaping="yes"/>
46    </literallayout>
47  </para>
48</xsl:template>
49
50<!-- Interface descriptions -->
51<xsl:template match="interface" >
52  <section id="protocol-spec-{@name}">
53    <title>
54      <xsl:value-of select="@name" />
55      <!-- only show summary if it exists -->
56      <xsl:if test="description/@summary">
57	- <xsl:value-of select="description/@summary" />
58      </xsl:if>
59    </title>
60    <xsl:call-template name="break">
61      <xsl:with-param name="text" select="description" />
62    </xsl:call-template>
63    <xsl:if test="request">
64      <section>
65        <title>Requests provided by <xsl:value-of select="@name" /></title>
66        <xsl:apply-templates select="request" />
67      </section>
68    </xsl:if>
69    <xsl:if test="event">
70      <section>
71        <title>Events provided by <xsl:value-of select="@name" /></title>
72        <xsl:apply-templates select="event" />
73      </section>
74    </xsl:if>
75    <xsl:if test="enum">
76      <section>
77        <title>Enums provided by <xsl:value-of select="@name" /></title>
78      <xsl:apply-templates select="enum" />
79      </section>
80    </xsl:if>
81  </section>
82</xsl:template>
83
84<!-- table contents for enum values -->
85<xsl:template match="entry">
86  <varlistentry>
87    <term><xsl:value-of select="@name"/></term>
88    <listitem>
89      <simpara>
90        <xsl:value-of select="@value"/>
91        <xsl:if test="@summary" >
92          - <xsl:value-of select="@summary"/>
93        </xsl:if>
94      </simpara>
95    </listitem>
96  </varlistentry>
97</xsl:template>
98
99<!-- table contents for request/event arguments -->
100<xsl:template match="arg">
101  <varlistentry>
102    <term><xsl:value-of select="@name"/></term>
103    <listitem>
104        <simpara>
105          <xsl:value-of select="@type"/>
106          <xsl:if test="@summary" >
107            - <xsl:value-of select="@summary"/>
108          </xsl:if>
109        </simpara>
110    </listitem>
111  </varlistentry>
112</xsl:template>
113
114<!-- id arguments -->
115<xsl:template match="arg[@type='object' and @interface]">
116  <varlistentry>
117    <term><xsl:value-of select="@name"/></term>
118    <listitem>
119        <simpara>
120          <link linkend="protocol-spec-{@interface}">
121            <xsl:value-of select="@interface"/>
122          </link>
123          <xsl:if test="@summary" >
124            - <xsl:value-of select="@summary"/>
125          </xsl:if>
126        </simpara>
127    </listitem>
128  </varlistentry>
129</xsl:template>
130
131<!-- new_id arguments -->
132<xsl:template match="arg[@type='new_id' and @interface]">
133  <varlistentry>
134    <term><xsl:value-of select="@name"/></term>
135    <listitem>
136        <simpara>
137          id for the new
138          <link linkend="protocol-spec-{@interface}">
139            <xsl:value-of select="@interface"/>
140          </link>
141          <xsl:if test="@summary" >
142            - <xsl:value-of select="@summary"/>
143          </xsl:if>
144        </simpara>
145    </listitem>
146  </varlistentry>
147</xsl:template>
148
149<!-- enum and bitfield arguments -->
150<xsl:template match="arg[@enum]">
151  <varlistentry>
152    <term><xsl:value-of select="@name"/></term>
153    <listitem>
154        <simpara>
155          <xsl:choose>
156            <xsl:when test="contains(@enum, '.')">
157              <link linkend="protocol-spec-{substring-before(@enum, '.')}-enum-{substring-after(@enum, '.')}">
158                <xsl:value-of select="substring-before(@enum, '.')"/>
159                <xsl:text>::</xsl:text>
160                <xsl:value-of select="substring-after(@enum, '.')"/>
161              </link>
162            </xsl:when>
163            <xsl:otherwise>
164              <link linkend="protocol-spec-{../../@name}-enum-{@enum}">
165                <xsl:value-of select="../../@name"/>
166                <xsl:text>::</xsl:text>
167                <xsl:value-of select="@enum"/>
168              </link>
169            </xsl:otherwise>
170          </xsl:choose>
171          (<xsl:value-of select="@type"/>)
172          <xsl:if test="@summary" >
173            - <xsl:value-of select="@summary"/>
174          </xsl:if>
175        </simpara>
176    </listitem>
177  </varlistentry>
178</xsl:template>
179
180<!-- Request/event list -->
181<xsl:template match="request|event">
182  <section id="protocol-spec-{../@name}-{name()}-{@name}">
183    <title>
184      <xsl:value-of select="../@name"/>::<xsl:value-of select="@name" />
185      <xsl:if test="description/@summary">
186        - <xsl:value-of select="description/@summary" />
187      </xsl:if>
188    </title>
189    <para>
190      <variablelist>
191        <xsl:apply-templates select="arg"/>
192      </variablelist>
193    </para>
194    <xsl:call-template name="break">
195      <xsl:with-param name="text" select="description" />
196    </xsl:call-template>
197  </section>
198</xsl:template>
199
200<!-- Enumeration -->
201<xsl:template match="enum">
202  <section id="protocol-spec-{../@name}-enum-{@name}">
203    <title>
204      <xsl:value-of select="../@name"/>::<xsl:value-of select="@name" />
205      <xsl:if test="@bitfield">
206        - bitfield
207      </xsl:if>
208      <xsl:if test="description/@summary">
209        - <xsl:value-of select="description/@summary" />
210      </xsl:if>
211    </title>
212    <xsl:call-template name="break">
213      <xsl:with-param name="text" select="description" />
214    </xsl:call-template>
215    <variablelist>
216      <xsl:apply-templates select="entry"/>
217    </variablelist>
218  </section>
219</xsl:template>
220
221</xsl:stylesheet>
222
223<!-- vim: set expandtab shiftwidth=2: -->
224