Efficient XSLT memory for converting large XML files

This question is related to the last answer michael.hor257k , which in turn is related to the answer of Dimitar Novachev .

When using the stylesheet in the above answer ( michael.hor257k ) for large XML (about 60 MB an example XML is present below), and the conversion was successful.

When you try to use a different stylesheet, slightly different from michael.hor257k, and is designed to group elements (with a child sectPr) and their next siblings (until the next next sibling element with a child sectPr), recursively (i.e. group the elements into depth XML input).

XML input sample:

<body>
    <p/>
    <p>
        <sectPr/>
    </p>
    <p/>
    <p/>
    <tbl/>
    <p>
        <sectPr/>
    </p>
    <p/>
</body>

, :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates select="*[1] | *[sectPr]"/>
        </xsl:copy>
        <xsl:apply-templates select="following-sibling::*[1][not(sectPr)]"/>
    </xsl:template>

    <xsl:template match="*[sectPr]">
        <myTag>
            <xsl:copy>
                <xsl:apply-templates select="*[1] | *[sectPr]"/>
            </xsl:copy>
            <xsl:apply-templates select="following-sibling::*[1][not(sectPr)]"/>
        </myTag>
    </xsl:template>

</xsl:stylesheet>

, OutOfMemoryError, XML 60 .

, , XSLT, michael.hor257k, Dimitre Novatchev, .

, OutOfMemoryError. , .

+4
2

Lingamurthy CS,

, <xsl:strip-space elements="*"/>, . XML- node.

- XML- , XML- .

, 20% - MS XslCompiledTransform.

- , , <xsl:strip-space elements="*"/> Saxon 9.1J - . . 9525004 340MB RAM. 5.3 . 4336366 215MB RAM. 5.06 sec

+4

, XSLT . ( ), , (15mb +) XML . ? .

Windows, (, XSLT 1.0). , , - .NET XslCompiledTransform, XSLT IL. , .

- .NET XmlReader XmlWriter, , , , . XML. .

+2

All Articles