[plug] [OT] XSTL .vs. PHP .vs. ???

James Devenish devenish at guild.uwa.edu.au
Fri Jun 4 22:34:54 WST 2004


In message <40BEDEBA.7060902 at tigris.org>
on Thu, Jun 03, 2004 at 04:18:02PM +0800, Tim White wrote:
> I am currently making a mock up interactive zoo. I am trying to work out 
> the best way to handle the animal data although I want to store it in 
> XML. The server I am using only has Apache and PHP (4 i think) and no 
> database access. I am also hoping to be able to produce the IZoo in such 
> a way that it can be put onto a CD-ROM and used for offline browsing.
> I know that with XSLT I can use javascript to do this offline.
> All that I need to work out is it better to use XSLT or PHP which loads 
> the animal data in to variables and just outputs the file with the 
> blanks filled in.

With the information you've given, there's no particular reason to use
either xSL or PHP -- it's pretty much an apples-and-oranges comparison!
Remember that XSLT is not a procedural programming language like PHP.
Without knowing the significance of the word "interaction" for your app,
my first thought is that you would want to produce a set of static pages
regardless of whether you were serving them via a web page or a CD-ROM.

If, on the other hand, you need to respond to user feedback in a manner
that is more sophisticated than those "choose your own adventure" books,
XSLT is not in itself what you are looking for. You may still choose to
use a XSLT-based process, but you would still need some other support.

As for your 'offline' situation, and the question of whether browser
scripting is appropriate, you need to supply more information.

> The other main problem I have is whether I use a separate XML file for 
> each animal and have the PHP parse a different file each time or I have 
> one big file and parse that with an xsl:if. If that is the recommended 
> way then how do I 1. Set a variable so that only that animals part of 
> the tree is parsed and 2. how do i use that variable in an xsl:if.

I'm not sure what xsl:if has to do with this.

I'd suggest putting all the data in a single file because it makes it so
much easier to do clever things. An alternative is to put each animal's
data into a separate file but also have a 'master' file that includes
all the others. Where you might like to start is to store your animals
in separate files, then use XInclude to derive a static 'combined' XML
file that combines the contents of all the others. That way, you can
experiment with both styles.

More information about the plug mailing list