R
R
Rom Black2012-10-08 10:05:49
PHP
Rom Black, 2012-10-08 10:05:49

PHP processor for processing xml+xslt?

There is an initial xml store (or a php script that generates an xml catalog from the database)
and xslt (generated in php dynamically depending on the parameters passed to the script)
The essence of the problem: if an xml file is processed up to 10MB, then everything is fine.
but on xml ~ 17+ mb falls due to lack of memory. (on the server I set the maximum script processing time and the maximum possible allocated memory, the problem was not solved)
I do the processing through xsltprocessor

$xml = new DOMDocument;<br>
$xml->load('http://site.ru/yandex_market.php');<br><br>
$xsl = new DOMDocument;<br>
$xsl->load('http://mysite.ru/manager/template.php?a='.$_GET['a'].'&o='.$_GET['o'].'&c='.$_GET['c']);<br><br>
// Configure the transformer<br>
$proc = new XSLTProcessor;<br>
$proc->importStyleSheet($xsl); // attach the xsl rules<br><br>
echo $proc->transformToXML($xml);<br>

if run through a similar script, it swears at xslt_create (), although xml, xlst modules are connected in phpinfo
<?php<br><br>
// Разместить новый XSLT-процессор<br>
$xh = xslt_create();<br><br>
// Обработать документ<br>
if (xslt_process($xh, 'sample.xml', 'sample.xsl', 'result.xml')) {<br>
print "SUCCESS, sample.xml was transformed by sample.xsl into result.xml";<br>
print ", result.xml has the following contents\n<br>\n";<br>
print "<pre>\n";<br>
readfile('result.xml');<br>
print "</pre>\n";<br>
}<br>
else {<br>
print "Sorry, sample.xml could not be transformed by sample.xsl into";<br>
print "result.xml the reason is that " . xslt_error($xh) . " and the ";<br>
print "error code is " . xslt_errno($xh);<br>
}<br><br>
xslt_free($xh);<br><br>
?><br>

Well, I don't know if this will help?
In general, the essence of the task is to replace the links in the offer/url (see yml ) with your own.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2012-10-08
@MrBlack

stackoverflow.com/questions/230702/memory-efficient-xslt-processor

A
Anton Belichkov, 2012-10-08
@za90

Without going into the wilds of the php code, I can only remind you of one thing - in case of lack of memory (the DOM is bold, it does not fit), you need to change the parser to SAX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question