Custom XML Validation Engines

Stylus Studio supports several XML validation engines, including the MSXML4.0 SAX Parser, Xerses-J 2.3.0, and .NET XML. The custom validation engine feature lets you register your own XML validation engine with Stylus Studio. Custom validation engines are added to the Validate Document drop-down list in the XML Editor once you register them with Stylus Studio, as shown in Figure 321.

Figure 321. Validate Document Drop-Down List

Output for custom validation engines is displayed in Stylus Studio's Output Window. Output for other custom applications, such as that created by the custom document wizard, is also displayed in Stylus Studio's Output Window.

Figure 322. Output Window

Registering a Custom Validation Engine

The process of registering a custom validation involves the following steps:

1. Make the necessary custom validation engine available to Stylus Studio.
2. Configure the custom validation engine on the Custom Validation Engines page of the Options dialog box. This step involves
a. Providing a name.
b. Specifying a command line template.
c. Defining any arguments required by the command line.
d. Optionally specifying the initial directory, path, and classpath to be used by the custom validation engine.
e. Optionally setting a feature that prompts the custom validation engine user for arguments when the custom validation engine is run.

More information for each of these steps is provided in the following section, Configuring a Custom Document Wizard.

Configuring a Custom Validation Engine

This section provides information and procedures for configuring a custom validation engine. It covers the following topics:

The Custom Validation Engines Page

You use the Custom Validation Engines page of the Options dialog box to work with custom validation engines in Stylus Studio.

Figure 323. Custom Validation Engines Page

How to display
To display the Custom Validation Engines page:
1. In the Stylus Studio menu bar, select Tools > Options.

The Options dialog box appears.

2. If necessary, expand Application Settings and click Custom Validation Engines.

The Custom Validation Engines page appears.

About macros

Stylus Studio provides macros for some fields to help speed creation of custom validation engines. Any macro you use to configure the custom validation engine is resolved when it is run.

Available macros vary based on the field for which they are being used. To display macros available for a given field, click . Predefined macros include

  • ${FilePath} - The complete path of the XML file to be validated.
  • ${FileDir} - The directory in which the XML file to be validated is stored.
  • ${FileName}- The name of the XML file to be validated.
  • ${FileExt} - The extension of the XML file to be validated.
  • ${ClassPath} - The Classpath environment variable.
  • ${StylusDir} - The path of the Stylus Studio installation directory.
Name

When you click the New button ( )to create a new custom validation engine, Stylus Studio displays an entry field for the name.

Figure 324. Specifying a Custom Validation Engine Name

You should replace the default name ( Validation Engine 1, for example) with the name you want to associate with the custom validation engine. The name you enter is displayed in the drop-down in the XML Editor.

Custom validation engines are displayed in the Validate Document drop-down list in the order in which they appear here.

You can change the custom validation engine order by
1. Selecting the custom validation engine whose order in the list you want to change.
2. Clicking the up or down arrow to the right of the custom validation engine list box as needed.
Command

You use the Command field to specify the command line used to invoke the custom validation engine. This is typically the path to the .exe, .cmd, or .bat file that starts the application.

Arguments

You use the Arguments field to specify any arguments required by the custom validation engine. Click to browse predefined macros.

Initial Directory

You use the Initial directory field to specify the directory you want Stylus Studio to use as the current directory when the custom validation engine is run. Click to browse predefined macros.

Path

You use the Path field to define paths to any files (such as .exe and .dll) required by the custom validation engine. You do not have to define any paths that are already defined in your PATH environment variable. Separate multiple paths with a semicolon. Click to browse predefined macros.

Classpath

You use the Classpath field to define paths to any JVM files required by the custom validation engine (such as .jar and .class). You do not have to define any paths that are already defined in your PATH environment variable. Click to browse predefined macros.

Prompt for arguments

The Prompt for arguments feature displays a dialog box when the custom validation engine is run.

Figure 325. Argument Prompt

The Arguments field allows the user to change the command line and arguments configured with the custom validation engine when it was registered with Stylus Studio.

How to Configure a Custom Validation Engine

Before you begin

Before performing this procedure, you should be familiar with the information in The Custom Validation Engines Page.

To configure a custom validation engine:
1. Display the Custom Validation Engines page of the Options dialog box. See How to display if you need help with this step.
2. Click the New button and enter a name for the custom validation engine. Remember that this value is displayed in the Validate Document drop-down list in the XML Editor.
3. Specify the command line any required arguments. See Command and Arguments if you need help with this step.
4. Optionally, specify an initial directory, path and classpath.
5. Click Prompt for arguments if you want Stylus Studio to display a dialog box that allows the user to change the command line or arguments when the custom validation engine is run.
6. Click OK.
 
Free Stylus Studio XML Training: