470,833 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

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
Jun 2 '08 #1
12 3213
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
Jun 2 '08 #2
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.
js*******@attglobal.net
==================

Jun 2 '08 #3
On May 3, 1:05 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
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
Jun 2 '08 #4
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.
Jun 2 '08 #5
On May 3, 7:15 am, Thiago Macedo <thiago.ch...@gmail.comwrote:
On May 3, 1:05 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
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.
Jun 2 '08 #6
Fatal error: Maximum execution time of ... seconds exceeded in ... on
line ...
Jun 2 '08 #7
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
Jun 2 '08 #8
On May 3, 11:29 am, Piotr <s...@poczta.onet.plwrote:
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
Jun 2 '08 #9
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
Jun 2 '08 #10
On May 3, 12:20 pm, Piotr <s...@poczta.onet.plwrote:
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
I'm not sure I'll get working XSL template if I comment some
instructions.
Jun 2 '08 #11
Meglio wrote:
>
I'm not sure I'll get working XSL template if I comment some
instructions.
It wont produce any good result for sure, but at this point, you
are just checking for what is causing the problem with PHP.
But as i said before, maybe it would be better to ask on xsl group about
template debugging.

best regards
Piotr N
Jun 2 '08 #12
On May 3, 12:20 pm, Piotr <s...@poczta.onet.plwrote:
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
I'm not sure whether this is PHP or XSLT problem so I have created
another thread in XSLT group too:
http://groups.google.com/group/micro...fd7cc536afaa3#
Jun 2 '08 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mike | last post: by
5 posts views Thread by Keith Chadwick | last post: by
1 post views Thread by Chris | last post: by
6 posts views Thread by Christopher | last post: by
1 post views Thread by George Durzi | last post: by
reply views Thread by Alain Frisch | last post: by
reply views Thread by Hoax | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.