2

I am trying to transform a large xml file (about 50mb) in php using the following code:

// Load the XML source
$xml = new DOMDocument;

$xml->load($dir . 'xml/vapProducts.xml');

$xsl = new DOMDocument;
$xsl->load($dir . 'all_products.xsl');

// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

$resulttxt= $proc->transformToXML($xml);

This works fine on my local dev machine but when I upload it to my hosting provider it fails with an out of memory error.

Is there a way to make the transfor more efficient or do it incrementally rather than loading the whole xml file into memory?

Thanks,

John

  • 1
    possible duplicate of [XSLTProcessor xmlSAX2Characters: out of memory](http://stackoverflow.com/questions/11197337/xsltprocessor-xmlsax2characters-out-of-memory) – slapyo Oct 27 '14 at 18:53
  • I don't know much about libxslt or libxml but having memory ten times the raw document size should usually be enough, so 50mb sounds feasible in principle. – Michael Kay Oct 27 '14 at 23:29
  • I'm not sure about smarter memory management, but maybe you can try to increase the memory limit in php.ini? – molbal Oct 28 '14 at 10:31

0 Answers0