[xsl] keep 2nd chapter element

Subject: [xsl] keep 2nd chapter element
From: Jim_Albright@xxxxxxxxxxxx
Date: Fri, 10 Oct 2003 08:59:29 -0400
reducing the problem to bare bones I want to keep only some of the 
"chapter" elements and toss the rest:
         <chapter id="BCV-MRK-0"  value="0" keep="no"/>
         <chapter id="BCV-MRK-0"  value="0" keep="no"/>
         <chapter id="BCV-MRK-1"  value="1" keep="yes"/>
         <chapter id="BCV-MRK-1"  value="1" keep="no"/>
         <chapter id="BCV-MRK-1"  value="1" keep="no"/>
         <chapter id="BCV-MRK-2"  value="2" keep="no"/>
         <chapter id="BCV-MRK-2"  value="2" keep="yes"/>
         <chapter id="BCV-MRK-2"  value="2" keep="no"/>
         <chapter id="BCV-MRK-2"  value="2" keep="no"/>
         <chapter id="BCV-MRK-3"  value="3" keep="no"/>
         <chapter id="BCV-MRK-3"  value="3" keep="yes"/>
         <chapter id="BCV-MRK-3"  value="3" keep="no"/>
         <chapter id="BCV-MRK-3"  value="3" keep="no"/>

I have added the keep attribute by hand to show which "chapter"s to keep
so I should end with
         <chapter id="BCV-MRK-1"  value="1" keep="yes"/>
         <chapter id="BCV-MRK-2"  value="2" keep="yes"/>
         <chapter id="BCV-MRK-3"  value="3" keep="yes"/>


<xsl:template match="chapter"  >
        <xsl:choose>
        <!--...... if  chapter is zero then toss   .....-->
                <xsl:when test="@value='0'">
                        <!--...... remove chapter 0 .....-->
                </xsl:when>
        <!--...... if very first chapter 1 in book then keep   .....-->
                <xsl:when test="@value='1' and 
preceding::chapter[not(@value='1')]">
                        <xsl:call-template name="copy-current-node"/>
                </xsl:when>
        <!--...... if second occurrence of same value and value is not 1 
then keep it  .....-->
                <xsl:when test=""><!-- not working yet-->
                        <xsl:call-template name="copy-current-node"/>
                </xsl:when>
                <xsl:otherwise>
                        <!--...... remove duplicate chapter  .....-->
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>


Jim Albright
704 843-0582
Wycliffe Bible Translators



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread