xsl-list
[Top] [All Lists]

preceding-sibling reversed ?

2002-08-29 03:13:22
Hello,

I created in an XSL-T stylesheet a variable that contains presentation
slides. Each of the slides is a '<div>' element with a 'class' attribute
with the value 'slide' and all these elements have and 'id' attribute with a
unique value. All slides exist in the same level in the hierarchy of the
document.

I wanted to add a 'previous' and 'next' button to each slide that (off
course) links to the previous and next slide in the presentation.

to be able to create the link to the next slide, I used the following lines:

<a>
        <xsl:attribute name="href">
                #<xsl:value-of select="following-sibling::div[(_at_)class = 
'slide']/@id"/>
        </xsl:attribute>
        <img src="images/icons/next.gif" border="0"/>
</a>

This works perfect, however for the previous slide I wanted to use:

<a>
        <xsl:attribute name="href">
                #<xsl:value-of select="preceding-sibling::div[(_at_)class = 
'slide']/@id"/>
        </xsl:attribute>
        <img src="images/icons/back.gif" border="0"/>
</a>

This always results in a link to the first slide (msxml). A bell started to
ring and I thought that the listing of the elements probabley would be
reversed, so I tried the following:

<a>
        <xsl:variable name="pos" select="position()" />
        <xsl:attribute name="href">
                #<xsl:value-of select="preceding-sibling::div[(_at_)class = 
'slide' and
position() = $pos -1]/@id"/>
        </xsl:attribute>
        <img src="images/icons/back.gif" border="0"/>
</a>

This also results in a link to the first slide. Now I have the following
that works fine, but I don't really understand why! Can anybody please
explain me this?

<a>
        <xsl:attribute name="href">
                #<xsl:value-of select="preceding-sibling::div[(_at_)class = 
'slide' and
position() = 1]/@id"/>
        </xsl:attribute>
        <img src="images/icons/back.gif" border="0"/>
</a>

thanks in advance!

Bjorn Boxstart


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>