[SDNC-5] Rebase sdnc-core
[sdnc/core.git] / dblib / common / doc / package.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3   Licensed to the Apache Software Foundation (ASF) under one or more
4   contributor license agreements.  See the NOTICE file distributed with
5   this work for additional information regarding copyright ownership.
6   The ASF licenses this file to You under the Apache License, Version 2.0
7   (the "License"); you may not use this file except in compliance with
8   the License.  You may obtain a copy of the License at
9
10       http://www.apache.org/licenses/LICENSE-2.0
11
12   Unless required by applicable law or agreed to in writing, software
13   distributed under the License is distributed on an "AS IS" BASIS,
14   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   See the License for the specific language governing permissions and
16   limitations under the License.
17 -->
18 <!--
19   Stylesheet that generates "package.html" for Javadoc tool
20   from jdbc-pool.xml documentation file.
21   It is based on "tomcat-docs" stylesheet, but it needs to avoid
22   generating complicated headers and footers, as those cannot be
23   digested by Javadoc tool and break layout of javadoc pages.
24 -->
25 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
26   version="1.0">
27
28
29   <!-- Output method -->
30   <xsl:output method="html"
31             encoding="UTF-8"
32               indent="no"/>
33
34
35   <!-- Defined parameters (overrideable) -->
36   <xsl:param    name="relative-path"    select="'.'"/>
37   <xsl:param    name="void-image"       select="'/images/void.gif'"/>
38   <xsl:param    name="standalone"       select="''"/>
39   <xsl:param    name="buglink"          select="'http://bz.apache.org/bugzilla/show_bug.cgi?id='"/>
40   <xsl:param    name="revlink"          select="'http://svn.apache.org/viewvc?view=rev&amp;rev='"/>
41
42   <!-- Defined variables (non-overrideable) -->
43   <xsl:variable name="body-bg"          select="'#ffffff'"/>
44   <xsl:variable name="body-fg"          select="'#000000'"/>
45   <xsl:variable name="body-link"        select="'#525D76'"/>
46   <xsl:variable name="banner-bg"        select="'#525D76'"/>
47   <xsl:variable name="banner-fg"        select="'#ffffff'"/>
48   <xsl:variable name="sub-banner-bg"    select="'#828DA6'"/>
49   <xsl:variable name="sub-banner-fg"    select="'#ffffff'"/>
50   <xsl:variable name="source-color"     select="'#023264'"/>
51   <xsl:variable name="attributes-color" select="'#023264'"/>
52   <xsl:variable name="table-th-bg"      select="'#039acc'"/>
53   <xsl:variable name="table-td-bg"      select="'#a0ddf0'"/>
54
55   <!-- Process an entire document into an HTML page -->
56   <xsl:template match="document">
57   <xsl:variable name="project"
58               select="document('project.xml')/project"/>
59     <html>
60     <head>
61     <title><xsl:value-of select="project/title"/> - <xsl:value-of select="properties/title"/></title>
62     </head>
63
64     <body bgcolor="{$body-bg}" text="{$body-fg}" link="{$body-link}"
65           alink="{$body-link}" vlink="{$body-link}">
66
67           <h2><xsl:value-of select="properties/title"/>.</h2>
68           <xsl:apply-templates select="body/section"/>
69     </body>
70     </html>
71
72   </xsl:template>
73
74
75   <!-- Process a documentation section -->
76   <xsl:template match="section">
77     <xsl:variable name="name">
78       <xsl:value-of select="@name"/>
79     </xsl:variable>
80     <table border="0" cellspacing="0" cellpadding="2">
81       <!-- Section heading -->
82       <tr><td bgcolor="{$banner-bg}">
83           <font color="{$banner-fg}" face="arial,helvetica.sanserif">
84           <a name="{$name}">
85           <strong><xsl:value-of select="@name"/></strong></a></font>
86       </td></tr>
87       <!-- Section body -->
88       <tr><td><blockquote>
89         <xsl:apply-templates/>
90       </blockquote></td></tr>
91     </table>
92   </xsl:template>
93
94
95   <!-- Process a documentation subsection -->
96   <xsl:template match="subsection">
97     <xsl:variable name="name">
98       <xsl:value-of select="@name"/>
99     </xsl:variable>
100     <table border="0" cellspacing="0" cellpadding="2">
101       <!-- Subsection heading -->
102       <tr><td bgcolor="{$sub-banner-bg}">
103           <font color="{$sub-banner-fg}" face="arial,helvetica.sanserif">
104           <a name="{$name}">
105           <strong><xsl:value-of select="@name"/></strong></a></font>
106       </td></tr>
107       <!-- Subsection body -->
108       <tr><td><blockquote>
109         <xsl:apply-templates/>
110       </blockquote></td></tr>
111     </table>
112   </xsl:template>
113
114
115   <!-- Process a source code example -->
116   <xsl:template match="source">
117     <xsl:variable name="void">
118       <xsl:value-of select="$relative-path"/><xsl:value-of select="$void-image"/>
119     </xsl:variable>
120     <div align="left">
121       <table cellspacing="4" cellpadding="0" border="0">
122         <tr>
123           <td bgcolor="{$source-color}" width="1" height="1">
124             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
125           </td>
126           <td bgcolor="{$source-color}" height="1">
127             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
128           </td>
129           <td bgcolor="{$source-color}" width="1" height="1">
130             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
131           </td>
132         </tr>
133         <tr>
134           <td bgcolor="{$source-color}" width="1">
135             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
136           </td>
137           <td bgcolor="#ffffff" height="1"><pre>
138             <xsl:value-of select="."/>
139           </pre></td>
140           <td bgcolor="{$source-color}" width="1">
141             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
142           </td>
143         </tr>
144         <tr>
145           <td bgcolor="{$source-color}" width="1" height="1">
146             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
147           </td>
148           <td bgcolor="{$source-color}" height="1">
149             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
150           </td>
151           <td bgcolor="{$source-color}" width="1" height="1">
152             <img src="{$void}" width="1" height="1" vspace="0" hspace="0" border="0"/>
153           </td>
154         </tr>
155       </table>
156     </div>
157   </xsl:template>
158
159
160   <!-- Process an attributes list with nested attribute elements -->
161   <xsl:template match="attributes">
162     <table border="1" cellpadding="5">
163       <tr>
164         <th width="15%" bgcolor="{$attributes-color}">
165           <font color="#ffffff">Attribute</font>
166         </th>
167         <th width="85%" bgcolor="{$attributes-color}">
168           <font color="#ffffff">Description</font>
169         </th>
170       </tr>
171       <xsl:for-each select="attribute">
172         <tr>
173           <td align="left" valign="center">
174             <xsl:if test="@required = 'true'">
175               <strong><code><xsl:value-of select="@name"/></code></strong>
176             </xsl:if>
177             <xsl:if test="@required != 'true'">
178               <code><xsl:value-of select="@name"/></code>
179             </xsl:if>
180           </td>
181           <td align="left" valign="center">
182             <xsl:apply-templates/>
183           </td>
184         </tr>
185       </xsl:for-each>
186     </table>
187   </xsl:template>
188
189   <!-- Process a properties list with nested property elements -->
190   <xsl:template match="properties">
191     <table border="1" cellpadding="5">
192       <tr>
193         <th width="15%" bgcolor="{$attributes-color}">
194           <font color="#ffffff">Property</font>
195         </th>
196         <th width="85%" bgcolor="{$attributes-color}">
197           <font color="#ffffff">Description</font>
198         </th>
199       </tr>
200       <xsl:for-each select="property">
201         <tr>
202           <td align="left" valign="center">
203             <code><xsl:value-of select="@name"/></code>
204           </td>
205           <td align="left" valign="center">
206             <xsl:apply-templates/>
207           </td>
208         </tr>
209       </xsl:for-each>
210     </table>
211   </xsl:template>
212
213   <!-- Fix relative links in printer friendly versions of the docs -->
214   <xsl:template match="a">
215     <xsl:variable name="href" select="@href"/>
216     <xsl:choose>
217       <xsl:when test="$standalone = 'standalone'">
218         <xsl:apply-templates/>
219       </xsl:when>
220       <xsl:when test="$href != ''">
221         <a href="{$href}"><xsl:apply-templates/></a>
222       </xsl:when>
223       <xsl:otherwise>
224         <xsl:variable name="name" select="@name"/>
225         <a name="{$name}"><xsl:apply-templates/></a>
226       </xsl:otherwise>
227     </xsl:choose>
228   </xsl:template>
229
230   <!-- Link to a bug report -->
231   <xsl:template match="bug">
232       <xsl:variable name="link"><xsl:value-of select="$buglink"/><xsl:value-of select="text()"/></xsl:variable>
233       <a href="{$link}"><xsl:apply-templates/></a>
234   </xsl:template>
235
236   <!-- Link to a SVN revision report -->
237   <xsl:template match="rev">
238       <xsl:variable name="link"><xsl:value-of select="$revlink"/><xsl:value-of select="text()"/></xsl:variable>
239       <a href="{$link}"><xsl:apply-templates/></a>
240   </xsl:template>
241
242   <!-- Process everything else by just passing it through -->
243   <xsl:template match="*|@*">
244     <xsl:copy>
245       <xsl:apply-templates select="@*|*|text()"/>
246     </xsl:copy>
247   </xsl:template>
248
249 </xsl:stylesheet>