1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- CaseName: numbering88 --> 5 <!-- Creator: David Marston --> 6 <!-- Purpose: Show discrepancies between number and position. --> 7 <!-- SpecCitation: Rec="XSLT" Version="1.0" type="OASISptr1" place="id(number)/ulist[2]/item[1]/p[1]/text()[5]" --> 8 <!-- SpecCitation: Rec="XSLT" Version="1.0" type="OASISptr1" place="id(number)/ulist[2]/item[3]/p[1]/text()[6]" --> 9 <!-- SpecCitation: Rec="XSLT" Version="1.0" type="OASISptr1" place="id(number)/ulist[1]/item[2]/p[1]/text()[3]" --> 10 <!-- SpecCitation: Rec="XSLT" Version="1.0" type="OASISptr1" place="id(number)/ulist[1]/item[3]/p[1]/text()[1]" --> 11 <!-- SpecCitation: Rec="XSLT" Version="1.0" type="OASISptr1" place="id(convert)/p[2]/text()[3]" --> 12 <!-- Scenario: operation="standard-XML" --> 13 <!-- Elaboration: While xsl:number always shows the number of the chapter among all chapters, 14 position() in the outer case is the position of the chapter among all children of doc, 15 position() in the inner case is the position of the chapter within the select="." set 16 that contains just one element. --> 17 18<xsl:template match="doc"> 19 <out> 20 <xsl:apply-templates/> 21 </out> 22</xsl:template> 23 24<xsl:template match="chapter"> 25 <xsl:element name="chap"> 26 <xsl:attribute name="number"> 27 <xsl:number/> 28 </xsl:attribute> 29 <xsl:attribute name="position"> 30 <xsl:value-of select="position()"/> 31 </xsl:attribute> 32 <xsl:value-of select="note[1]"/> 33 <xsl:apply-templates select="." mode="repeat"/> 34 </xsl:element> 35</xsl:template> 36 37<xsl:template match="chapter" mode="repeat"> 38 <xsl:element name="sel"> 39 <xsl:attribute name="number"> 40 <xsl:number/> 41 </xsl:attribute> 42 <xsl:attribute name="position"> 43 <xsl:value-of select="position()"/> 44 </xsl:attribute> 45 </xsl:element> 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