Altova XMLSpy 2025 Enterprise Edition

The XMLSpy installation package contains an example Java project, located in the ActiveX Examples folder of the application folder: <ApplicationFolder>\Examples\ActiveX\Java\.

 

The Java example shows how to integrate the XMLSpyControl in a common desktop application created with Java. You can test it directly from the command line using the batch file BuildAndRun.bat, or you can compile and run the example project from within Eclipse. See below for instructions on how to use these procedures.

 

File list

The Java examples folder contains all the files required to run the example project. These files are listed below:

 

.classpath

Eclipse project helper file

.project

Eclipse project file

AltovaAutomation.dll

Java-COM bridge: DLL part (for the 32-bit installation)

AltovaAutomation_x64.dll

Java-COM bridge: DLL part (for the 64-bit installation)

AltovaAutomation.jar

Java-COM bridge: Java library part

BuildAndRun.bat

Batch file to compile and run example code from the command line prompt. Expects folder where Java Virtual Machine resides as parameter.

XMLSpyActiveX.jar

Java classes of the XMLSpy ActiveX control

XMLSpyActiveX_JavaDoc.zip

Javadoc file containing help documentation for the Java API

XMLSpyContainer.java

Java example source code

XMLSpyContainerEventHandler.java

Java example source code

XMLTreeDialog.java

Java example source code

 

What the example does

The example places one XMLSpy document editor window, the XMLSpy project window, the XMLSpy XPath window and an XMLSpy entry helper in an AWT frame window. It reads out the File menu defined for XMLSpy and creates an AWT menu with the same structure. You can use this menu or the project window to open and work with files in the document editor.

 

You can modify the example in any way you like.

 

The following specific features are described in code listings:

 

Creating the ActiveX Controls: Starts XMLSpy, which is registered as an automation server, or activates XMLSpy if it is already running.

Loading Data in the Controls: Locates one of the example documents installed with XMLSpy and opens it.

Basic Event Handling: Changes the view of all open documents to Text View. The code also shows how to iterate through open documents.

Menus: Validates the active document and shows the result in a message box. The code shows how to use output parameters.

UI Update Event Handling: Shows how to handle XMLSpy events.

Creating an XML Tree: Shows how to create an XML tree and prepare it for modal activation.

 

Updating the path to the Examples folder

Before running the provided sample, you may need to edit the XMLSpyContainer.java file. Namely, check that the following path refers to the actual folder where the XMLSpy example files are stored on your operating system:

 

// Locate samples installed with the product.
final String strExamplesFolder = System.getenv( "USERPROFILE" ) + "\\Documents\\Altova\\XMLSpy2025\\XMLSpyExamples\\";

 

 

Running the example from the command line

To run the example from the command line:

 

1.Check that all prerequisites are met (see Prerequisites).

2.Open a command prompt window, change the current directory to the sample Java project folder, and type:

buildAndRun.bat "<Path-to-the-Java-bin-folder>"

3.Press Enter.

 

The Java source in XMLSpyContainer.java will be compiled and then executed.

 

Compiling and running the example in Eclipse

To import the sample Java project into Eclipse:

 

1.Check that all prerequisites are met (see Prerequisites).

2.On the File menu, click Import.

3.Select Existing Projects into Workspace, and browse for the Eclipse project file located at <ApplicationFolder>\Examples\ActiveX\Java\. Since you may not have write-access in this folder, it is recommended to select the Copy projects into workspace check box on the Import dialog box.

 

To run the example application, right-click the project in Package Explorer and select the command Run as | Java Application.

 

Help for Java API classes is available through comments in code as well as the Javadoc view of Eclipse. To enable the Javadoc view in Eclipse, select the menu command Window | Show View | JavaDoc.

© 2018-2024 Altova GmbH