PHP 5, XSL transformations of big files

This is a discussion on PHP 5, XSL transformations of big files within the PHP Language forums, part of the PHP Programming Forums category; Hi. I'm going to make in auto some tasks that I'm doing manually every day. I'm uploading ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-02-2008
Meglio
 
Posts: n/a
Default PHP 5, XSL transformations of big files

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
Reply With Quote
  #2 (permalink)  
Old 05-03-2008
Thiago Macedo
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

try to use javascript xslt transformation:
http://www.w3schools.com/xsl/xsl_client.asp

probaly faster

Meglio wrote:
> 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

Reply With Quote
  #3 (permalink)  
Old 05-03-2008
Jerry Stuckle
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

Thiago Macedo wrote:
> try to use javascript xslt transformation:
> http://www.w3schools.com/xsl/xsl_client.asp
>
> probaly faster
>
> Meglio wrote:
>> 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

>


How is that going to help? Javascript is client side - he'd have to
download those large files, then do it on the client and finally upload
the results. And clients machines are typically less powerful than servers.

A very bad suggestion, IMHO.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #4 (permalink)  
Old 05-03-2008
Thiago Macedo
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

On May 3, 1:05 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Thiago Macedo wrote:
> > try to use javascript xslt transformation:
> >http://www.w3schools.com/xsl/xsl_client.asp

>
> > probaly faster

>
> > Meglio wrote:
> >> 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

>
> How is that going to help? Javascript is client side - he'd have to
> download those large files, then do it on the client and finally upload
> the results. And clients machines are typically less powerful than servers.
>
> A very bad suggestion, IMHO.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


sorry for not acquiring your "requisites".. but, if it will run on a
server, instead of download this large file, he'll upload it.. and
this is usually worst.
by the way, probaly the timeout is occurring in the file upload, not
in the transformation. already examined where it stops the execution?

regards,

Thiago
Reply With Quote
  #5 (permalink)  
Old 05-03-2008
Iván Sánchez Ortega
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

Jerry Stuckle wrote:

> Thiago Macedo wrote:
>> try to use javascript xslt transformation:

[...]
> How is that going to help?


By not crashing. This one's a quick & dirty automation task, so it ain't to
be pretty.

> Javascript is client side - he'd have to download those large files, then
> do it on the client and finally upload the results. And clients machines
> are typically less powerful than servers.


We can suppose the O.P. is inside a LAN and that semi-large files are not a
problem.




Meglio wrote:
> 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 might get kicked out of here for saying here, but maybe PHP isn't the
right tool for this particular job.

You can consider using PHP as a web frontend, and use exec() to call a
command-line xsltproc, or any other 3rd-party tool. You can also do
client-side processing, given you have set the size limits for uploads
right.


> I allowed 10 minutes ( set_time_limit(600) ) and it still crashes and says
> that time excited.


Can we have a look at the *exact* error message?


--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Y dijo el capitán Bloub: "Abordar el barco"... y les quedó precioso.
Reply With Quote
  #6 (permalink)  
Old 05-03-2008
Meglio
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

On May 3, 7:15 am, Thiago Macedo <thiago.ch...@gmail.com> wrote:
> On May 3, 1:05 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
>
> > Thiago Macedo wrote:
> > > try to use javascript xslt transformation:
> > >http://www.w3schools.com/xsl/xsl_client.asp

>
> > > probaly faster

>
> > > Meglio wrote:
> > >> 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

>
> > How is that going to help? Javascript is client side - he'd have to
> > download those large files, then do it on the client and finally upload
> > the results. And clients machines are typically less powerful than servers.

>
> > A very bad suggestion, IMHO.

>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck...@attglobal.net
> > ==================

>
> sorry for not acquiring your "requisites".. but, if it will run on a
> server, instead of download this large file, he'll upload it.. and
> this is usually worst.
> by the way, probaly the timeout is occurring in the file upload, not
> in the transformation. already examined where it stops the execution?
>
> regards,
>
> Thiago


>> if it will run on a server, instead of download this large file, he'll upload it.. and

this is usually worst.

THIS is not worst because when I do it manually I still transform XML
to SQL (which is big file too) and upload it to the server. So I have
to upload SQL to the server in any case. The goal is to upload XML
directly to the server on auto and to transform it to SQL file using
PHP script.

>> by the way, probably the timeout is occurring in the file upload, not

in the transformation. already examined where it stops the execution?

I'm not so stupid to ask question before to examine where it stops. It
freezes on XSL transformation.
Reply With Quote
  #7 (permalink)  
Old 05-03-2008
Meglio
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

Fatal error: Maximum execution time of ... seconds exceeded in ... on
line ...
Reply With Quote
  #8 (permalink)  
Old 05-03-2008
Piotr
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

Meglio wrote:
> 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.


Maybe there is some issue that causes PHP xslt processor to fail or go
into infinite loop. Try cutting the xsl template to few smaller parts
(just for test) and see if the error occurs in any specyfic part. Maybe
there is some syntax used that PHP doesn't really like..

Not an xsl expert, so if this is way off, just ignore..

best regards
Piotr N
Reply With Quote
  #9 (permalink)  
Old 05-03-2008
Meglio
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

On May 3, 11:29 am, Piotr <s...@poczta.onet.pl> wrote:
> Meglio wrote:
> > 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.

>
> Maybe there is some issue that causes PHP xslt processor to fail or go
> into infinite loop. Try cutting the xsl template to few smaller parts
> (just for test) and see if the error occurs in any specyfic part. Maybe
> there is some syntax used that PHP doesn't really like..
>
> Not an xsl expert, so if this is way off, just ignore..
>
> best regards
> Piotr N


Hi. Thanks for you advice. But i'm not XSLT expert too so it is not
simple way for me to find such bug. So I'm still looking for an expert
who can help me to understand where the problems is.

Thanks,
Anton
Reply With Quote
  #10 (permalink)  
Old 05-03-2008
Piotr
 
Posts: n/a
Default Re: PHP 5, XSL transformations of big files

Meglio wrote:
>> Maybe there is some issue that causes PHP xslt processor to fail or go
>> into infinite loop. Try cutting the xsl template to few smaller parts
>> (just for test) and see if the error occurs in any specyfic part. Maybe
>> there is some syntax used that PHP doesn't really like..
>>
>> Not an xsl expert, so if this is way off, just ignore..
>>
>> best regards
>> Piotr N

>
> Hi. Thanks for you advice. But i'm not XSLT expert too so it is not
> simple way for me to find such bug. So I'm still looking for an expert
> who can help me to understand where the problems is.
>
> Thanks,
> Anton


Afaik, you should find tags like his:

<xsl:template match="some_tag">
[..]
</xsl:template>

if you have more then one, simply comment all but one, see if this times
out, if it doesn't, comment this template out and uncomment next one. Do
so as long as you find the one that times out.

When you find that one, comment out some functions, like xsl:for-each.
To comment, use <!-- --> syntax.

I suppose there is also xsl group for xslt specific problems.

best regards
Piotr N
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:49 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0