我有一个带有这种树的大 XML 文件(6 GB):
<Report>
<Document>
<documentType>E</documentType>
<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>
</Document>
<Document>
[...]
</Document>
<Document>
[...]
</Document>
[... there are a lot of Documents]
</Report>
所以我使用了新的 XSLT 3.0 流功能和 Saxon 9.6 EE。我不想在文档中有一次流式约束。这就是我尝试使用copy-of()
. 我认为,我想要做的,非常接近这里描述的“突发模式”:http: //saxonica.com/documentation/html/sourcedocs/streaming/burst-mode-streaming.html
这是我的 XSLT 样式表:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:mode streamable="yes" />
<xsl:template match="/">
GLOBAL HEADER
<xsl:for-each select="/Report/Document/copy-of()" >
DOC HEADER
documentType: <xsl:value-of select="documentType"/>
person/firstname: <xsl:value-of select="person/firstname"/>
<xsl:call-template name="fnc1"/>
DOC FOOTER
</xsl:for-each>
GLOBAL FOOTER
</xsl:template>
<xsl:template name="fnc1">
documentType again: <xsl:value-of select="documentType"/>
</xsl:template>
</xsl:stylesheet>
从某种意义上说,它之所以有效,是因为copy-of()
我可以xsl:value-of
直接在 for-each 中使用几个(就像在这个问题中一样)。(否则我有这个错误 * There are at least two consuming operands: {xsl:value-of} on line 8, and {xsl:value-of} on line 9
)
但我仍然有流媒体限制,因为<xsl:call-template name="fnc1"/>
会产生这个错误:
Error at xsl:template on line 4 column 25 of stylesheet.xsl:
XTSE3430: Template rule is declared streamable but it does not satisfy the streamability rules.
* xsl:call-template is not streamable in this Saxon release
Stylesheet compilation failed: 1 error reported
所以我的问题是:如何进行部分流式传输(文档被一个一个加载但完全加载)以便能够在文档中使用call-template
(和其他apply-templates
)?
谢谢您的帮助!