我有一个带有这种树的大 XML 文件(6 GB):
<Report>
<Document>
<documentType>E</documentType>
<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>
</Document>
<Document>
[...]
</Document>
<Document>
[...]
</Document>
[...]
</Report>
如果我在其上应用 XSLT 样式表,则会出现以下错误:
线程“主”java.lang.OutOfMemoryError 中的异常:Java 堆空间
所以我想尝试新的 XSLT 3.0 功能:流式传输,以及 Saxon 9.6 EE。我不想在文档中有一次流式约束。我认为,我想要做的,非常接近这里描述的“突发模式”:http: //saxonica.com/documentation/html/sourcedocs/streaming/burst-mode-streaming.html
这是我的撒克逊命令行:
java -cp saxon9ee.jar net.sf.saxon.Transform -t -s:input.xml -xsl:stylesheet.xsl -o:output/output.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:iterate select="copy-of()/Report/Document" >
DOC HEADER
documentType: <xsl:value-of select="documentType"/>
person/firstname: <xsl:value-of select="person/firstname"/>
DOC FOOTER
<xsl:next-iteration/>
</xsl:iterate>
GLOBAL FOOTER
</xsl:template>
</xsl:stylesheet>
但我仍然有同样的内存不足错误。
谢谢您的帮助!