Subject: Re: [xsl] writing to file from MSXML 4.0 From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx> Date: Fri, 6 Jun 2008 14:41:26 +0100 |
-------------------------------------------------- From: "Christian Wittern" <cwittern@xxxxxxxxx> Sent: Friday, June 06, 2008 2:10 PM To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] writing to file from MSXML 4.0
Dear Joe,Chris
Thanks for the quick answer.
Chris
Basically you use transformNodeToObject, there's an example here:http://msdn.microsoft.com/en-us/library/ms766561(VS.85).aspxIf your output is XML then use the same logic as the example exceptinstead of the last line (WScript.echo) use result.save(<path to >DomDocument to accept the result and write to disk.save to>). If the output is not XML you can use an ADODB.Stream instead of a
I guess you are talking about this example:
// Load data. var source = new ActiveXObject("Msxml2.DOMDocument.3.0"); source.async = false; source.load("hello.xml"); if (source.parseError.errorCode != 0) { var myErr = source.parseError; WScript.Echo("You have error " + myErr.reason); } else { // Load style sheet. var stylesheet = new ActiveXObject("Msxml2.DOMDocument.3.0"); stylesheet.async = false; stylesheet.load("hello.xsl"); if (stylesheet.parseError.errorCode != 0) { var myErr = stylesheet.parseError; WScript.Echo("You have error " + myErr.reason); } else { // Set up the resulting document. var result = new ActiveXObject("Msxml2.DOMDocument.3.0"); result.async = false; result.validateOnParse = true; // Parse results into a result DOM Document. WScript.Echo(source.transformNodeToObject(stylesheet, result)); } }
Unfortunately, this is doing the reverse, calling a XSL transform from Jscript. What I need is calling JScript from XSLT. The following is the closest I found to what I need:
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://mycompany.com/mynamespace">
<msxsl:script language="JScript" implements-prefix="user"> function xml(nodelist) { return nodelist.nextNode().xml; } </msxsl:script>
<xsl:template match="/"> <xsl:value-of select="user:xml(.)"/> </xsl:template>
</xsl:stylesheet>
However what I do not understand is, how to get an object that can be saved in the msxsl:script block.
All the best,
Chris
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] writing to file from MSXM, Christian Wittern | Thread | [xsl] self axis vs ., Andrew Welch |
Re: [xsl] XQuery basics, Andrew Welch | Date | Re: [xsl] XQuery basics, Robert Koberg |
Month |