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