[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

AW: JScript extension function, which takes a result t

Subject: AW: JScript extension function, which takes a result tree and serializes it?
From: "Ilya Khandamirov" <ikh@xxxxxxxxxxx>
Date: Fri, 7 Sep 2001 19:27:36 +0200
jscript extension
Hi List,

I ended up with the following simple script which seems to work for all
kinds of data. Reviews are welcome. (Watch the line breaks)

<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[

	function saveToFile(nodes, outputFile) {
		var objFSO = new ActiveXObject("Scripting.FileSystemObject");
		var objFile = objFSO.CreateTextFile(outputFile, true);
		try {
			for (var i = 0; i < nodes.length; i++) {
				objFile.Write(nodes.item(i).xml);
			}
		}
		finally {
			objFile.Close();
			delete objFSO;
			delete objFile;
		}

		return("");
	}
]]>
</msxsl:script>

Regards,
Ilya



-----Ursprungliche Nachricht-----
Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von Ilya
Khandamirov
Gesendet: Freitag, 7. September 2001 17:06
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff:  JScript extension function, which takes a result tree and
serializes it?


Dear List,

I thought this should be a FAQ and i was surprised when found no information
on this issue. No samples, no explanations... Did i overlook something?

I would like to produce multiple output files during one transformation with
MSXML (I know, it is relatively easy to accomplish with other XSLT
prrocessors, but i have to do it with the one from Microsoft). Simplified
algorithm i'm going to use is as follows:


<msxsl:script language="JScript" implements-prefix="user">

	function saveToFile(data, outputFile) {
		// serialize, if needed, and
		// save to file here
		return("");
	}

</msxsl:script>

<xsl:template name="prepareDataForOneFile">

	<xsl:variable name="dataChunk">
	<!-- XSLT processing here -->
	</xsl:variable>

	<xsl:value-of select="user:saveToFile($dataChunk, $fileName)"/>
</xsl:template>


My question is how to treat, i.e. proccess, $dataChunk passed from a
template to an extension function? I guess, if $dataChunk contains pure XML,
then extension function receives a nodeset and the best way to process it is
just cycling through the nodes.

But wat happens, then the template returns, i.e. $dataChunk contains, HTML
or raw RTF code? I mean, what type of object will i get in this case in
function parameter - string, nodes, ...? How to access the parameter data to
save it to file? Sorry, it must be something obvious, but i'm stuck.

Any ideas, suggestions, comments and links on the topic are very much
appreciated.


p.s. Many thanks to all, answered my previous question: "xsl:sort - sorting
outline numbered values". Special thanks to David Carlisle and Francis
Norton.

Regards,
Ilya


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.