I try to split a large XML (like 10 GB) file into smaller XML files with XSL streaming.
The XML looks like:
<?xml version="1.0" encoding="UTF-8"?>
<Book>
<Header>...</Header>
<Entry>...</Entry>
<Entry>...</Entry>
<Entry>...</Entry>
<Entry>...</Entry>
</Book>
The XSL looks like:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>
<xsl:template match="/">
<xsl:apply-templates select="Book">
<xsl:with-param name="header" select="/Book/Header"/>
<xsl:with-param name="top-level-element" select="name(/*[1])"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Book">
<xsl:param name="top-level-element"/>
<xsl:param name="header"/>
<xsl:result-document href="{concat(position(),'.xml')}" method="xml">
<xsl:element name="{$top-level-element}">
<xsl:value-of select="$header"/>
<xsl:iterate
select="Entry">
<xsl:apply-templates select="."/>
</xsl:iterate>
</xsl:element>
</xsl:result-document>
</xsl:template>
<xsl:template match="Entry">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
When I call the transformation with the XML I get following error:
Error on line 6 column 29
XTSE3430 Template rule is not streamable
* Operand {Book/Header} of {xsl:apply-templates} selects streamed nodes in a
context that allows arbitrary navigation (line 8)
* The result of the template rule can contain streamed nodes
Can someone help me what I'm doing wrong?