Click to return to the XML (Extensible Markup Language) home page    
Using XSL in an Active Se...     Detecting and Handling XS...     Using the XSL Processor    
Web Workshop  |  XML (Extensible Markup Language)

Getting the Results of an XSL Transformation as a New DOM Document


The transformNodeToObject method provides a way to generate a new DOM document instead of XML text. In this example, data islands are used to load the XML source and the XSL style sheet, and an empty data island is created that will hold the results of the transformation.

<HTML>
  <SCRIPT FOR="window" EVENT="onload">
    data.transformNodeToObject(ss.XMLDocument, resultTree.XMLDocument);
  </SCRIPT>
  
  <XML id="data" src="portfolio.xml"></XML>
  <XML id="ss" src="portfolio.xsl"></XML>
  <XML id="resultTree"></XML>
</HTML>

Like the transformNode method, the transformNodeToObject method is applied to a node in the source tree, and accepts an XSL style sheet in the form of a DOM tree. A second parameter contains another DOM Document node that will hold the results of the transformation.

Properties set on the output XML DOM Document will be honored during the transformation, such as validateOnParse and async. Any previous children will be deleted during the transformation.

Try it! The above code is a simplification of the Transformation Viewer sample.

Download Download this sample.



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.