Skip to content

Instantly share code, notes, and snippets.

@viewpointsa
Created May 4, 2022 13:54
Show Gist options
  • Save viewpointsa/678f15584029d0e0c7e822088abb0a33 to your computer and use it in GitHub Desktop.
Save viewpointsa/678f15584029d0e0c7e822088abb0a33 to your computer and use it in GitHub Desktop.
VBscript XLST process
' https://stackoverflow.com/a/56497728/2137364
Sub XSLTransform( inputXml, inputXsl )
' REFERENCE Microsoct XML, v6.0
Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")
Set xslDoc = CreateObject("Msxml2.FreeThreadedDOMDocument.6.0")
Set xslTemp = CreateObject("Msxml2.XSLTemplate.6.0")
Dim xslProc
' LOAD XML AND XSL FILES
xmlDoc.async = False
xmlDoc.Load inputXml
'Wscript.Echo "load xml :" & xmlDoc.parseError
xslDoc.async = False
xslDoc.validateOnParse = False
xslDoc.resolveExternals = False
xslDoc.preserveWhiteSpace = True
xslDoc.setProperty "AllowDocumentFunction", True
xslDoc.Load inputXsl
'If xslDoc.parseError == 0 Then
' Wscript.Echo "load xsl: " & xslDoc.parseError
'End If
' INITIALIZE NEEDED OBJECTS
Set xslTemp.stylesheet = xslDoc
Set xslProc = xslTemp.createProcessor()
With xslProc
.input = xmlDoc
.addParameter "job", "PXJ_TEST1" ' ADD PARAMETER(S)
.addParameter "src", "MultiParamXSLT.xml"
.addParameter "spath", "TEST1"
.transform ' TRANSFORM XML
Wscript.Echo .output
'newDoc.LoadXML .output ' LOAD RESULT TREE
'newDoc.Save "Output.xml" ' SAVE OUTPUT TO FILE
End With
'Wscript.Echo "transform: " & xslProc.parseError
End Sub
Set Arg = WScript.Arguments
XSLTransform Arg(0), Arg(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment