xref: /aosp_15_r20/external/apache-xml/test/tests/contrib/xsltc/mk/mk003.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<xsl:stylesheet
2
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
5   version="1.0">
6
7
8
9  <!-- Test FileName: mk003.xsl -->
10
11  <!-- Source Attribution:
12
13       This test was written by Michael Kay and is taken from
14
15       'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
16
17       ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved.
18
19       Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
20
21       No part of this book may be reproduced, stored in a retrieval system or
22
23       transmitted in any form or by any means - electronic, electrostatic, mechanical,
24
25       photocopying, recording or otherwise - without the prior written permission of
26
27       the publisher, except in the case of brief quotations embodied in critical articles or reviews.
28
29  -->
30
31  <!-- Example:  Displaying a Poem (poem.xml, poem.xsl) -->
32
33  <!-- Chapter/Page: 1-36 -->
34
35  <!-- Purpose:  Show rules based approach to formatting -->
36
37
38
39<xsl:template match="poem">
40
41<html>
42
43<head>
44
45	<title><xsl:value-of select="title"/></title>
46
47</head>
48
49<body>
50
51	<xsl:apply-templates select="title"/>
52
53	<xsl:apply-templates select="author"/>
54
55	<xsl:apply-templates select="stanza"/>
56
57	<xsl:apply-templates select="date"/>
58
59</body>
60
61</html>
62
63</xsl:template>
64
65
66
67<xsl:template match="title">
68
69<div align="center"><h1><xsl:value-of select="."/></h1></div>
70
71</xsl:template>
72
73
74
75<xsl:template match="author">
76
77<div align="center"><h2>By <xsl:value-of select="."/></h2></div>
78
79</xsl:template>
80
81
82
83<xsl:template match="stanza">
84
85<p><xsl:apply-templates select="line"/></p>
86
87</xsl:template>
88
89
90
91<xsl:template match="line">
92
93<xsl:if test="position() mod 2 = 0">&#160;&#160;</xsl:if>
94
95<xsl:value-of select="."/><br/>
96
97</xsl:template>
98
99
100
101<xsl:template match="date">
102
103<p><i><xsl:value-of select="."/></i></p>
104
105</xsl:template>
106
107  <!--
108   * Licensed to the Apache Software Foundation (ASF) under one
109   * or more contributor license agreements. See the NOTICE file
110   * distributed with this work for additional information
111   * regarding copyright ownership. The ASF licenses this file
112   * to you under the Apache License, Version 2.0 (the  "License");
113   * you may not use this file except in compliance with the License.
114   * You may obtain a copy of the License at
115   *
116   *     http://www.apache.org/licenses/LICENSE-2.0
117   *
118   * Unless required by applicable law or agreed to in writing, software
119   * distributed under the License is distributed on an "AS IS" BASIS,
120   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121   * See the License for the specific language governing permissions and
122   * limitations under the License.
123  -->
124
125</xsl:stylesheet>
126