Altova XMLSpy 2024 Professional Edition 

COM specifies that a client must register itself at a server for callbacks using the connection point mechanism. The automation interface for XMLSpy defines the necessary event interfaces. The way to connect to those events depends on the programming language you use in your client. The following code listing shows how this is done using VBScript.

 

The method WScript.ConnectObject is used to receive events.

 

To run this code, paste it into a file with .vbs extension, and either double-click in Windows Explorer, or run it from a command prompt.

 

' the event handler function
Function DocEvent_OnBeforeCloseDocument(objDocument)
  Call WScript.Echo("received event - before closing document")
End Function
 
' create or connect to XmlSpy
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objSpy = WScript.GetObject("", "XMLSpy.Application")
' If only Authentic is installed (and XMLSpy is not installed) use:
' Set objSpy = WScript.GetObject("", "AuthenticDesktop.Application")
' If only XMLSpy 64-bit is intalled, use:
' Set objSpy = WScript.GetObject("", "XMLSpy_x64.Application")
 
' create document object and connect to its events
objSpy.Visible = True
 
' Find out user's personal folder and locate one of the installed examples.
personalFolder = objWshShell.ExpandEnvironmentStrings("%UserProfile%")
majorVersionYear = objSpy.MajorVersion + 1998
xmlspyExamplesFolder = personalFolder & "\Documents\Altova\XMLSpy" & majorVersionYear  & "\Examples\"
docPath = xmlspyExamplesFolder & "ExpReport.xml"
 
' open a document
Set objDoc = objSpy.Documents.OpenFile (docPath, False)
Call WScript.ConnectObject(objDoc, "DocEvent_")
 
' keep running while waiting on the event
' in the meantime close the document in XMLSPY manually
Call WScript.Echo ("sleeping for 10 seconds ...")
Call WScript.Sleep (10000)
 
Set objDoc = Nothing
Call WScript.Echo ("stopped listening for event")
Call objSpy.Quit

 

 

 

Nota:En la versión de 32 bits de XMLSpy, el nombre registrado o identificador programático (ProgId) del objeto COM es XMLSpy.Application. Para la versión de 64 bits de XMLSpy, el nombre es XMLSpy_x64.Application. Sin embargo, debe tener en cuenta que el programa que realiza las llamadas accede a las entradas de registro CLASSES de su propio subárbol o grupo (de 32 o 64 bits). Por tanto, si ejecuta scripts usando la línea de comandos estándar y el explorador de Windows en una instancia Windows de 64 bits, el programa accederá a las entradas de registro de 64 bits, que apuntan a la versión de 64 bits de XMLSpy. Por eso, si tiene instaladas tanto la versión de 32 bits como la versión de 64 bits de XMLSpy necesitará dar un rodeo para llamar a la versión de 32 bits. Por ejemplo, si el programa que realiza las llamadas es Windows Scripting Host, haga lo siguiente:

 

1.Cambie el directorio actual a C:\Windows\SysWOW64.

2.En la línea de comandos, escriba wscript.exe seguido de la ruta de acceso a la secuencia de comandos que desea ejecutar, por ejemplo:

 

wscript.exe "C:\Users\...\Documents\Altova\StyleVision2024\StyleVisionExamples\API\JScript\start.js"wscript.exe "C:\Users\...\Documents\Altova\XMLSpy2024\Examples\API\JScript\start.js"

© 2018-2024 Altova GmbH