tags:

views:

59

answers:

1

Given the following sample;

<ul id="s-nav">
  <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=2]/node">
    <li>
      <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
     <xsl:attribute name="class">current</xsl:attribute>
      </xsl:if>
    </li>
  </xsl:for-each>
</ul>

When the current node is the same as the current <li>, the attribute class is set to 'current'.

Now I want to set a second attribute within the if block, but for the previous <li>, not the current. Any idea how to accomplish this?

Many thanks.

A: 

I don't think that XSLT will let you modify the attributes of nodes that have already been output. The best thing is to think about each node as its output, and work out the conditions under which it should have various attributes.

Rich