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