473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

javascript with wscript filesystemobject

Hi, I'm trying to write to a file.

The file is getting created.

The file is even getting written to because the file ends up being one
kb. so I guess there is something coming in.

The code that is driving me crazy right now is:

xslDoc2.load("C:/projects/tests/schematron/suchen/validationreport.xsl");
xslt2.stylesheet = xslDoc2;
xslProc2 = xslt2.createProcessor();
xslProc2.input = xmlDoc;
xslProc2.transform();

WScript.Echo(xslProc2.output);
openfile = fso.GetFile(newFileObject);
openedfile = openfile.OpenAsTextStream(2, true);
openedfile.Write(xslProc2.output);

openedfile.Close();

The XSLT above is being loaded. the transform executed, the output
echoed.

But when I try to write that output to the file it does not work. note
the file is getting created and it exists.

Thanks

Aug 1 '06 #1
2 2397


pantagruel wrote:

xslDoc2.load("C:/projects/tests/schematron/suchen/validationreport.xsl");
xslt2.stylesheet = xslDoc2;
xslProc2 = xslt2.createProcessor();
xslProc2.input = xmlDoc;
xslProc2.transform();

WScript.Echo(xslProc2.output);
openfile = fso.GetFile(newFileObject);
openedfile = openfile.OpenAsTextStream(2, true);
^^^^
That parameter should be -1 for Unicode (UTF-16), 0 for ASCII, -2 for
the Windows default code page (e.g. Windows-1252).
openedfile.Write(xslProc2.output);

openedfile.Close();
What kind of transformation result are you trying to create? If you want
to create an XML document as the result of the transformation then it is
much easier to do e.g.
// you need to adapt the version number so it is consistent
// with the other objects you use above
var resultDocument = new ActiveXObject('Msxml2.DOMDocument.3.0');
xslProc2.output = resultDocument;
xslProc2.transform();
resultDocument.save('C:\\temp\\file.xml');
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 1 '06 #2
Thanks, I ended up:

result = xslProc2.output;
result.toString();

if(displaymessage=="true"){WScript.Echo(result)};

//save error text to file.

openfile= fso.OpenTextFile(newFileObject,8,true);
openfile.Write(result);
openfile.Close();

Needed to do it that way to get a text output.
Thanks
Martin Honnen wrote:
pantagruel wrote:

xslDoc2.load("C:/projects/tests/schematron/suchen/validationreport.xsl");
xslt2.stylesheet = xslDoc2;
xslProc2 = xslt2.createProcessor();
xslProc2.input = xmlDoc;
xslProc2.transform();

WScript.Echo(xslProc2.output);
openfile = fso.GetFile(newFileObject);
openedfile = openfile.OpenAsTextStream(2, true);
^^^^
That parameter should be -1 for Unicode (UTF-16), 0 for ASCII, -2 for
the Windows default code page (e.g. Windows-1252).
openedfile.Write(xslProc2.output);

openedfile.Close();

What kind of transformation result are you trying to create? If you want
to create an XML document as the result of the transformation then it is
much easier to do e.g.
// you need to adapt the version number so it is consistent
// with the other objects you use above
var resultDocument = new ActiveXObject('Msxml2.DOMDocument.3.0');
xslProc2.output = resultDocument;
xslProc2.transform();
resultDocument.save('C:\\temp\\file.xml');
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rcmail14872 | last post by:
I have seen some very general suggestions for alternative code to the WScript.Shell code, but nothing specific. In the two lines of code below (I think) the first line creates a text file on the...
3
by: nithidolly | last post by:
I have an array with a list of files and would like to open them one by one and process them using a Filesystem object. But I am getting a "Function expected" error. Here is my code snippet: ...
2
by: =?Utf-8?B?VG9kZA==?= | last post by:
Hello I'm using the following script to try and ping: <% Response.Buffer = true %> <% url = "www.espn.com" Set objWShell = CreateObject("WScript.Shell") Set objCmd = objWShell.Exec("ping " &...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.