test="count(preceding-sibling::chapter[(_at_)value=current()/@value])=1"
Michael Kay
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Jim_Albright(_at_)wycliffe(_dot_)org
Sent: 10 October 2003 13:59
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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