1<xsl:stylesheet 2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xsl:version="1.0"> 4 5 <!-- Test FileName: mk031.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: opera.xml, composers.xsl --> 17 <!-- Chapter/Page: 4-316 --> 18 <!-- Purpose: Getting the result of call-template in a variable --> 19 20<xsl:template match="/"> 21 <xsl:variable name="list"> 22 <xsl:call-template name="make-list"> 23 <xsl:with-param name="names" select="/programme/composer/fullname"/> 24 </xsl:call-template> 25 </xsl:variable> 26 This week's composers are: 27 <xsl:value-of select="translate($list, ',', ';')"/> 28</xsl:template> 29 30<xsl:template name="make-list"> 31 <xsl:param name="names"/> 32 <xsl:for-each select="$names"> 33 <xsl:value-of select="."/> 34 <xsl:if test="position()!=last()">, </xsl:if> 35 <xsl:if test="position()=last()-1">and </xsl:if> 36 </xsl:for-each> 37</xsl:template> 38 39 <!-- 40 * Licensed to the Apache Software Foundation (ASF) under one 41 * or more contributor license agreements. See the NOTICE file 42 * distributed with this work for additional information 43 * regarding copyright ownership. The ASF licenses this file 44 * to you under the Apache License, Version 2.0 (the "License"); 45 * you may not use this file except in compliance with the License. 46 * You may obtain a copy of the License at 47 * 48 * http://www.apache.org/licenses/LICENSE-2.0 49 * 50 * Unless required by applicable law or agreed to in writing, software 51 * distributed under the License is distributed on an "AS IS" BASIS, 52 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 * See the License for the specific language governing permissions and 54 * limitations under the License. 55 --> 56 57</xsl:stylesheet> 58