PHP 5,大文件的XSL转换 [英] PHP 5, XSL transformations of big files

查看:37
本文介绍了PHP 5,大文件的XSL转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。


我打算在汽车上做一些我每天手动完成的任务。每天b
。我正在上传大型XML文件(~20mb)然后我正在使用XSLT模式

将其转换为MySQL查询文件。


我已经使用第三个工具来处理XSLT,并且需要几秒钟来处理我的大XML文件。


但是现在我正在转向PHP所以我''我试图使用XSL PHP扩展来支持我的XSL文件
。但是......它需要几分钟......我允许10分钟

(set_time_limit(600))并且它仍然崩溃并且说时间

兴奋。


所以请有人帮我找到摆脱僵局的方法。由于XSL处理缓慢,我现在无法继续前进。


我正在使用的代码是:

*******

//加载XML源

$ xml =新的DOMDocument;

$ xml - > load(''extract / marketplace_feed_v1.xml'');


$ xsl =新的DOMDocument;

$ xsl-> load(' 'cb_marketplace_feed_compact.xsl'');


//配置变压器

$ proc = new XSLTProcessor;

$ proc- > importStyleSheet($ XSL); //附上xsl规则


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

if($ sqlCommands == FALSE)

{

echo" XSLT转换失败" ;;

退出;

}


if(file_put_contents(''cbfeed.sql'',$ sqlCommands)== FALSE);

{

echo''无法保存XSLT转换结果到文件

" cbfeed.sql"'';

退出;

}

*** ****


您可以在此处上传我的脚本中使用的文件:

http://megliosoft.org/meglio/cbfeed/...ce_feed_v1.xml
http://megliosoft.org/meglio/cbfeed/...ed_compact.xsl

任何信息都可能有所帮助。


谢谢,

Anton

Hi.

I''m going to make in auto some tasks that I''m doing manually every
day. I''m uploading big XML file (~20mb) and then I''m using XSLT schema
to transform it to MySQL queries file.

I have used 3rd tools to process XSLT and it takes few seconds to
process my big XML file.

But now I''m moving to PHP so I''m trying to use XSL PHP extension to
apply my XSL file. But... it takes minutes... I allowed 10 minutes
( set_time_limit(600) ) and it still crashes and says that time
excited.

So please somebody help me to find a way out of the impasse. I can''t
move forward now because of slow XSL processing.

The code I''m using is:

*******
// Load the XML source
$xml = new DOMDocument;
$xml->load(''extracted/marketplace_feed_v1.xml'');

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

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

$sqlCommands = $proc->transformToXML($xml);
if ($sqlCommands == FALSE)
{
echo "XSLT transformation failed";
exit;
}

if (file_put_contents(''cbfeed.sql'', $sqlCommands) == FALSE);
{
echo ''Failed to save XSLT transformation result to the file
"cbfeed.sql"'';
exit;
}
*******

You can upload files used in my script here:

http://megliosoft.org/meglio/cbfeed/...ce_feed_v1.xml
http://megliosoft.org/meglio/cbfeed/...ed_compact.xsl
Any information may help.

Thanks,
Anton

解决方案

xml = new DOMDocument;
xml = new DOMDocument;


xml-> load(''extract / marketplace_feed_v1.xml'');

xml->load(''extracted/marketplace_feed_v1.xml'');


xsl = new DOMDocument;
xsl = new DOMDocument;


这篇关于PHP 5,大文件的XSL转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆