[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Indexing Tree Elements
At 00/07/07 13:14 +0100, David Carlisle wrote:
> is it possible that it may compare its attributes with the attributes > of the previous document-tree node of the same level? I'm sorry if this sounds pedantic, but because the second argument is a node list, the above expression will be true if *any* of the preceding siblings nodes has an attribute named "foo" of the equal value. To check the immediately preceding element for an attribute named "foo", I would think one would use: <xsl:if test="@foo = preceding-sibling::*[1]/@foo"> To check the the closest (in proximity) preceding element with an attribute named "foo", I would think one would use: <xsl:if test="@foo = preceding-sibling::*[@foo][1]/@foo"> I hope this helps and is considered constructive. ................. Ken
<xsl:template match="/"> <!--root rule--> <xsl:for-each select="//test[last()]"> @foo = preceding-sibling::*/@foo: <xsl:choose> <xsl:when test="@foo = preceding-sibling::*/@foo"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:otherwise>no</xsl:otherwise> </xsl:choose> @foo = preceding-sibling::*[1]/@foo: <xsl:choose> <xsl:when test="@foo = preceding-sibling::*[1]/@foo"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:otherwise>no</xsl:otherwise> </xsl:choose> @foo = preceding-sibling::*[@foo][1]/@foo: <xsl:choose> <xsl:when test="@foo = preceding-sibling::*[@foo][1]/@foo"> <xsl:text>yes</xsl:text> </xsl:when> <xsl:otherwise>no</xsl:otherwise> </xsl:choose> <xsl:text> (</xsl:text> <xsl:value-of select="preceding-sibling::*[@foo][1]/@foo"/> <xsl:text>)</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
@foo = preceding-sibling::*/@foo: yes @foo = preceding-sibling::*[1]/@foo: no @foo = preceding-sibling::*[@foo][1]/@foo: no (z) T:\ftemp>rem
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|