1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- FileName: position09 --> 5 <!-- Document: http://www.w3.org/TR/xpath --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 4.1 Node Set Functions --> 8 <!-- Creator: Paul Dick --> 9 <!-- Purpose: Test of position in match pattern predicates, both long and short versions. --> 10 11<xsl:template match="doc"> 12 <out> 13 <xsl:apply-templates/> 14 </out> 15</xsl:template> 16 17<xsl:template match="foo[3]/a[position()=3]/num/@val"> 18 <xsl:value-of select="."/><xsl:text>,</xsl:text> 19</xsl:template> 20 21<xsl:template match="foo[3]/a[position()=2]/num/@val"> 22 <xsl:value-of select="."/><xsl:text>,</xsl:text> 23</xsl:template> 24 25<xsl:template match="foo[3]/a[position()=1]/num/@val"> 26 <xsl:value-of select="."/><xsl:text>,</xsl:text> 27</xsl:template> 28 29<xsl:template match="foo[2]/a[position()=3]/num/@val"> 30 <xsl:value-of select="."/><xsl:text>,</xsl:text> 31</xsl:template> 32 33<xsl:template match="foo[2]/a[position()=2]/num/@val"> 34 <xsl:value-of select="."/><xsl:text>,</xsl:text> 35</xsl:template> 36 37<xsl:template match="foo[2]/a[position()=1]/num/@val"> 38 <xsl:value-of select="."/><xsl:text>,</xsl:text> 39</xsl:template> 40 41<xsl:template match="foo[1]/a[position()=3]/num/@val"> 42 <xsl:value-of select="."/><xsl:text>,</xsl:text> 43</xsl:template> 44 45<xsl:template match="foo[1]/a[position()=2]/num/@val"> 46 <xsl:value-of select="."/><xsl:text>,</xsl:text> 47</xsl:template> 48 49<xsl:template match="foo[1]/a[position()=1]/num/@val"> 50 <xsl:value-of select="."/><xsl:text>,</xsl:text> 51</xsl:template> 52 53<xsl:template match="a/num"> 54 <xsl:apply-templates select="@val"/> 55</xsl:template> 56 57<!-- Override default template matching, otherwise the values 10, 11, 12 will be displayed --> 58 59<xsl:template match="@val" priority="-1"/> 60 61 62 <!-- 63 * Licensed to the Apache Software Foundation (ASF) under one 64 * or more contributor license agreements. See the NOTICE file 65 * distributed with this work for additional information 66 * regarding copyright ownership. The ASF licenses this file 67 * to you under the Apache License, Version 2.0 (the "License"); 68 * you may not use this file except in compliance with the License. 69 * You may obtain a copy of the License at 70 * 71 * http://www.apache.org/licenses/LICENSE-2.0 72 * 73 * Unless required by applicable law or agreed to in writing, software 74 * distributed under the License is distributed on an "AS IS" BASIS, 75 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 76 * See the License for the specific language governing permissions and 77 * limitations under the License. 78 --> 79 80</xsl:stylesheet> 81