我用下面与设置修改属性匹配所有<section>
秒。 <section>
可以出现在文档树的许多不同级别上,始终包含在<chapter>
s之内。XSLT:从一个传递价值,每场比赛到下一个
<xsl:for-each select="//section[@revision]">
<!-- Do one thing if this is the first section
matched in this chapter -->
<!-- Do something else if this section is in the same
chapter as the last section matched -->
</xsl:for-each>
正如评论说,我需要将每for-each
迭代认识到的以前匹配部分所属的章。我知道<xsl:variable>
实际上一旦设置就是静态的,而<xsl:param>
只适用于调用模板。
这是Docbook的,我可以retreive用一节的章号:
<xsl:apply-templates select="ancestor::chapter[1]" mode="label.markup" />
,但我认为它可以与纯粹的XPath来完成。
任何想法?谢谢!
谢谢,我正在为此工作。但有一件事:'for-each'之前定义的'sections'变量在'for-each'循环本身中不可用。虽然只是不使用常量,但很容易修复。 – carillonator 2009-12-02 18:31:00
当然是''内部可用的变量。唯一不正确的是'[position() - 1]'谓词,我现在已经解决了这个问题。 –
Tomalak
2009-12-03 07:46:49