[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

keep 2nd chapter element

Subject: keep 2nd chapter element
From: Jim_Albright@xxxxxxxxxxxx
Date: Fri, 10 Oct 2003 08:59:29 -0400
chapter id
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.