Save the file as Data IslandTransformationhtm

<! -- Data Island #1 contains raw XML data in External file -->

<XML id="source" src="Courses.xml"></XML> <! -- Data Island #2 contains the XSL stylesheet in External file -->

<XML id="style" src="Courses.xsl"></XML> <! -- Insert the Transform result into a DIV element -- > <DIV id="displayOutput"></DIV>

<SCRIPT language=vbscript>

displayOutput.innerHTML = source.transformNode(style.XMLDocument) </SCRIPT> </BODY>

3. Open the newly created HTML file in your browser. The code above begins with the definition of two data islands named source and style and a blank HTML <DIV> tag named displayOutput. The source data island contains a reference to the raw XML document. The style data island points to the XSLT stylesheet containing the formatting instructions. In order to apply XSLT formatting instructions to the XML data, you need to write client-side VBScript code with the following statement:

displayOutput.innerHTML = source.transformNode(style.XMLDocument)

This line uses the tranformNode method of the XMLDocument object to apply the stylesheet to the Raw XML document named source. The result of the transformation is then assigned to the innerHTML property of the DIV tag named displayOutput for displaying in a web page. The result of the preceding code is illustrated in Figure 17-22.

Figure 17-22:

By using client-side VBScript with Dynamic HTML and XSLT stylesheet, you can transform the contents of XML data islands to render them on the web page.

Figure 17-22:

By using client-side VBScript with Dynamic HTML and XSLT stylesheet, you can transform the contents of XML data islands to render them on the web page.

0 0

Post a comment