473,383 Members | 1,805 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,383 software developers and data experts.

dumping xml and xsl for PHP and MySQL

I currently create sites using xml and xsl to produce .html files. I'm
thinking about using PHP and MySQL instead for performance reasons. Is
there a way of using PHP to create a set of .html files in batch that
can then be hosted on a server? The server in question doesn't
necessarily support PHP.

Thanks in advance,
David

Apr 5 '06 #1
11 1702
da******@gmail.com wrote:
I currently create sites using xml and xsl to produce .html files. I'm
thinking about using PHP and MySQL instead for performance reasons. Is
there a way of using PHP to create a set of .html files in batch that
can then be hosted on a server? The server in question doesn't
necessarily support PHP.

Thanks in advance,
David


All depends on what hat kind of data you're using. If it's static, I
would just write out straight (X)HTML and use CSS to style it.

What kind of data are you wanting to use MySQL to store?

If you're looking to create separate components (say header, footer,
sidebar) and then inject them into each page, then you can write those
as HTML files, and in each php page

require_once( 'header.html' );
require_once( 'body.html');
.....

Apr 6 '06 #2
No, I'm talking about a technical specification encompassing thousand's
of pages.

David

Apr 6 '06 #3
da******@gmail.com wrote:
No, I'm talking about a technical specification encompassing thousand's
of pages.

David


David,

You could generate them statically and upload them. But personally I'd get a
server which supported PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 6 '06 #4
So, how would I go about creating them statically using PHP and MySQL?

Apr 6 '06 #5
da******@gmail.com wrote:
So, how would I go about creating them statically using PHP and MySQL?


There are a few options to parse XML. I like the DOM functions
[http://us2.php.net/manual/en/ref.dom.php] or even SimpleXML
[http://us2.php.net/manual/en/ref.simplexml.php] if you have php 5.
They'll let you access the nodes of your document, so then you can put
the data inside your HTML tags.

If the document is static, there's no use using MySQL since it's extra
load and processing time. Better to leave the XML in it's source form.

But even so, if the document is indeed static, it's really best to use
the XML parser and write the HTML out to text files, so that you'll
never have to do it again.

Apr 7 '06 #6
The specification a living document and so is updated all the time. I
was interested in using PHP and MySQL for performance reasons. My guess
is that using the XML parser would not provide the benefit I'm looking
for.

When I generate the HTML currently, I use the
org.apache.xalan.xslt.extensions.Redirect xml extension. Is there a
similar extension to PHP that I would use to redirect the PHP output to
an HTML file rather than just serving the .php via the server?

Thanks in advance,
David

Apr 7 '06 #7
David,

php.exe outputs HTML to a file by default. Download PHP locally (you
won't need Apache or anything else). Install the application. It will
install a "php.exe" file. You run it from a DOS prompt using something
like:

php.exe myscript.php > mypage.htm

php.exe will run myscript.php and send the output to mypage.htm.

-Robert

Apr 7 '06 #8
Great. Now, with my xsl code, I have one stylesheet that creates a page
for *each instance* of a particular type of xml element, e.g., foo. It
sounds like the method you mentioned assumes a 1:1 correspondance bw a
..php and .html. That won't work for my application as there can be
thousands of foo's. Is there another approach that might?

TIA,
David

Apr 7 '06 #9
David, if your xsl solution works for you, why switch over at all?

My understanding is that your server is 100% static and does not
support server side scripting and that you are doing the XML/XSL ->
HTML translations prior to uploading the static HTML to the server. Is
that correct?

Also, currently you have 1 XSL file and 1 XML file right? That single
XML file contains thousends of "foo"s and each one needs to end up in a
seperate HTML file once translated, is that correct? If so how have you
been doing that with XSL? Does XSL not assume a 1:1 ratio of XML input
to HTML output files?

-Robert

Apr 7 '06 #10
Robert,

As I mentioned before, I'm using a redirect feature implemented at
org.apache.xalan.xslt.extensions.Redirect and redirecting to a new html
file upon every iteration through a xsl:for-each loop on all foo's. An
equivalent PHP function is what I'm looking for.

XML processing is relatively slow and the processing of many different
xsl stylesheets (there's a lot more to the data than just foo's and the
stylesheets sometime incorporate fairly complex XPATH statements) takes
a couple of hours and I'm concerned about scalabilty.

I currently start by transforming the native markup of a UML modeling
tool we're using into a body of xml that conforms to my own schema. I
then transform that into the HTML as I've described above. I'm
currently considering whether it might be better to simply convert the
tool's native markup into SQL statements with which to construct a
database and then using PHP to generate the static pages more quickly.

So there you have the whole story. Thoughts?

Thanks again for your interest,
David

Apr 7 '06 #11
David,

PHP is not a translation language, it's a full blown programming
language with full file IO capabilities so PHP can certainly handle the
task at hand. The PHP manual is a great place to look. For example, see
here: http://www.php.net/manual/en/function.fopen.php (that is the PHP
function to open an external file for reading or writing).

I think what you want to do is populate a MySQL database with your XML
data. Do you know how to do this? Then create a PHP script to run
queries against the database to create the HTML pages. Also, since you
are not running these translations on the server, you are not in any
way restricted to using PHP. If you have Microsoft Office, you could
just as easily use a native windows application (your_program.exe) and
an access database for example. That would probably be easier as there
is less overhead involved for you. MySQL is a big pill to swallow for
just one app. :o)

Since you don't know much PHP you might want to hire a professional
coder to implement the project. Your project really isn't that complex
but the amount of experience its going to take to do this yourself is
way beyond what I can teach you. Rent-A-Coder is a good place to check.
I've been programming on there for a while and most of the guys there
are very smart and not too expensive. I'd probably charge in the $500
range and the project shouldn't take more than a day or two to
complete. Don't pay more than that.

http://www.rentacoder.com/

My coder username on rent-a-coder is rlee0001 and you have my offer
above.

If you really want to do this yourself, look through the manual at
http://www.php.net/ (this is where you download PHP too). If you need
help setting up PHP and MySQL and using the manual let me know and I'll
try to help.

-Robert

Apr 8 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: NotGiven | last post by:
I have a db that I need to dump into a format that can be easily read my MS Access. I tried the dump with regular PHPAdmin. Then I used the dump to run a query in MS Access. Errors occurred...
3
by: kerri | last post by:
Hi, I need to do a mysqldump of specific inserts, updates & deletes. I read in the docs that I can use -w or --where. Can I do a join? Could someone provide an example? Is there another...
6
by: Greg Brant | last post by:
Hi, how can i backup a table / entire DB and get the index's as well as the data / create table's etc cheers Greg
4
by: rozrabiak | last post by:
Hi:) I need to dump data from database in to *.sql file. I try it using DUMP DATABASE but it not work that I need it. So, how can I dump data from database in to *.sql file and then run it...
2
by: mr.kuhl | last post by:
I thought I would contribute a solution for once. We have a standard SUSE LAMP (Linux Apache Mysql PHP) server running some custom apps, of which one component is dumping reports out to excel. ...
10
by: ken | last post by:
hello, i'm writing a c program on a linux system. i'm debugging a segmentation fault but i don't want it to dump a core file because the memory footprint of the program is over 300Mb and i don't...
0
by: xpcer | last post by:
i was have an error when i dumping an database using mysql, this is the message: mysqldump: Got error: 1146: Table '↑╪◄ .v_sp_buku_dipinjam_denda' doesn't exist when using LOCK TABLES can...
1
by: lawrence k | last post by:
I'm trying to figure out how to export info from a Mysql database, using PHP to manage the export, as phpMyAdmin manages to do. I'm guessing I need to run a shell script that looks like this: ...
4
by: prosad | last post by:
hi! my problems: 1. i can not restore my database from my command line i type gives me: /*!40101 SET @OLD_CHARACTER...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.