1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- FileName: namedtemplate10 --> 5 <!-- Document: http://www.w3.org/TR/xslt --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 6 Named Templates --> 8 <!-- Purpose: Test of simulated numerically-indexed for loop. --> 9 <!-- This is example 77 from Nic Miloslav's tutorial site. --> 10 11<xsl:template match="/"> 12 <out> 13 <xsl:apply-templates/> 14 </out> 15</xsl:template> 16 17<xsl:template match="/doc/*"> 18 <p> 19 <xsl:call-template name="for"> 20 <xsl:with-param name="stop"> 21 <xsl:value-of select="@repeat"/> 22 </xsl:with-param> 23 </xsl:call-template> 24 </p> 25</xsl:template> 26 27<xsl:template name="for"> 28 <xsl:param name="start">1</xsl:param> 29 <xsl:param name="stop">1</xsl:param> 30 <xsl:param name="step">1</xsl:param> 31 <!-- put out one iteration of the name and a trailing space --> 32 <xsl:value-of select="name()"/> 33 <xsl:text> </xsl:text> 34 <!-- here's the recursion --> 35 <xsl:if test="$start < $stop"> 36 <xsl:call-template name="for"> 37 <xsl:with-param name="stop"> 38 <xsl:value-of select="$stop"/> 39 </xsl:with-param> 40 <xsl:with-param name="start"> 41 <xsl:value-of select="$start + $step"/> 42 </xsl:with-param> 43 </xsl:call-template> 44 </xsl:if> 45</xsl:template> 46 47 48 <!-- 49 * Licensed to the Apache Software Foundation (ASF) under one 50 * or more contributor license agreements. See the NOTICE file 51 * distributed with this work for additional information 52 * regarding copyright ownership. The ASF licenses this file 53 * to you under the Apache License, Version 2.0 (the "License"); 54 * you may not use this file except in compliance with the License. 55 * You may obtain a copy of the License at 56 * 57 * http://www.apache.org/licenses/LICENSE-2.0 58 * 59 * Unless required by applicable law or agreed to in writing, software 60 * distributed under the License is distributed on an "AS IS" BASIS, 61 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 62 * See the License for the specific language governing permissions and 63 * limitations under the License. 64 --> 65 66</xsl:stylesheet> 67