1<?xml version="1.0" ?> 2<xsl:stylesheet version="1.0" 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 4 5 <!-- Test FileName: mk014.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: countries.xml, options.xsl --> 17 <!-- Chapter/Page: 4-160 --> 18 <!-- Purpose: Generating an attribute conditionally --> 19 20<xsl:output method="html" indent="yes" /> 21<xsl:template match="/"> 22<html> 23 <body> 24 <h1>Please select a country:</h1> 25 <select id="country"> 26 <xsl:for-each select="//country"> 27 <option value="{@name}"> 28 <xsl:if test="@selected='yes'"> 29 <xsl:attribute name="selected">selected</xsl:attribute> 30 </xsl:if> 31 <xsl:value-of select="@name"/> 32 </option> 33 </xsl:for-each> 34 </select> 35<hr/> 36</body> 37</html> 38 39</xsl:template> 40 41 <!-- 42 * Licensed to the Apache Software Foundation (ASF) under one 43 * or more contributor license agreements. See the NOTICE file 44 * distributed with this work for additional information 45 * regarding copyright ownership. The ASF licenses this file 46 * to you under the Apache License, Version 2.0 (the "License"); 47 * you may not use this file except in compliance with the License. 48 * You may obtain a copy of the License at 49 * 50 * http://www.apache.org/licenses/LICENSE-2.0 51 * 52 * Unless required by applicable law or agreed to in writing, software 53 * distributed under the License is distributed on an "AS IS" BASIS, 54 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 55 * See the License for the specific language governing permissions and 56 * limitations under the License. 57 --> 58 59</xsl:stylesheet> 60