1<?xml version="1.0" ?> 2<xsl:stylesheet 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 4 version="1.0" 5> 6 7 <!-- Test FileName: mk039.xsl --> 8 <!-- Source Attribution: 9 This test was written by Michael Kay and is taken from 10 'XSLT Programmer's Reference' published by Wrox Press Limited in 2000; 11 ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 12 Now updated in the second edition (ISBN 1861005067), http://www.wrox.com. 13 No part of this book may be reproduced, stored in a retrieval system or 14 transmitted in any form or by any means - electronic, electrostatic, mechanical, 15 photocopying, recording or otherwise - without the prior written permission of 16 the publisher, except in the case of brief quotations embodied in critical articles or reviews. 17 --> 18 <!-- Example: resorts.xml, resorts.xsl --> 19 <!-- Chapter/Page: 7-464 --> 20 <!-- Purpose: Using generate id to create links --> 21 22<xsl:template match="/"> 23<html> 24<body> 25 <h1>Hotels</h1> 26 <xsl:for-each select="//hotel"> 27 <xsl:sort select="stars" order="descending" data-type="number"/> 28 <h2><xsl:value-of select="name"/></h2> 29 <p>Address: <xsl:value-of select="address"/></p> 30 <p>Stars: <xsl:value-of select="stars"/></p> 31 <p>Resort: <a href="#{generate-id(parent::resort)}"> 32 <xsl:value-of select="parent::resort/name"/></a></p> 33 </xsl:for-each> 34 35 <h1>Resorts</h1> 36 <xsl:for-each select="//resort"> 37 <h2><a name="{generate-id()}"> 38 <xsl:value-of select="name"/> 39 </a></h2> 40 <p><xsl:value-of select="details"/></p> 41 </xsl:for-each> 42</body> 43</html> 44</xsl:template> 45 46 <!-- 47 * Licensed to the Apache Software Foundation (ASF) under one 48 * or more contributor license agreements. See the NOTICE file 49 * distributed with this work for additional information 50 * regarding copyright ownership. The ASF licenses this file 51 * to you under the Apache License, Version 2.0 (the "License"); 52 * you may not use this file except in compliance with the License. 53 * You may obtain a copy of the License at 54 * 55 * http://www.apache.org/licenses/LICENSE-2.0 56 * 57 * Unless required by applicable law or agreed to in writing, software 58 * distributed under the License is distributed on an "AS IS" BASIS, 59 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 60 * See the License for the specific language governing permissions and 61 * limitations under the License. 62 --> 63 64</xsl:stylesheet> 65