SPL Reference
This section gives you an overview of SPL (Spy Programming Language), code generator's template language. It is assumed that you have prior programming experience, and are familiar with operators, functions, variables and classes, as well as the basics of object-oriented programming - which is used heavily in SPL. You should also have detailed knowledge of XML Schema.
The templates used by XMLSpy are supplied in the applications's spl folder. You can use these files as a guide to developing your own templates.
How code generator works
Code is generated on the basis of the template files (.spl files) and the object model provided by XMLSpy. The template files contain the code of the target programming language combined with SPL instructions for creating files, reading information from the object model, and performing calculations.
The template file is interpreted by the code generator and outputs the source-code files of the target language/s (that is, the non-compiled code files) and any other relevant project file or template-dependent file. The source code can then be compiled into an executable file that accesses the XML data described by the schema file.
SPL files have access to a wide variety of information that is collated from the source schemas. Note that an SPL file is not tied to a specific schema, but allows access to all schemas. So, make sure you write your SPL files generically and avoid structures which apply to specific schemas.
Note about method names
When you customize code generation using the supplied SPL files, it might be necessary to reserve names to avoid collisions with other symbols. Follow the instructions below:
1.Navigate to the program installation directory, for example, C:\Program Files\Altova\XMLSpy2025.
2.In the spl subdirectory, locate the directory corresponding to the programming language, for example, ..\spl\java.
3.Open the settings.spl file and insert a new line into the reserve section, for example, reserve "myReservedWord".
4.Regenerate the program code.
Example: Creating a new file in SPL
This is a very basic SPL file. It creates a file named test.cpp, and places the include statement within it. The close command completes the template.
[create "test.cpp"] #include "stdafx.h" [close] |