Altova XMLSpy 2025 Enterprise Edition

Authentic View supports event connection on a per-object basis. Implementation of this feature is based on COM connection points and is available in environments that support this mechanism.

 

The following example is a VBScript code example that shows how to use events from within a VBScript project.

 

' --------------------------------------------------------------------------
' VBScript example that demonstrates how to use events.
' --------------------------------------------------------------------------
 
' Event handler for OnSelectionChanged event of AuthenticView
Function AuthenticViewEvent_OnSelectionChanged(objAuthenticRange)
  If objAuthenticRange.FirstTextPosition <> objAuthenticRange.LastTextPosition Then
      Call WScript.Echo("Selection: " & objAuthenticRange.Text & vbNewLine & vbNewLine & "Close this dialog.")
  Else
      Call WScript.Echo("Cursor position: " & objAuthenticRange.FirstTextPosition & vbNewLine & vbNewLine & "Close this dialog.")
  End If
End Function
 
' Start/access XMLSpy and connect to its automation interface.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objSpy = GetObject("", "XMLSpy.Application")
' Make the UI of XMLSpy visible.
objSpy.Visible = True
 
' Find out user's personal folder and locate one of the installed XMLSpy examples.
personalFolder = WshShell.ExpandEnvironmentStrings("%UserProfile%")
majorVersionYear = objSpy.MajorVersion + 1998
xmlspyExamplesFolder = personalFolder & "\Documents\Altova\XMLSpy" & majorVersionYear  & "\Examples\"
docPath = xmlspyExamplesFolder & "ExpReport.xml"
 
' Create object to access windows file system and test if the our document exists.
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(docPath) Then
   ' open the document
  Call objSpy.Documents.OpenFile(docPath, False)
  set objDoc = objSpy.ActiveDocument
 
   ' switch active document to authentic view
   objDoc.SwitchViewMode 4 ' spyViewAuthentic
   
   ' Register for connection point events on the authentic view of the active document.
   ' Any function with a valid event name prefixed with "AuthenticViewEvent_" will
   ' be called when the corresponding event gets triggered on the specified object.
  set objView = objDoc.AuthenticView
  Call WScript.ConnectObject(objView, "AuthenticViewEvent_")
  Call WScript.Echo("Events are connected." & vbNewLine & vbNewLine & "Now set or move the cursor in XMLSpy." & vbNewLine & vbNewLine & "Close this dialog to shut down XMLSpy.")
 
   ' To disconnect from the events delete the reference to the object.
  set objView = Nothing
Else
  Call WScript.Echo("The file " & docPath & " does not exist.")
End If
 
' shut down XMLSpy when this script ends
objSpy.Visible = False

 

© 2018-2024 Altova GmbH