1<xsl:stylesheet 2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version="1.0"> 4 5 <!-- Test FileName: mk050.xsl --> 6 <!-- Source Attribution: 7 This test was written by Michael Kay and is taken from 8 'XSLT Programmer's Reference' published by Wrox Press Limited in 2000; 9 ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 10 Now updated in the second edition (ISBN 1861005067), http://www.wrox.com. 11 No part of this book may be reproduced, stored in a retrieval system or 12 transmitted in any form or by any means - electronic, electrostatic, mechanical, 13 photocopying, recording or otherwise - without the prior written permission of 14 the publisher, except in the case of brief quotations embodied in critical articles or reviews. 15 --> 16 <!-- Example: booklist.xml, booksales.xsl --> 17 <!-- Chapter/Page: 8-537 --> 18 <!-- Purpose: Illustrate a navigational stylesheet --> 19 20<xsl:key name="pub" match="book" use="publisher"/> 21 22<xsl:variable name="publishers" 23 select="//publisher[not(.=preceding::publisher)]"/> 24 25<xsl:template match="/"> 26<html> 27<head> 28 <title>Sales volume by publisher</title> 29</head> 30<body> 31 <h1>Sales volume by publisher</h1> 32 <table> 33 <tr> 34 <th>Publisher</th><th>Total Sales Value</th> 35 </tr> 36 <xsl:for-each select="$publishers"> 37 <tr> 38 <td><xsl:value-of select="."/></td> 39 <td><xsl:call-template name="total-sales"/></td> 40 </tr> 41 </xsl:for-each> 42 </table> 43</body> 44</html> 45</xsl:template> 46 47<!-- calculate total book sales for the current publisher --> 48<xsl:template name="total-sales"> 49 <xsl:value-of select="sum(key('pub',string(.))/sales)"/> 50</xsl:template> 51 52 <!-- 53 * Licensed to the Apache Software Foundation (ASF) under one 54 * or more contributor license agreements. See the NOTICE file 55 * distributed with this work for additional information 56 * regarding copyright ownership. The ASF licenses this file 57 * to you under the Apache License, Version 2.0 (the "License"); 58 * you may not use this file except in compliance with the License. 59 * You may obtain a copy of the License at 60 * 61 * http://www.apache.org/licenses/LICENSE-2.0 62 * 63 * Unless required by applicable law or agreed to in writing, software 64 * distributed under the License is distributed on an "AS IS" BASIS, 65 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 66 * See the License for the specific language governing permissions and 67 * limitations under the License. 68 --> 69 70</xsl:stylesheet> 71