XSLT transformation on Large XML files with C#

前端 未结 3 2142
再見小時候
再見小時候 2020-12-06 19:37

I have some very large XML files (800 MB to 1.5 GB). I need to apply XSLT on that. I am able to read it XMLTextReader. When i applied XSLT transformation, get SystemOutOfMem

3条回答
  •  盖世英雄少女心
    2020-12-06 20:06

    XSLT uses XPath and this requires that the whole XML document be maintained in memory. Thus the problem of insufficient memory is by definition.

    There are simle rules to approximate how much memory is needed and one of them says 5 * text-size.

    So, for a "typical 1.5GB XML file" 8GB RAM may be sufficient.

    Either split the document into smaller parts or wait for an implementation of XSLT 2.1, which defines special streaming instructions. In the meantime one may use the latest (commercial) version of Saxon, which implements extensions for streaming and successful processing of 64GB document has been reported on twitter.

提交回复
热议问题