First page Back Continue Last page Graphics
...Linking to Document
HTML script:
- JavaScript or VBScript in HTML
- Uses IE transformNode( ) method
- See notes for an example…
Embedded in document:
- You can embed the style sheet in the document
- Least flexible option; style sheet becomes part of document’s DOM tree
- Style sheet must ignore itself when processing tree
- See notes for an example...
Custom software:
- An application can use an XSL API to transform a document using a style sheet
Notes:
This example illustrates how JavaScript can create a DOM tree for a document and a style sheet, then use the latter to transform the former. The transformNode( ) method is proprietary to IE’s implementation of DOM.
<HTML>
<BODY>
<DIV ID="insertHTML"></DIV>
<SCRIPT LANGUAGE=JavaScript>
<!-- Create tree from source document -->
var XMLDoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
XMLDoc.load("schedule.xml");
var XMLDocElem = XMLDoc.documentElement;
<!-- Create tree from style sheet -->
var XSLDoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
XSLDoc.load("schedule.xsl");
var XSLDocElem = XSLDoc.documentElement;
<!-- Apply style sheet to source document -->
result = XMLDocElem.transformNode(XSLDocElem);
insertHTML.innerHTML = result;
</SCRIPT>
</BODY>
</HTML>