different webpages-1database

P

Piet L.

hey,
I have a huge database (MySQL), and now I want to display that
information
on my website. I want to organize it in such way that the user can say
what he wants to see.
For example, only cd's from the years 2000, or all books from author
x, ...
I'v looked around on the net, and this is what I came up with:
use a script that returns xml, use xslt to extract the wanted
information out of the xml, in the right order, formatted in the
wanted manner.
But now the problem:
can I do all of this with 1 script? (I prefer perl),
how do I generate the xml file?
do I use parameters or is there an other way (and so, how should this
be organized)
What about performance?

An example can help me a lot, a prototype or something.
....

Lots of questions, so waiting for lots of answers.

THANKS
 
A

Andy Dingley

can I do all of this with 1 script? (I prefer perl),

Yes, easily. You will use multiple XSLT files to get the variation
between sites or page types. The "script" that executes the transform
can be very static.
how do I generate the xml file?

Pretty easy - query the database, walk through the rows and append
them to a DOM. The use the DOM to write out an XML document (if you
want to store it) or keep the DOM in memoy and apply XSLT to it
directly.

Don't write your own XML serializer (i.e. print statements to a file)
- use a DOM instead. You don't even _need_ a serializer, unless it's
for some caching or debug purposes. The DOM will give you an XML
document in memory and the XSLT transform can operate on it there.
do I use parameters or is there an other way (and so, how should this
be organized)

You shouldn't have much need for them. Parameterise the SQL queries
(although this is hard in MySQL, for something with the compelxity of
a search - you'll need to emulate SQL stored procs in the Perl layer).

Beyond that point the XSLT can usually be fairly parameter free. If
you need some, they're often best supplied through the XML source
document, not by setting param values on the stylesheet.

What about performance?

Use XSLT to format and _maybe_ sort, but don't use it to filter. Have
the database do that.

Always know what you're doing. XSLT is a declarative language (sic)
and those are infamous for involving huge numbers of clock cycles to
execute an apparently simple task. I've seen XML-based systems that
pulled 20MB of XML from a database, just so as to allocate a new ID
number by counting to three and adding one ! Keep you eye on that
designed architecture, the data flows and don't just let the code
write itself.

XSLT transformations themselves are fast and efficient. Loading and
parsing XML documents from files, and _especially_ loading XSLT
documents into a transform engine are slow. Good efficiency at this
point depends on caching the loaded XSLT stylesheets between pages (I
have no idea how to do this with mod_perl). Unless there's much
searching or filtering going on, it may also be worth caching some XML
intermediate documents.

An example can help me a lot, a prototype or something.

Sorry, that's more Perl than I know.


Don't write your own XML serializer. Really. I'm sick of seeing
people screw projects up by doing this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top