XSLT:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Objects">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="business">
<xsl:for-each-group select="WorkItem" group-starting-with="WorkItem[(position() -1)mod 3 = 0]">
<xsl:variable name="file" select="concat('WorkItem',position(),'.xml')"/>
<xsl:result-document href="{$file}">
<Objects>
<business>
<xsl:copy-of select="current-group()" />
</business>
</Objects>
</xsl:result-document>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
InputXML:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Objects>
<business>
<WorkItem>
..............
</WorkItem>
<WorkItem>
..............
</WorkItem>
<WorkItem>
..............
</WorkItem>
<WorkItem>
..............
</WorkItem>
<WorkItem>
..............
</WorkItem>
<WorkItem>
..............
</WorkItem>
</business>
</Objects>
预期输出:2个单独的文件,每个文件中包含三个工作项。
收到错误:
Error: XSLT Service failed. Failed to transform document Exception:
javax.xml.transform.TransformerException: Could not find function: current-group
答案 0 :(得分:1)
您的样式表使用XSLT 2.0功能,但您使用的是XSLT 1.0处理器。