1<xsl:transform 2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version="1.0" 4> 5 6 <!-- Test FileName: mk040.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: booklist.xml, authors.xml, author-biogs.xsl --> 18 <!-- Chapter/Page: 7-472 --> 19 <!-- Purpose: Using keys --> 20 21<xsl:key name="biog" match="author" use="@name"/> 22<xsl:variable name="biogs" select="document('./inc/authors.xml')"/> 23 24<xsl:template match="/"> 25 <html><body> 26 <xsl:variable name="all-books" select="//book"/> 27 <xsl:for-each select="$all-books"> 28 <h1><xsl:value-of select="title"/></h1> 29 <h2>Author<xsl:if test="count(author)!=1">s</xsl:if></h2> 30 <xsl:for-each select="author"> 31 <xsl:variable name="name" select="."/> 32 <h3><xsl:value-of select="$name"/></h3> 33 <xsl:for-each select="$biogs"> 34 <xsl:variable name="auth" select="key('biog', $name)"/> 35 <p><xsl:value-of select="concat($auth/born, ' - ', $auth/died)"/></p> 36 <p><xsl:value-of select="$auth/biog"/></p> 37 </xsl:for-each> 38 </xsl:for-each> 39 </xsl:for-each> 40 </body></html> 41</xsl:template> 42 43 <!-- 44 * Licensed to the Apache Software Foundation (ASF) under one 45 * or more contributor license agreements. See the NOTICE file 46 * distributed with this work for additional information 47 * regarding copyright ownership. The ASF licenses this file 48 * to you under the Apache License, Version 2.0 (the "License"); 49 * you may not use this file except in compliance with the License. 50 * You may obtain a copy of the License at 51 * 52 * http://www.apache.org/licenses/LICENSE-2.0 53 * 54 * Unless required by applicable law or agreed to in writing, software 55 * distributed under the License is distributed on an "AS IS" BASIS, 56 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 57 * See the License for the specific language governing permissions and 58 * limitations under the License. 59 --> 60 61</xsl:transform> 62