xref: /aosp_15_r20/external/apache-xml/test/tests/conf/position/position101.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4  <!-- FileName: position101 -->
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 a comment 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/comment()[1]">
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="comment()" mode="census">
39  <xsl:text>C: </xsl:text><xsl:value-of select="."/><xsl:text>
40</xsl:text>
41</xsl:template>
42
43<xsl:template match="text()|processing-instruction()" mode="census">
44  <xsl:text>ERROR! </xsl:text><xsl:value-of select="."/><xsl:text>
45</xsl:text>
46</xsl:template>
47
48
49  <!--
50   * Licensed to the Apache Software Foundation (ASF) under one
51   * or more contributor license agreements. See the NOTICE file
52   * distributed with this work for additional information
53   * regarding copyright ownership. The ASF licenses this file
54   * to you under the Apache License, Version 2.0 (the  "License");
55   * you may not use this file except in compliance with the License.
56   * You may obtain a copy of the License at
57   *
58   *     http://www.apache.org/licenses/LICENSE-2.0
59   *
60   * Unless required by applicable law or agreed to in writing, software
61   * distributed under the License is distributed on an "AS IS" BASIS,
62   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63   * See the License for the specific language governing permissions and
64   * limitations under the License.
65  -->
66
67</xsl:stylesheet>
68