开发者

XSLT: setting an attribute of a previous node

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开发者_开发问答.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜