different webpages-1database

Discussion in 'XML' started by Piet L., Jan 21, 2005.

  1. Piet L.

    Piet L. Guest

    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
     
    Piet L., Jan 21, 2005
    #1
    1. Advertising

  2. Piet L.

    Andy Dingley Guest

    On 21 Jan 2005 03:49:41 -0800, (Piet L.) wrote:

    >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.


    --
    Smert' spamionam
     
    Andy Dingley, Jan 21, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruno Alexandre

    How to build WebPages?

    Bruno Alexandre, Jan 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    Mark Fitzpatrick
    Jan 23, 2004
  2. =?Utf-8?B?cmVpa3M=?=

    webpages

    =?Utf-8?B?cmVpa3M=?=, Jan 31, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    632
    Munsifali Rashid
    Jan 31, 2004
  3. chris

    Dynamic Webpages

    chris, Apr 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    353
    Steven Cheng[MSFT]
    Apr 2, 2004
  4. =?Utf-8?B?UHJhbmF2?=

    Export WebPages with a Chart to Excel

    =?Utf-8?B?UHJhbmF2?=, Apr 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,531
    =?Utf-8?B?UHJhbmF2?=
    Apr 7, 2004
  5. Champs
    Replies:
    2
    Views:
    183
    Champs
    Oct 10, 2003
Loading...

Share This Page