473,395 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 3330
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike | last post by:
I am trying to code vb.net to perform XML transformations by applying a style sheet to a XML doc. All of my XML and XSLT documents will be in either XML DOM Objects or string variables. I am not...
0
by: Franck Perrin | last post by:
I'd like to know if there is a way to apply to successive XSL transformations on one XML file. I got this XML file : <page Action="N047"> <data defaultName="c0dos010" Type="String"...
5
by: Keith Chadwick | last post by:
I am migrating an existing ASP app that uses XSLT transformations to render against a language XML doc for localization and other items. When I moved this logic into .NET and the native xml and xsl...
1
by: Chris | last post by:
I am doing a little research into the xml web server control and in particular the ability to do transformations with it. However all's I can see is the ability to feed in from an actual xml file....
6
by: Christopher | last post by:
I am currently in the process of evaluating the performance hits of moving to the .NET platform for our application. I created a sample project that loads the transforms the same XML and XSLT in...
1
by: George Durzi | last post by:
Folks, I'm running into some performance issues with my Xsl transformations. I've done a ton of debugging and digging around, and have come to the conclusion that the performance issues are NOT...
0
by: Alain Frisch | last post by:
Hello, I'd like to announce a new small language for XML transformation, called XStream. Transformations written in XStream are compiled into efficient XML stream processors: the output is...
0
by: Hoax | last post by:
I didn't see a forum for OpenGL so i assume it would go here. I've having an issues with my camera interfering with the transformations of my geometry. Here is my Display() code, I think it's...
0
by: Geico Caveman | last post by:
Hello, I am trying to generate a doc file from latex source for a colleague (simple article class, using authblk package) through one of the two following ways : 1. Create an odt file using :...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.