[Home] [By Thread] [By Date] [Recent Entries]
At 00/08/17 10:14 +0100, Lee Goddard wrote:
<xsl:if test="not(@foo = preceding-sibling::*[@foo][1]/@foo)"> Right ... because there are no preceding-siblings, the comparison of @foo would be false, so the negation would be true. Would the following do what you wish? <xsl:if test="preceding-sibling::*[@foo] and
not(@foo = preceding-sibling::*[@foo][1]/@foo)">Attached below is an example ... I hope this helps. ............. Ken T:\ftemp>type goddard.xml
<?xml version="1.0"?>
<doc>
<test foo="a" item="1"/>
<test foo="b" item="2"/>
<test foo="b" item="3"/>
<test foo="c" item="4"/>
<test foo="d" item="5"/>
<test foo="d" item="6"/>
</doc>
T:\ftemp>type goddard1.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="/"> <!--root rule-->
<xsl:for-each select="//test">
<xsl:if test="not(@foo = preceding-sibling::*[@foo][1]/@foo)">
Found: <xsl:value-of select="@foo"/> in <xsl:value-of
select="@item"/>
</xsl:if>
</xsl:for-each>
</xsl:template></xsl:stylesheet>
Found: a in 1
Found: b in 2
Found: c in 4
Found: d in 5
T:\ftemp>type goddard2.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="/"> <!--root rule-->
<xsl:for-each select="//test">
<xsl:if test="preceding-sibling::*[@foo] and
not(@foo = preceding-sibling::*[@foo][1]/@foo)">
Found: <xsl:value-of select="@foo"/> in <xsl:value-of
select="@item"/>
</xsl:if>
</xsl:for-each>
</xsl:template></xsl:stylesheet>
Found: b in 2 Found: c in 4 Found: d in 5 T:\ftemp>rem
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



