1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- FileName: position94 --> 5 <!-- Document: http://www.w3.org/TR/xslt --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 11.6 --> 8 <!-- Creator: Sergei Ivanov, adapted by David Marston --> 9 <!-- Purpose: Test of position() and last() in xsl:with-param. --> 10 11<xsl:output method="xml" encoding="UTF-8"/> 12 13<xsl:template match="/root"> 14 <out> 15 <xsl:apply-templates select="a" /> 16 </out> 17</xsl:template> 18 19<xsl:template match="a"> 20 <xsl:text> 21</xsl:text> 22 <xsl:text>In a, position() is </xsl:text> 23 <xsl:value-of select="position()"/> 24 <xsl:text> and last() is </xsl:text> 25 <xsl:value-of select="last()"/><xsl:text> 26</xsl:text> 27 <xsl:apply-templates select="b"> 28 <xsl:with-param name="a.pos" select="position()"/> 29 <xsl:with-param name="a.last" select="last()"/> 30 </xsl:apply-templates> 31</xsl:template> 32 33<xsl:template match="b"> 34 <xsl:param name="a.pos" select="pos-bad"/> 35 <xsl:param name="a.last" select="last-bad"/> 36 <xsl:text>In b number </xsl:text> 37 <xsl:value-of select="position()"/> 38 <xsl:text>, $a.pos=</xsl:text> 39 <xsl:value-of select="$a.pos"/> 40 <xsl:text> and $a.last=</xsl:text> 41 <xsl:value-of select="$a.last"/> 42 <xsl:text> 43</xsl:text> 44</xsl:template> 45 46 47 <!-- 48 * Licensed to the Apache Software Foundation (ASF) under one 49 * or more contributor license agreements. See the NOTICE file 50 * distributed with this work for additional information 51 * regarding copyright ownership. The ASF licenses this file 52 * to you under the Apache License, Version 2.0 (the "License"); 53 * you may not use this file except in compliance with the License. 54 * You may obtain a copy of the License at 55 * 56 * http://www.apache.org/licenses/LICENSE-2.0 57 * 58 * Unless required by applicable law or agreed to in writing, software 59 * distributed under the License is distributed on an "AS IS" BASIS, 60 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 61 * See the License for the specific language governing permissions and 62 * limitations under the License. 63 --> 64 65</xsl:stylesheet> 66