我正在使用以下内容将所有<section>
s 与修订属性集匹配。<section>
可以出现在文档树的许多不同级别,总是包含在<chapter>
s 中。
<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>
s 设置后实际上是静态的,并且<xsl:param>
仅适用于调用模板。
这是 Docbook,我可以通过以下方式检索章节的章节编号:
<xsl:apply-templates select="ancestor::chapter[1]" mode="label.markup" />
但我认为它可以用纯粹的 XPath 来完成。
有任何想法吗?谢谢!