Sahand
Sahand

Reputation: 8370

XSLT out of memory even though I'm using streaming

I have the following stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:mode streamable="yes"/>
    <xsl:output method="text"/>

    <xsl:template match="/">
        <xsl:value-of select="//w" separator="&#10;"/>
    </xsl:template>

</xsl:stylesheet>

And I run the following command in the command line:

java -jar saxon9he.jar korpus.xml xslt.xml > korpus.txt

I get the out of memory error even though I have specified streaming in the stylesheet.

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at net.sf.saxon.tree.tiny.TinyTree.ensureAttributeCapacity(TinyTree.java:277)
    at net.sf.saxon.tree.tiny.TinyTree.addAttribute(TinyTree.java:757)
    at net.sf.saxon.tree.tiny.TinyBuilder.attribute(TinyBuilder.java:302)
    at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:366)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:504)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:401)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2763)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:513)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:815)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:744)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:128)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:543)
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:444)
    at net.sf.saxon.event.Sender.send(Sender.java:177)
    at net.sf.saxon.Controller.transform(Controller.java:1872)
    at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:553)
    at net.sf.saxon.Transform.processFile(Transform.java:1178)
    at net.sf.saxon.Transform.doTransform(Transform.java:765)
    at net.sf.saxon.Transform.main(Transform.java:77)

My korpus.xml file is 3.61 GB big.

What have I done wrong?

Upvotes: 0

Views: 815

Answers (1)

Michael Kay
Michael Kay

Reputation: 163458

You are using Saxon-HE which does not support streaming. You need Saxon-EE.

Also it's probably a good idea to set version="3.0" on the xsl:stylesheet element, and -xsltversion:3.0 on the command line. Because 3.0 is not yet a W3C Recommendation, Saxon runs as an XSLT 2.0 processor unless requested otherwise. An XSLT 2.0 processor, unfortunately, ignores an xsl:mode declaration under the rules for "forwards compatibility".

Upvotes: 4

Related Questions