Created
May 4, 2022 13:54
-
-
Save viewpointsa/678f15584029d0e0c7e822088abb0a33 to your computer and use it in GitHub Desktop.
VBscript XLST process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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