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