METHOD:  Object::transformNode

This method is a Microsoft extension to the W3C DOM.

Object  Attr   CDATASection   CharacterData   Comment   Document   DocumentFragment   DocumentType   Entity   EntityReference   Node   Notation   ProcessingInstruction   Text
 
Object.transformNode(stylesheet)

The transformNode method processes this node and its descendants using the specified XSL stylesheet, and returns the resulting transformation. The 'stylesheet' parameter must be either a valid XML document (which is assumed to be an XSL stylesheet), or a DOM node from an XSL stylesheet, in which case the node is treated as a stand-alone stylesheet fragment.

The source node defines a context for the stylesheet to operate on, but navigation outside this scope is allowed.

This method supports both standalone and embedded style sheets, and additionally provides the ability to run a localized style sheet fragment against a particular source node.

The following example demonstrates how this method can be used to display the contents of an XML file within an HTML page using an XSL stylesheet. First the code loads both the XML and XSL files, and then the transformNode method is used in conjunction with a document.write to display the contents at the desired place in the HTML document.

Code (JavaScript):
<script>
   xmldoc = new ActiveXObject("Microsoft.XMLDOM");
   xmldoc.async = false;
   xmldoc.load("beers.xml");

   xsldoc = new ActiveXObject("Microsoft.XMLDOM");
   xsldoc.async = false;
   xsldoc.load("beers.xsl");
</script>

<script>
   document.write(xmldoc.transformNode(xsldoc));
</script>



Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information