p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   how to save html output of xslt to file (http://p2p.wrox.com/showthread.php?t=2532)

wtalbin August 6th, 2003 02:30 PM

how to save html output of xslt to file
 
Afraid I'm fairly new to xml, xslt and java. Need some [hopefully] quick advice.

I'm using the DOM method transformNodeToObject (MSXML 4.0) within a jscript to create some html output. Everything works fine within the script for loading the xml and xsl documents, performing the transform and seeing a WScript.Echo of the results. My final html looks just the way I want it.

[u]Problem</u>: I can't figure out how to save this html output to file on my local C:\ drive. I've tried the DOM save method but this is for saving xml files; and my html doesn't make it through the parser as well-formed data. I'm thinking this has got to be something already figured out...

As a novice I appreciate your advice.

joefawcett August 7th, 2003 12:42 AM

If, as you say, the transform is successful then into what object did you transform into. If your results are not xml then you will have to do one of two things, either use the transformNode object to return a string which you can write to a text file using the "Scripting.FileSystemObject" which can then be saved or using a different class for the second argument to the transformNodeToObject. You will need one that implements IStream and the easiest to use in a COM scenario is "Adodb.Stream", available with Adodb versions 2.5 and above.
Once you have created an instance of the stream and output to it then you can save the results to a file. For details of all its methods and examples consult MSDN online.

--

Joe

Patanjali August 15th, 2003 09:14 PM

Saving the output of the transform as XML from the DOM will work if you create XHTML (HTML obeying XML rules) in your XSLT.

The rules are simple:
- always use end tags or the special no-content form (<img />)
- always quote attribute values
- always give an attribute a value



All times are GMT -4. The time now is 12:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.