Re: XML Web Site + MySQL
- From: Mark <mnbayazit@xxxxxxxxx>
- Date: Tue, 25 Sep 2007 12:00:44 -0700
On Sep 25, 1:16 am, Pavel Lepin <p.le...@xxxxxxxxxxx> wrote:
Mark <mnbaya...@xxxxxxxxx> wrote in
<1190705655.141713.295...@xxxxxxxxxxxxxxxxxxxxxxxxxxx>:
I'm developing my website using XML + XSLT.
I hope you don't mean you serve XML documents with
xml-stylesheet PI's. As a rule of the thumb, that's a bad
idea. Transform server-side and serve HTML 4.01 Strict
instead. The reasons have been discussed half a zillion
times in the past on this newsgroup, as well as on several
others.
I'd like to insert some data into my XML from a MySQL
database. Typically I would do this with PHP, but my web
server doesn't seem to support PHP in *.xml documents.
The PHP is not invoked for those files. If you insist on
doing this, either reconfigure you http server to invoke
PHP for those files, or, if you're unable to do that, force
the invocation (by renaming/moving your files to match the
http server's idea of what PHP should be invoked for).
You'll need to set Content-Type via header() call as well.
Better yet, as I said above, transform server-side. PHP5
has XSL extension which uses libxslt as a transformation
engine.
You could also employ stored procedures to move the burden
of generating XML documents to SQL server. This path is
fraught with peril, though, since you need to ensure
well-formedness.
or something that produces the same effect. It would be
even nicer if I could somehow use XSLT to rewrite the XML
so that I could have tags like
<sql:query="SELECT * FROM blog"/>
<sql:for-each-row>
<title><sql:value-of select="title"></title>
...
</sql:for-each-row>
I don't like the idea. You already use PHP, presumably for
application logic/interfacing with the http server, SQL for
juggling you relational data, and XSLT for presentational
transformations. Now you want to introduce a custom
language with poorly defined domain into the equation. From
my (relatively extensive) experience with custom glues this
is going to have two main consequences:
1) The logic is going to drown in all that glue.
2) As you move forward, you'll realize that you want more
and more features in your language as you need done various
things you hadn't though of at first. This has two possible
outcomes: either you leave your language in this
rudimentary state and delegate the logic to PHP or SQL
anyway, or you slowly move towards Turing-completeness, the
end-result being a slow, poorly designed and frail language
of your own (think early versions of PHP/FI--in fact, the
scenario described is in a way how PHP came to be).
As a matter of fact, tinkering with languages of your own is
a wonderful pastime, but not recommended for Real Work
unless you're extremely sure of your footing.
To answer your specific question, what you want to achieve
is impossible with XSLT alone. It may be possible with
custom extensions for your XSLT processor, but quite a
chore anyway. A saner alternative is implementing a
separate processor for your language (in PHP/whatever), but
even that's a dangerous route to take due to reasons
outlined above.
--
"You hold judicial proceedings in drinking-houses!?"
"Poh! That judge is no more drunk than any magistrate of the
Old Bailey."
Very informative post. Thank you for taking the time to write that
all out!
If I can get XSLT to do all my dirty work, I may not need PHP at all.
I just need to figure out how to handle forms... then I won't have
such a muddle of technologies.
Yes, I am transforming the XML client-side. Which method do you
recommend for doing it server-side? Could you point me in the right
direction? I understand there are multiple ways to do this...
Reflex/Active Tags sounds like what I was looking for, but it might be
a little tricky to get working on my server. My host doesn't seem to
like me muddling with things (I somehow managed to crash the server
once already!)
I guess my last option is to do it all with PHP. I hope it isn't too
horrible to implement...
.
- Follow-Ups:
- Re: XML Web Site + MySQL
- From: Pavel Lepin
- Re: XML Web Site + MySQL
- From: Peter Flynn
- Re: XML Web Site + MySQL
- References:
- XML Web Site + MySQL
- From: Mark
- Re: XML Web Site + MySQL
- From: Pavel Lepin
- XML Web Site + MySQL
- Prev by Date: Re: Activity on this forum
- Next by Date: Re: XML Web Site + MySQL
- Previous by thread: Re: XML Web Site + MySQL
- Next by thread: Re: XML Web Site + MySQL
- Index(es):
Relevant Pages
|