Re: [xsl] New to the list

Subject: Re: [xsl] New to the list
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 31 Oct 2002 09:32:51 +0000
Hi Bix,

> My question is that suppose I just want to show the given node with
> its information, in a particular HTML format, how would I use the
> original XML and simple output HTML to a browser on-the-fly?

You need to script the transformation. From your description, I'd do
it by doing something like:

  1. Create an HTML page to hold the results; the HTML page can be
     empty aside from a <div> with an id that you will 'fill' with the
     results of the transformation.

  2. Include a <script> in the <head> of the HTML page. In that,
     create some global variables to hold the DOMs of both the source
     XML and the XSLT stylesheet that you want to use.

  3. Create a function that takes an argument that you can use to
     work out which node should form the source of the transformation;
     identify that node in the XML DOM and then use the
     .transformNode() method (with the XSLT DOM as the argument) to do
     the transformation; use the .innerHTML property of the <div> to
     set the content of the <div> to the result of the call to
     .transformNode().

  4. When you create the "links" have them call the function with the
     appropriate argument to identify the node.

To get more information about writing the script, have a look at:

  - the MSXML SDK documentation from http://msdn.microsoft.com/
  - the Clientside tutorials on Chris Bayes' site
    http://www.bayes.co.uk/xml
  - Appendix A (on MSXML 3) in Mike Kay's XSLT Programmer's Reference
    2nd Ed.
  - pp. 559-576 of Beginning XSLT (by me)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread