1<?xml version="1.0" encoding="ISO-8859-1"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- FileName: position97 --> 5 <!-- Document: http://www.w3.org/TR/xpath --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 3.3 --> 8 <!-- Creator: Joerg Heinicke, trimmed by David Marston --> 9 <!-- Purpose: Use a (number-valued) variable in a predicate, but inside a for-each. --> 10 <!-- Also tests that weird sentence: "The predicate filters the node-set with respect to 11 the child axis" because .//description[2] means the second description that is a child 12 of the a (or b) node under which you found the description currently being considered. --> 13 14<xsl:output method="xml" indent="no" encoding="UTF-8"/> 15 16<xsl:template match="root"> 17 <out> 18 <xsl:text> 19</xsl:text> 20 <xsl:apply-templates select="base//description"/> 21 </out> 22</xsl:template> 23 24<xsl:template match="description"> 25 <xsl:variable name="pos" select="position()"/> 26 <tr row="{$pos}"> 27 <xsl:for-each select="/root/base"> 28 <td> 29 <xsl:copy-of select="@side"/> 30 <xsl:value-of select=".//description[$pos]"/> 31 </td> 32 </xsl:for-each> 33 </tr> 34 <xsl:text> 35</xsl:text> 36</xsl:template> 37 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