1<?xml version="1.0"?> 2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 3 4 <!-- FileName: axes116 --> 5 <!-- Document: http://www.w3.org/TR/xpath --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 2.5 --> 8 <!-- Creator: David Marston --> 9 <!-- Purpose: Test of //@ sequences --> 10 11<xsl:output method="xml" encoding="utf-8"/> 12 13<xsl:template match="/"> 14 <out><xsl:text> </xsl:text> 15 <all-attribs><xsl:value-of select="count(//@*)"/></all-attribs><xsl:text> </xsl:text> 16 <all-titles><xsl:value-of select="count(//@title)"/></all-titles><xsl:text> </xsl:text> 17 <all-sect-attribs><xsl:value-of select="count(//section//@*)"/></all-sect-attribs><xsl:text> </xsl:text> 18 <all-sect-titles><xsl:value-of select="count(//section//@title)"/></all-sect-titles><xsl:text> </xsl:text> 19 <!-- The above two, respectively, must equal the sums of sect-*-attribs and sect-*-titles below. --> 20 <xsl:apply-templates/> 21 </out> 22</xsl:template> 23 24<xsl:template match="chapter"> 25 <chap-attribs><xsl:value-of select="count(.//@*)"/></chap-attribs><xsl:text> </xsl:text> 26 <chap-titles><xsl:value-of select="count(.//@title)"/></chap-titles><xsl:text> </xsl:text> 27 <!-- Rather than iterate, we want to have a sub-element name lead the path expression. --> 28 <sect-1-attribs><xsl:value-of select="count(section[1]//@*)"/></sect-1-attribs><xsl:text> </xsl:text> 29 <sect-1-titles><xsl:value-of select="count(section[1]//@title)"/></sect-1-titles><xsl:text> </xsl:text> 30 <sect-2-attribs><xsl:value-of select="count(section[2]//@*)"/></sect-2-attribs><xsl:text> </xsl:text> 31 <sect-2-titles><xsl:value-of select="count(section[2]//@title)"/></sect-2-titles><xsl:text> </xsl:text> 32 <sect-3-attribs><xsl:value-of select="count(section[3]//@*)"/></sect-3-attribs><xsl:text> </xsl:text> 33 <sect-3-titles><xsl:value-of select="count(section[3]//@title)"/></sect-3-titles><xsl:text> </xsl:text> 34</xsl:template> 35 36 37 <!-- 38 * Licensed to the Apache Software Foundation (ASF) under one 39 * or more contributor license agreements. See the NOTICE file 40 * distributed with this work for additional information 41 * regarding copyright ownership. The ASF licenses this file 42 * to you under the Apache License, Version 2.0 (the "License"); 43 * you may not use this file except in compliance with the License. 44 * You may obtain a copy of the License at 45 * 46 * http://www.apache.org/licenses/LICENSE-2.0 47 * 48 * Unless required by applicable law or agreed to in writing, software 49 * distributed under the License is distributed on an "AS IS" BASIS, 50 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 * See the License for the specific language governing permissions and 52 * limitations under the License. 53 --> 54 55</xsl:stylesheet> 56