Reference - Functions

Here you find a list of all functions you can use in an expression.

nodeSet attributes()

Returns all attributes of the current node in the model.

nodeSet childElements()

Returns all child elements of the current node in the model.

string className()

Returns the class name for the current element in the model, which must have a name attribute. The value of the name attribute is transformed into a class name according to Java naming conventions.

E.g. if you have the following model:

...
<class name="ACL entry">
    ...

and the <class> element is the current node in the model when a template is expanded, a call to className() in an expression would return the string 'AclEntry'.

string className(string name)

Transforms the given name into a class name according to Java naming conventions.

E.g. className('ACL Entry') would return 'AclEntry'.

string constName()

Returns the const name for the current element in the model, which must have a name attribute. The value of the name attribute is transformed into a const name according to Java naming conventions.

E.g. if you have the following model:

...
<attribute name="first name">
    ...

and the <attribute> element is the current node in the model when a template is expanded, a call to constName() in an expression would return the string 'FIRST_NAME'.

string constName(string name)

Transforms the given name into a const name according to Java naming conventions.

E.g. constName('first name') would return 'FIRST_NAME'.

integer count(nodeSet aNodeSet)

Returns the number of nodes in the given node set. This method is extremly useful if you want to know, if an optional element/attribute in your model is present.

E.g. in a template you could write:

renderInputField(..., <if test="count(editable) == 0">true</if><else>false</else>

Or you can check if there are elements with certain properties in your model:

<if test="count(attribute[type == 'date']) > 0"> ...

string dirName(string packageName)

Returns the directoy name for the given Java package name.

E.g. dirName('com.aperto.xyz') returns 'com/aperto/xyz'

string firstLetterUpperCase1(string someString)

Makes the first letter of the given string upper case.

string getterName()

Returns the getter method name for the current element in the model, which must have a name attribute. The value of the name attribute is transformed into a getter method name according to Java naming conventions.

E.g. if you have the following model:

...
<attribute name="first name">
    ...

and the <attribute> element is the current node in the model when a template is expanded, a call to getterName() in an expression would return the string 'getFirstName'.

string getterName(string name)

Transforms the given name into a getter method name according to Java naming conventions.

E.g. getterName('first name') would return 'getFirstName'.

string javaFileName()

Returns the java file name (with package as path component) for the current element in the model, which must have a name attribute as well as a <package> element as an ancestor (which must also have a name attribute).

E.g. if you have the following model:

...
<package name="com.aperto.foo.security">
    <class name="ACL entry">
        ...

and the <class> element is the current node in the model when a template is expanded, a call to javaFileName() in an expression would return the string 'com/aperto/foo/security/AclEntry.java'.

You typically use this function in the file attribute of a <template> tag, e.g.:

<template match="*.class" file="src/${javaFileName()}">

string jspFileName()

Returns the jsp file name (without the suffix '.jsp') for the current element in the model, which must have a name attribute. All charaters are transformed to lowercase and whitespaces are replaced by the '_' character.

E.g. if you have the following model:

...
<form name="Edit user">
   ...

and the <form> element is the current node in the model when a template is expanded, a call to jspFileName() in an expression would return the string 'edit_user'.

You typically use this function in the file attribute of a <template> tag, e.g.:

<template match="*.form" file="wwwroot/${jspFileName()}.jsp">

string jspFileName(string name)

Transforms the given name into a jsp file name (without the suffix '.jsp'). All charaters are transformed to lowercase and whitespaces are replaced by the '_' character.

E.g. jspFileName('edit user') would return 'edit_user'.

integer length(string someString)

Returns the length in characters of the given string.

string lowerCase(string someString)

Returns the given string in lower case.

string name()

Returns the name of current node (a XML element or attribute) in the model.

node parentElement()

Returns the parent element of the current node in the model.

string setterName()

Returns the setter method name for the current element in the model, which must have a name attribute. The value of the name attribute is transformed into a setter method name according to Java naming conventions.

E.g. if you have the following model:

...
<attribute name="first name">
    ...

and the <attribute> element is the current node in the model when a template is expanded, a call to setterName() in an expression would return the string 'setFirstName'.

string setterName(string name)

Transforms the given name into a setter method name according to Java naming conventions.

E.g. setterName('first name') would return 'setFirstName'.

string text()

Returns the current node in the model as a string. If the current node is a XML element, the textual body of the element is returned, if the current node is a XML attribute, the value of the attribute is returned.

string trim(string someString)

Removes leading and trailing whitespaces from the given string.

string upperCase(string someString)

Returns the given string in upper case.

string varName()

Returns the variable name for the current element in the model, which must have a name attribute. The value of the name attribute is transformed into a variable name according to Java naming conventions.

E.g. if you have the following model:

...
<attribute name="first name">
    ...

and the <attribute> element is the current node in the model when a template is expanded, a call to varName() in an expression would return the string 'firstName'.

string varName(string name)

Transforms the given name into a variable name according to Java naming conventions.

E.g. varName('first name') would return 'firstName'.