source: rfc2629xslt/xslt-test.xslt @ 24

Last change on this file since 24 was 6, checked in by fielding@…, 15 years ago

XSLT stylesheet for enhanced RFC2629 xml2rfc output as HTML.
By Julian Reschke

Obtained from: wget -N http://www.greenbytes.de/tech/webdav/rfc2629xslt.zip

  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
1<!--
2    XSLT test cases
3
4    Copyright (c) 2007, Julian Reschke (julian.reschke@greenbytes.de)
5    All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are met:
9
10    * Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    * Neither the name of Julian Reschke nor the names of its contributors
16      may be used to endorse or promote products derived from this software
17      without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29    POSSIBILITY OF SUCH DAMAGE.
30-->
31
32<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33                version="1.0"
34                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
35                xmlns:exslt="http://exslt.org/common"
36                exclude-result-prefixes="msxsl exslt">
37
38<xsl:output method="html" encoding="iso-8859-1" version="4.0" doctype-public="-//W3C//DTD HTML 4.01//EN" indent="no"/>
39
40<xsl:template match="/">
41  <html>
42    <head>
43      <title>XSLT test cases</title>
44      <style type="text/css">
45        body {
46          font-family: verdana, helvetica, arial, sans-serif;
47          font-size: 10pt;
48        }
49        td {
50          text-align: left;
51        }
52        th {
53          text-align: left;
54        }
55        h1 {
56          font-size: 14pt;
57        }
58        h2 {
59          font-size: 12pt;
60        }
61        .green {
62          color: green;
63        }
64        .red {
65          color: red;
66        }
67      </style>
68    </head>
69    <body>
70      <h1>XSLT test cases</h1>
71     
72      <xsl:call-template name="info"/>
73      <xsl:call-template name="nodeset"/>
74      <xsl:call-template name="whitespace-treatment"/>
75    </body>
76  </html>
77</xsl:template>
78
79<xsl:template name="info">
80  <h2 id="engine.information">Engine Information</h2>
81
82  <table>
83    <thead>
84      <tr>
85        <th><a href="http://www.w3.org/TR/xslt#function-system-property">System Property</a></th>
86        <th>Value</th>
87      </tr>
88    </thead>
89    <tbody>
90      <tr>
91        <td>
92          <code>
93            xsl:version
94          </code>
95        </td>
96        <td>
97          <tt>
98            <xsl:value-of select="system-property('xsl:version')"/>
99          </tt>
100        </td>
101      </tr>
102      <tr>
103        <td>
104          <code>
105            xsl:vendor
106          </code>
107        </td>
108        <td>
109          <tt>
110            <xsl:value-of select="system-property('xsl:vendor')"/>
111          </tt>
112        </td>
113      </tr>
114      <tr>
115        <td>
116          <code>
117            xsl:vendor-url
118          </code>
119        </td>
120        <td>
121          <tt>
122            <a href="{system-property('xsl:vendor-url')}"><xsl:value-of select="system-property('xsl:vendor-url')"/></a>
123          </tt>
124        </td>
125      </tr>
126    </tbody>
127  </table>
128</xsl:template>
129
130<xsl:template name="nodeset">
131  <h2 id="node-set">Node-Set Support</h2>
132 
133  <table>
134    <thead>
135      <tr>
136        <th>Nodeset Extension</th>
137        <th>Available?</th>
138      </tr>
139    </thead>
140    <tbody>
141      <tr>
142        <td>
143          <code>
144            <a href="http://www.exslt.org/exsl/functions/node-set/exsl.node-set.html">exslt:node-set</a>
145          </code>
146        </td>
147        <td>
148          <xsl:choose>
149            <xsl:when test="function-available('exslt:node-set')">
150              <div class="green">Yes</div>
151            </xsl:when>
152            <xsl:otherwise>
153              <div class="red">No</div>
154            </xsl:otherwise>
155          </xsl:choose>
156        </td>
157      </tr>
158      <tr>
159        <td>
160          <code>
161            <a href="http://msdn2.microsoft.com/en-us/library/ms256197.aspx">msxsl:node-set</a>
162          </code>
163        </td>
164        <td>
165          <xsl:choose>
166            <xsl:when test="function-available('msxsl:node-set')">
167              <div class="green">Yes</div>
168            </xsl:when>
169            <xsl:otherwise>
170              No
171            </xsl:otherwise>
172          </xsl:choose>
173        </td>
174      </tr>
175    </tbody>
176  </table>
177</xsl:template>
178
179<xsl:template name="whitespace-treatment">
180  <h2 id="whitespace">Whitespace Treatment</h2>
181
182  <p>
183    Whitespace between elements is respected:
184    <xsl:choose>
185      <xsl:when test="/*/whitespace-test[@id='ws-def']/text()">
186        <span class="green">Yes</span>
187      </xsl:when>
188      <xsl:otherwise>
189        <span class="red">No</span>
190      </xsl:otherwise>
191    </xsl:choose>
192  </p>
193  <p>
194    Whitespace between elements respected when xml:space='preserved' :
195    <xsl:choose>
196      <xsl:when test="/*/whitespace-test[@id='ws-pres']/text()">
197        <span class="green">Yes</span>
198      </xsl:when>
199      <xsl:otherwise>
200        <span class="red">No</span>
201      </xsl:otherwise>
202    </xsl:choose>
203  </p>
204</xsl:template>
205
206</xsl:transform>
Note: See TracBrowser for help on using the repository browser.