1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- CaseName: numbering89 --> 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 (repeat mode) is the position of the chapter/text within the select set 16 that contains the chapter and all its siblings. --> 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="../node()" 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<xsl:template match="text()" mode="repeat"> 49 <xsl:text> </xsl:text> 50 <xsl:element name="text"> 51 <xsl:attribute name="number"> 52 <xsl:number/> 53 </xsl:attribute> 54 <xsl:attribute name="position"> 55 <xsl:value-of select="position()"/> 56 </xsl:attribute> 57 </xsl:element> 58</xsl:template> 59 60 61 <!-- 62 * Licensed to the Apache Software Foundation (ASF) under one 63 * or more contributor license agreements. See the NOTICE file 64 * distributed with this work for additional information 65 * regarding copyright ownership. The ASF licenses this file 66 * to you under the Apache License, Version 2.0 (the "License"); 67 * you may not use this file except in compliance with the License. 68 * You may obtain a copy of the License at 69 * 70 * http://www.apache.org/licenses/LICENSE-2.0 71 * 72 * Unless required by applicable law or agreed to in writing, software 73 * distributed under the License is distributed on an "AS IS" BASIS, 74 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 75 * See the License for the specific language governing permissions and 76 * limitations under the License. 77 --> 78 79</xsl:stylesheet> 80