Subject: RE: keep 2nd chapter element
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 10 Oct 2003 14:29:24 +0100
|
test="count(preceding-sibling::chapter[@value=current()/@value])=1"
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Jim_Albright@xxxxxxxxxxxx
> Sent: 10 October 2003 13:59
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: keep 2nd chapter element
>
>
> 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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|