Altova MobileTogether Designer

An SPL template is constructed in the programming language of the program code you wish to generate. The template contains snippets of SPL instructions to integrate MobileTogether data into the generated program code. SPL instructions are enclosed in square brackets. Here, for example, is a template to generate an XML file (written in XML), with the SPL instructions highlighted in yellow.

 

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="[=$Options.androidPackageName]"

android:versionCode="[=$Options.appVersion]"

android:versionName="[=$Options.appVersion]">

<uses-sdk

android:minSdkVersion="15"

android:targetSdkVersion="22"/>

</manifest>

 

Multiple statements

Multiple statements can be included in a bracket pair. Additional statements have to be separated from the previous statement by a new line or a colon. Valid examples are:

 

[$x = 42

$x = $x + 1]

[$x = 42: $x = $x + 1]

 

Text

Text not enclosed by square brackets is written directly to the output. To generate square brackets, escape them with a backslash: \[ and \]. To generate a backslash, use \\.

 

Comments

Comments inside an instruction block always begin with a ' character, and terminate on the next line, or with a closing square bracket.

 

Variables

Variables are created by assigning values to them. The $ character is used when declaring or using a variable. Variable names are case-sensitive. Variables can be of the following types:

 

Integer: Also used as boolean, where 0 is false and everything else is true

String. See also String Mechanisms.

Object: Provided by MobileTogether. For example, the $Options object.

 

Variable types are declared by first assignment:

 

[$x = 0] means that x is now an integer.

[$x = "teststring"] means that x is now a string.

 

Strings

Strings are enclosed in double quotes. \ and \t inside double quotes are interpreted as newline and tab, \" is a literal double quote, and \\ is a backslash. String constants can also span multiple lines. String concatenation uses the & character:

 

[$BasePath = $outputpath & "/" & $JavaPackageDir]

 

Objects

Objects are MobileTogether structures. Objects have properties, which can be accessed by using the . operator. It is not possible to create new objects in SPL, but it is possible to assign objects to variables. For example:

 

class [=$class.Name]

 

This example outputs the word class, followed by a space and the value of the Name property of the $class object.

 

Conditions

Use IF statements, with or without the ELSE clause, as follows. Do not use round brackets around the condition.

 

if condition

      statements

else

      statements

endif

 

 

Example

 

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

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

[endif]

 

Iterators

Use FOREACH statements to iterate, as follows:

 

foreach object in collection

          statements

next

 

 

Example

 

[foreach $class in $classes

 if not $class.IsInternal

]        class [=$class.Name];

[        endif

next]

 

© 2018-2024 Altova GmbH