1<html xsl:version="1.0" 2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 lang="en"> 4 5 <!-- FileName: spacing02 --> 6 <!-- Document: http://www.w3.org/TR/xslt --> 7 <!-- DocVersion: 19991116 --> 8 <!-- Section: 2.3 LRE as Stylesheet --> 9 <!-- Creator: Paul Dick --> 10 <!-- Purpose: Do everything inside an HTML element, including for-each and if structures. --> 11 12<head> 13 <title>Sales Results By Division</title> 14</head> 15<body> 16 <table border="1"> 17 <tr> 18 <th>Division</th> 19 <th>Revenue</th> 20 <th>Growth</th> 21 <th>Bonus</th> 22 </tr> 23 <xsl:for-each select="sales/division"> 24 <!-- order the result by revenue --> 25 <xsl:sort select="revenue" data-type="number" order="descending"/> 26 <tr> 27 <td> 28 <em><xsl:value-of select="@id"/></em> 29 </td> 30 <td> 31 <xsl:value-of select="revenue"/> 32 </td> 33 <td> 34 <!-- highlight negative growth in red --> 35 <xsl:if test="growth < 0"> 36 <xsl:attribute name="style"> 37 <xsl:text>color:red</xsl:text> 38 </xsl:attribute> 39 </xsl:if> 40 <xsl:value-of select="growth"/> 41 </td> 42 <td> 43 <xsl:value-of select="bonus"/> 44 </td> 45 </tr> 46 </xsl:for-each> 47 </table> 48</body> 49 50 <!-- 51 * Licensed to the Apache Software Foundation (ASF) under one 52 * or more contributor license agreements. See the NOTICE file 53 * distributed with this work for additional information 54 * regarding copyright ownership. The ASF licenses this file 55 * to you under the Apache License, Version 2.0 (the "License"); 56 * you may not use this file except in compliance with the License. 57 * You may obtain a copy of the License at 58 * 59 * http://www.apache.org/licenses/LICENSE-2.0 60 * 61 * Unless required by applicable law or agreed to in writing, software 62 * distributed under the License is distributed on an "AS IS" BASIS, 63 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 64 * See the License for the specific language governing permissions and 65 * limitations under the License. 66 --> 67 68 69</html> 70