Altova XMLSpy 2025 Enterprise Edition

SPL allows you to use standard "if" statements. The syntax is as follows:

 

if condition

 statements

else

 statements

endif

 

or, without else:

 

if condition

 statements

endif

 

Note:There are no round brackets enclosing the condition.

 

As in any other programming language, conditions are constructed with logical and comparison operators.

 

Example:

 

[if $namespace.ContainsPublicClasses and $namespace.Prefix <> ""]

 whatever you want ['inserts whatever you want, in the resulting file]

[endif]

 

Switch

SPL also contains a multiple choice statement.

 

Syntax:

switch $variable

 case X:

         statements

 case Y:

 case Z:

         statements

 default:

         statements

endswitch

 

The case labels must be constants or variables.

 

The switch statement in SPL does not fall through the cases (as in C), so there is no need for a "break" statement.

© 2018-2024 Altova GmbH