Altova XMLSpy 2025 Enterprise Edition

The listing below shows how to listen for and use events.

 

 

01 // The following lines attach to the document events using a default implementation

02 // for the events and override one of its methods.

03 // If you want to override all document events it is better to derive your listener class

04 // from DocumentEvents and implement all methods of this interface.

05

06 Document doc = xmlSpy.getActiveDocument();

07 doc.addListener(new DocumentEventsDefaultHandler()

08     {

09       @Override

10       public boolean

11       onBeforeCloseDocument(Document i_ipDoc) throws AutomationException

12       {

13         System.out.println("Document " + i_ipDoc.getName() + " requested closing.");

14

15         // Allow closing of document

16         return true;

17       }

18     });

19 doc.close(true);

20 doc = null;

 

© 2018-2024 Altova GmbH