How to ... Create scripting templates

SQL Visualizer allows you to create scripts based on XSLT templates. This means that you can create scripts the way you want them to appear or create new ones to perform tasks specific to your needs. SQL Visualizer comes with a default set of XSLT templates that you to use to understand the principals or extend.

While creating XSLT templates is beyond the scope of this topic the following details illustrate how to create a simple template and add it to the list of available scripting menu commands.

An XML schema of the available objects and properties output when a script is created can be found in the Templates sub-directory of the SQL Visualizer application (this will be the directory you chose during the initial installation. By default this is C:\Program Files\Killer Bite Software\SQL Visualizer).

Suppose you want to create a script to execute a stored procedure. In order to do this you would need to create a template to declare a variable for each parameter in the stored procedure, allow the value of each variable to be set, then execute the procedure and pick up the return value. This template is placed in a file called ExecuteStoredProcedureTemplate.xslt

Now that the XSLT template has been created you need to add it to the available scripting list. In the Templates sub-directory there is an XML file called Templates.xml that dictates what scripting output is available for each type of object. Open this file and add an entry for the XSLT file.

You can specify a path to a 16x16 pixel GIF image to help identify the command in the list.

N.B. The Type value should always be "SQL".

The new scripting command will be immediately available in the scripting list.

The variable values can now be set and the script executed.