This is probably something that should go into a beginner's FAQ
somewhere, because it seems to be kind of fundamental. If you don't have
an answer to this one, you're stuck and can go no further with XSLT, it
seems.
Basic question: how do I get my XSLT transformation to show up in a web
browser?
1. If you know the browser is a late-model, full-featured application
like Mozilla, IE 6 or Opera 7+ (? help me here...) then you can tell it
to display the XSLT directly. The way I do it is:
In the XML, put a header thus:
<?xml version="1.0" encoding="..."?>
<?xml-stylesheet type="text/xsl" href="my_xslt_stylesheet.xslt"?>
Now, when a user follows a link to that XML document, it will load up the
stylesheet first, transform the XML, and display the result.
2. If you want the page to work on any browser (obviously recommended if
it's not, say, a corporate intranet, or just for your own use) you need
to do the transformation yourself. There are two ways. One is to run
your XSLT-transformer-of-choice in advance to produce an HTML page, and
save that page into your website, so that nothing ever changes and the
user only gets a static page. The other way is to transform it
dynamically. The only way I know of is using PHP's Sablotron, which is
the built-in XSLT transformation engine. Instructions are on
<http://www.php.net/>; like most PHP documentation, the quality is not
the best, but you can usually work it out with a bit of head-scratching.
A typical example, without error handling or other complexities, off the
top of my head:
<?php
$xh = xslt_create();
print
xslt_transform($xh,'file:my_xml_data.xml','file:my_xslt_stylesheet.xslt');
xslt_free($xh);
?>
(Note the "file:" part; this is important.)
Hope this is a start. How do non-PHP people do it? Someone mentioned
JavaScript, which made my blood freeze in horror...
: Bat :
------------------------------------------------------------
Fruitbat PO Box 1269, Belconnen ACT 2616
Eric TF Bat http://flurf.net/
Paul Sleigh bat(_at_)flurf(_dot_)net
Karl Faustus von Aachen 0407-468-244
------------------------------------------------------------
It all sounds rather naive and sentimental to be talking
about children laughing and dancing and singing together
when we all know perfectly well that what children do in
real life is snarl and take drugs.
- Douglas Adams, _The Salmon Of Doubt_
------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list