1<?xml version="1.0" encoding="ISO-8859-1" ?> 2<!DOCTYPE xsl:stylesheet [ 3<!ENTITY nbsp " "> 4]> 5<xsl:stylesheet 6 version="1.0" 7 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 8 xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax" 9 exclude-result-prefixes="e" 10> 11 12 <!-- Test FileName: mk056.xsl --> 13 <!-- Source Document: XSLT Programmer's Reference by Michael Kay --> 14 <!-- Example: REC-xslt-19991116.xml, spec.dtd, xslt.xsl --> 15 <!-- Chapter/Page: 9-588 --> 16 <!-- Purpose: Formatting the XSLT Specification --> 17 18<xsl:import href="mk055.xsl"/> 19 20<xsl:strip-space elements="e:*"/> 21 22<xsl:template match="spec" mode="css"> 23<xsl:text>p.element-syntax { border: solid thin }</xsl:text> 24<xsl:apply-imports/> 25</xsl:template> 26 27<xsl:template match="e:element-syntax-summary"> 28 <xsl:for-each select="//e:element-syntax"> 29 <xsl:sort select="@name"/> 30 <p class="element-syntax-summary"><code> 31 <xsl:apply-templates select="e:in-category"/> 32 <xsl:text><</xsl:text> 33 <a href="#element-{@name}"> 34 <xsl:text>xsl:</xsl:text><xsl:value-of select="@name"/> 35 </a> 36 <xsl:apply-templates mode="top"/> 37 </code></p> 38 </xsl:for-each> 39</xsl:template> 40 41<xsl:template match="e:element-syntax"> 42<p class="element-syntax"><a name="element-{@name}"/><code> 43<xsl:apply-templates select="e:in-category"/> 44<xsl:text><xsl:</xsl:text><xsl:value-of select="@name"/> 45<xsl:apply-templates mode="top"/> 46</code></p> 47</xsl:template> 48 49<xsl:template match="e:in-category"> 50<xsl:text><!-- Category: </xsl:text> 51<xsl:value-of select="@name"/> 52<xsl:text> --></xsl:text> 53<br/> 54</xsl:template> 55 56<xsl:template match="e:sequence|e:choice|e:model|e:element|e:text" mode="top"> 57<xsl:text>></xsl:text> 58<br/> 59<xsl:text> <!-- Content: </xsl:text> 60<xsl:apply-templates select="."/> 61<xsl:text> --></xsl:text> 62<br/> 63<xsl:text></xsl:</xsl:text> 64<xsl:value-of select="../@name"/> 65<xsl:text>></xsl:text> 66</xsl:template> 67 68<xsl:template match="e:sequence|e:choice"> 69<xsl:text>(</xsl:text> 70<xsl:apply-templates/> 71<xsl:text>)</xsl:text> 72<xsl:call-template name="repeat"/> 73</xsl:template> 74 75<xsl:template match="e:model"> 76<xsl:call-template name="group"/> 77<var><xsl:value-of select="@name"/></var> 78<xsl:call-template name="repeat"/> 79</xsl:template> 80 81<xsl:template match="e:text">#PCDATA</xsl:template> 82 83<xsl:template match="e:element"> 84<xsl:call-template name="group"/> 85<a href="#element-{@name}"> 86<xsl:text>xsl:</xsl:text> 87<xsl:value-of select="@name"/> 88</a> 89<xsl:call-template name="repeat"/> 90</xsl:template> 91 92<xsl:template name="group"> 93<xsl:if test="position()>1"> 94<xsl:choose> 95<xsl:when test="parent :: e:sequence">, </xsl:when> 96<xsl:when test="parent :: e:choice"> | </xsl:when> 97</xsl:choose> 98</xsl:if> 99</xsl:template> 100 101<xsl:template name="repeat"> 102 <xsl:choose> 103 <xsl:when test="@repeat='one-or-more'"> 104 <xsl:text>+</xsl:text> 105 </xsl:when> 106 <xsl:when test="@repeat='zero-or-more'"> 107 <xsl:text>*</xsl:text> 108 </xsl:when> 109 <xsl:when test="@repeat='zero-or-one'"> 110 <xsl:text>?</xsl:text> 111 </xsl:when> 112 </xsl:choose> 113</xsl:template> 114 115 116<xsl:template match="e:empty" mode="top"> 117<xsl:text> /></xsl:text> 118</xsl:template> 119 120<xsl:template match="e:attribute" mode="top"> 121<br/> 122 123<xsl:text> </xsl:text> 124<xsl:choose> 125<xsl:when test="@required='yes'"> 126<b><xsl:value-of select="@name"/></b> 127</xsl:when> 128<xsl:otherwise> 129<xsl:value-of select="@name"/> 130</xsl:otherwise> 131</xsl:choose> 132<xsl:text> = </xsl:text> 133 134<xsl:apply-templates/> 135</xsl:template> 136 137<xsl:template match="e:data-type"> 138<xsl:if test="position()>1"> | </xsl:if> 139<var><xsl:value-of select="@name"/></var> 140</xsl:template> 141 142<xsl:template match="e:constant"> 143<xsl:if test="position()>1"> | </xsl:if> 144<xsl:text>"</xsl:text> 145<xsl:value-of select="@value"/> 146<xsl:text>"</xsl:text> 147</xsl:template> 148 149<xsl:template match="e:attribute-value-template"> 150<xsl:text>{ </xsl:text> 151<xsl:apply-templates/> 152<xsl:text> }</xsl:text> 153</xsl:template> 154 155<xsl:template match="var"> 156<var><xsl:apply-templates/></var> 157</xsl:template> 158 159 160 <!-- 161 * Licensed to the Apache Software Foundation (ASF) under one 162 * or more contributor license agreements. See the NOTICE file 163 * distributed with this work for additional information 164 * regarding copyright ownership. The ASF licenses this file 165 * to you under the Apache License, Version 2.0 (the "License"); 166 * you may not use this file except in compliance with the License. 167 * You may obtain a copy of the License at 168 * 169 * http://www.apache.org/licenses/LICENSE-2.0 170 * 171 * Unless required by applicable law or agreed to in writing, software 172 * distributed under the License is distributed on an "AS IS" BASIS, 173 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 174 * See the License for the specific language governing permissions and 175 * limitations under the License. 176 --> 177 178</xsl:stylesheet> 179