Altova Authentic 2024 Desktop

COM definiert einen Client, der sich über den Connection Point-Mechanismus als Server für Callbacks registrieren muss. Das Automation Interface für XMLSpy definiert die dafür erforderlichen Event Interfaces. Wie eine Verbindung zu diesen Events hergestellt wird, hängt von der Programmiersprache ab, die Sie auf Ihrem Client verwenden. Im folgenden Codefragment wird gezeigt, wie dies in JScript erfolgt.

 

Die Methode WScript.ConnectObject dient zum Empfang von Events.

 

// The event-handler function
functionDocEvent_OnBeforeCloseDocument(objDocument)
{
 WScript.Echo("Received event - before closing document");
}
 
// Create or connect to XMLSpy (or Authentic Desktop)
try
{
 // Create the environment and XMLSpy (or Authentic Desktop)
 objWshShell = WScript.CreateObject("WScript.Shell");
 objFSO = WScript.CreateObject("Scripting.FileSystemObject");
 objSpy = WScript.GetObject("", "XMLSpy.Application");
 
// If only Authentic Desktop is installed (and XMLSpy is not installed) use:
// objSpy = WScript.GetObject("", "AuthenticDesktop.Application")
 
}
catch(err)
 { WScript.Echo ("Can't create WScript.Shell object or XMLSpy"); }
 
// Create document object and connect to its events
objSpy.Visible = true;
majorVersionYear = objSpy.MajorVersion + 1998
docPath = objWshShell.ExpandEnvironmentStrings("%USERPROFILE%") + "\\Documents\\Altova\\XMLSpy"+ majorVersionYear + "\\Examples\\ExpReport.xml";
objDoc = objSpy.Documents.OpenFile (docPath, false);
WScript.ConnectObject(objDoc, "DocEvent_");
 
// Keep running while waiting for the event
// In the meanwhile close this document in XMLSpy (or Authentic Desktop) manually
WScript.Echo ("Sleeping for 10 seconds ...");
WScript.Sleep (10000);
 
objDoc = null;
WScript.Echo ("Stopped listening for event");
objSpy.Quit();

 

© 2017-2023 Altova GmbH