Altova StyleVision Server 2025

The example below shows how to use VB Script code to generate an output RTF file using a PXF file and an input XML file. Ensure that StyleVision Server is installed and licensed and that it is available as a COM server object. Registration as a COM server object usually takes place during installation of StyleVision Server. To check if registration was successful, see About the COM Interface.

 

Option Explicit

 

'Create a StyleVision Server object; use "StyleVision_x64.Server" if you want to use the 64-bit installation

Dim objSVS

' Since we load a COM-DLL we need care about the process architecture

On Error Resume Next        ' ignore any COM errors avoiding uncontrolled script termination

Dim WshShell

Dim WshProcEnv

Set WshShell =  CreateObject("WScript.Shell")

Set WshProcEnv = WshShell.Environment("Process")

Dim process_architecture

process_architecture= WshProcEnv("PROCESSOR_ARCHITECTURE")

If process_architecture = "x86" Then

 Set objSVS = WScript.GetObject( "", "StyleVision.Server" )

 If Err.Number <> 0 then

         WScript.Echo("You are running in a 32-bit process but StyleVision Server COM-API 32-bit seems not to be installed on your system.")

         WScript.Quit -1

 End If

Else

 Set objSVS = WScript.GetObject( "", "StyleVision_x64.Server" )

 If Err.Number <> 0 then

         WScript.Echo("You are running in a 64-bit process but StyleVision Server COM-API 64-bit seems not to be installed on your system.")

         WScript.Echo("If you have installed 32-bit StyleVision Server consider calling your script from the 32-bit console 'C:\Windows\SysWOW64\cmd.exe.'")

         WScript.Quit -1

 End If

End If

On Error Goto 0                ' re-enble default error promotion

 

'Set a working directory - used for input, output and for intermediate files

'objSVS.WorkingDirectory = "C:\Program Files (x86)\Altova\StyleVisionServer2020\etc\examples"

objSVS.WorkingDirectory = ".."

 

'Default path to the StyleVision Server executable is the installation path (same dir with the StyleVisionServer.dll)

'In case you moved the binaries on the disk, you need to explicitly set the path to the .exe file

'objSVS.ServerPath = "C:\Program Files (x86)\Altova\StyleVisionServer2020\bin\StyleVisionServer_DebugDLL.exe"

 

' The Generate method will return 'True' if generation was successful otherwise 'False'.

' In the case of fundamental errors like termination of the server process a COM error will be raised which

' can be handled using the VBScript Err object.

On Error Resume Next        ' ignore any COM errors avoiding uncontrolled script termination

Err.Clear

 

WScript.Echo("Running " & objSVS.ProductNameAndVersion & vbCrlf)

 

'Prepare the name of the working XML

'    This can be an absolute/relative path if the file is stored externally (not inside PXF)

' objSVS.InputXML = "ExpReport.xml"

'    or it can contain the path INSIDE the PXF

objSVS.InputXML = "ExpReport.pxf|zip\ExpReport.xml"

'    or refer to the file as being embedded in the transformation file

'objSVS.InputXML = "altova://packagedfile/ExpReport.xml"

 

'Add output paths (absolute or relative to WorkingDirectory) for all formats that should be generated

' make sure you have write permissions

'objSVS.OutputRTF = "C:\tmp\ExpReport.rtf"

objSVS.OutputPDF = "C:\tmp\ExpReport.pdf"

'objSVS.OutputHTML = "C:\tmp\ExpReport.html"

 

'Prepare the parameters, if your design uses parameters

'Call objSVS.AddParameter( "testparam1", "value_1" )

 

' Run the transformation. The PXF file path can be relative to the working folder or absolute.

WScript.Echo("Generating output from ExpReport.pxf...")

If ( objSVS.Generate( "ExpReport.pxf" ) ) Then

 WScript.Echo( objSVS.LastExecutionMessage )

 WScript.Echo( "Success - finished execution" )

Else

 WScript.Echo( objSVS.LastExecutionMessage )

End If

 

' handle COM errors

If Err.Number <> 0 Then

 WScript.Echo("Internal error - " & Err.Description )

 WScript.Quit -1

End If

 

On Error Goto 0                ' re-enble default error promotion

 

 

© 2018-2024 Altova GmbH