评论中建议使用的示例
for-each-group
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:output indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="item" group-adjacent="(position() - 1) idiv 19">
<page count="{position()}" is-last-page="{position() eq last()}">
<xsl:apply-templates select="current-group()"/>
</page>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
<xsl:mode on-no-match="shallow-copy"/>
</xsl:stylesheet>
对于 XSLT 2 处理器,分组是相同的,用身份转换模板替换声明性
xsl:mode
声明