Re: [xsl] How to simplify this?

Subject: Re: [xsl] How to simplify this?
From: a.m@xxxxxxxxxxx
Date: Thu, 23 Sep 2004 14:01:09 +0200
Hi!

>>>
> Missed some of this thread but what do you mean a VBScript error?
> Where does
> VBScript enter the equation?
>>>

On the transform part:

OutFile.Write xmlSource.transformNode(xslSource)

Here the full code, i think there are no bugs:

' Call it: transform.vbs mydoc.xml mysheet.xsl output.html
' require: MSXML 3, MSXML 4, xinclude.exe

Option Explicit

' check the correct Argument number

If ( WScript.Arguments.Count <> 3 ) Then
    WScript.echo("Usage: transform.vbs mydoc.xml mysheet.xsl
output.html")
Else
	Dim strErr
	Dim newShell
	Dim exec
	Dim strXML

	Dim xmlSource
	Dim xslSource


	' resolve xinclude elements

	'Set newShell = CreateObject( "WScript.Shell" )
	'Set exec = newShell.Exec( "xinclude.exe " &
WScript.Arguments(0) )
	'strXML = exec.StdOut.ReadAll()
	'WScript.Echo strXML


	' create DOM from resolved XML

	Set xmlSource = CreateObject( "MSXML2.DOMDocument.4.0" )
	xmlSource.async = False
	xmlSource.validateOnParse = True

	If ( xmlSource.loadXML( WScript.Arguments(0) ) ) Then
	    'WScript.echo("conform document")
	Else
	    strErr = Err.Description & vbCrLf
	    strErr = strErr & xmlSource.parseError.reason & " line: "
& xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos
& " text: " & xmlSource.parseError.srcText
	    MsgBox strErr, vbCritical, "Error loading the XML"
	End If


	' load XSL-File

	Set xslSource = WScript.CreateObject(
"MSXML2.DOMDocument.4.0" )
	xslSource.async = False
	xslSource.validateOnParse = True

	If ( xslSource.load( WScript.Arguments(1) ) ) Then
	    'WScript.echo("conform document")
	Else
	    strErr = Err.Description & vbCrLf
	    strErr = strErr & xslSource.parseError.reason & " line: "
& xslSource.parseError.Line & " col: " & xslSource.parseError.linepos
& " text: " & xslSource.parseError.srcText
	    MsgBox strErr, vbCritical, "Error loading the XML"
	End If


	Dim OutFile
	Dim FSO
	Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
	Set OutFile = FSO.CreateTextFile(WScript.Arguments(2))


	OutFile.Write xmlSource.transformNode(xslSource)
	OutFile.Close

	'Set newShell = CreateObject( "WScript.Shell" )
	'Set exec = newShell.Exec( "C:\Programme\Internet
Explorer\iexplore.exe D:\Anton\rovero\" & WScript.Arguments(2) )
End If

best wishes
A. Metz

Current Thread