XSLT Tutorial
Worksheet 8: XSLT: Putting it all together
For this worksheet, open the default.htm in Notepad (or
double-click on the file and then view source in the browser).
In the function, transformFiles() :
Load the XML and XSLT files, making sure you go through all the
basics of loading XML files, for excample your async property, checking for
load errors, etc.:
set xslDoc=createObject("MSXML2.DOMDocument.3.0")
set xmlDoc= createObject("MSXML2.DOMDocument.3.0")
We need to have a container in which to output the transformation
HTML. For this we use a <div> element to output the transformation,
by getting
a reference to the <div> found in the HTML body.
set objDiv = document.all("divHeadlines")
We then call the transformNode method on the DomDocument to output
the transformed HTML into the DIV's InnerHTML property:
strHTML = xmlDoc.transformNode(xslDoc)
objDiv.innerHTML =
strHTML
Note: The reason that I say this is
the basics, is because one the latest version of the msxml DOM, there
are methods and objects for allowing one to cache the XSLT files, called
templates.
When we spoke about the xsl:param element, there are also methods
and objects for allowing one to pass a parameter to the XSLT file.
|