UIEvolutin Inc.
UJML Language Reference
Syntax Notes

UJML is an XML-based declarative language consisting of a specific set of elements and possible attribute values, melded with a simple procedural scripting language.

The UJML language consists of a set of XML elements and attributes that describe UJML content and of script elements containing UJML script. The possible XML element tags and attribute values represent the XML portion of UJML syntax. See XML Tags, UJML Tags. The UJML scripting language resembles a subset of JavaScript (also known as ECMAScript because it is a standard of Ecma International). See Scripting Language

Because it is based on XML, UJML follows standard XML conventions. The language consists of a set of XML elements and attributes that describe UJML content and script elements containing UJML script. These are specified by an XML Document Type Declaration (DTD) provided with your UJML installation.

UJML XML elements

An XML element consists of a matched pair of tags <tagname> and </tagname>. Some elements may contain other elements in a hierarchy specified by the UJML DTD. Attribute values are also specified by the DTD and may have other limitations enforced by the UJML compiler.

Element order

UJML syntax requires strict ordering of many elements (for example, <x> must appear before <y> within any visual element). Unless otherwise noted, you can assume that the order specified in this document is a required order. Any UJML document that does not correspond with the required order will be invalid and will be rejected by the compiler. The XML syntax that will be accepted by the compiler is formally defined by the UJML DTD.

White space

White space between elements is ignored. White space is only important within elements that contain literal text or numbers. Within text elements, white space is interpreted literally. Within numerical elements, white space results in a compile-time error.

Mixed content

Mixed content is the presence of text and UJML elements at the same level of the XML hierarchy. Mixed content is not allowed. Non-empty elements either contain text or they contain other elements, but they cannot contain a mixture of text and other elements. When it is necessary to include text or numbers at the same level of the hierarchy as other elements, the item must be enclosed within a <val> element.

Entities

XML allows the definition of entities which define meaningful strings for often-used constants. See XML Entities. The UJML DTD defines a number of useful entities, the names of which begins with '_'. See Entities. The user is free to define other entities in addition to the predefined ones. See Literals and Constants.

UJML element syntax definitions

The syntax of a UJML element is specified with a canonical example which indicates the elements it may contain and, if appropriate, its attributes. In some cases a child element may be repeated n times, which is indicated using an ellipsis (...). In other cases, child elements may contain n grandchild elements, also indicated using an ellipsis (...). Optional elements are indicated by surrounding them with square braces ([]). Sometimes element content is indicated using curly braces ({}) which contain a concise description of the allowed content; which may be text, a scripting expression, or a set of specific UJML elements. 

For example, the box element is specified like so:

<box>
    [<x>{integer-expr}</x>]
    [<y>{integer-expr}</y>]
    [<width>{integer-expr}</width>]
    [<height>{integer-expr}</height>]
    [<fg>{color-expr}</fg>]
    [<bg>{color-expr}</bg>]
    [<x-clip>{boolean-expr}</x-clip>]
    [<event>...</event>]
    [{visual-element}...]
</box>

 

And the var element is specified like so:

<var
    name="{string}"
    type="int | boolean | string | reference"
    [size="{integer}[,{integer}...]"]
    [access="import | export"]
    [visibility="public | private"]/>
Scripting language

Within a script element, the content must conform to the rules for UJML script. See Scripting Language for a complete scripting language syntax specification. XML elements are not allowed within a script element, although entities and XML comments may be employed.

UJML API function syntax definitions

UJML provides a comprehensive set of built-in functions you can call from your code. See Functions. Each has a return value or void (if no return value). Each has zero to n arguments, each of a specific data type. In some cases, the last argument may be repeated n times, which is indicated using an ellipsis (...). Optional arguments are indicated by surrounding them with square braces ([]). 

For example the _strcat() function is specified like so:

string _strcat(string s1, string s2, ...)

 

And the _srand() function is specified like so:

int _srand(int seed)
Syntax Notation
Syntax Element 
Description 
<name
A named XML tag. 
name="{value-type}" 
A named XML attribute. 
[ ] 
Denotes an optional item. 
... 
Denotes a repeated or omitted item. 
Denotes a choice between two or more items. 
{boolean} 
True or false literal value. See boolean, Literals and Constants
{integer} 
An integer literal value. See int, Literals and Constants
{string} 
A Unicode string literal value. See string, Literals and Constants
{variable-reference} 
A reference to a specific variable of any type. If the variable is an array, the array element must be referenced as well. 
{array-reference} 
A reference to an array variable of any type. This refers to the entire array, not to any one array element. 
{expression} 
A literal value or a scripting element that evaluates to a value of any data type. 
{boolean-expr} 
An {expression} that evaluates to {boolean}. 
{integer-expr} 
An {expression} that evaluates to {integer}. 
{reference-expr} 
An {expression} that evaluates to a reference value. See reference data type, Components
{string-expr} 
An {expression} that evaluates to {string}. 
{color-expr} 
RGB color value expressed as an integer. See UJML Colors
{size-expr} 
Font size value expressed as an integer. See Text and Fonts, Font Entities
{style-expr} 
Font style value expressed as an integer. See Text and Fonts, Font Entities
{face-expr} 
Font face value expressed as an integer. See Text and Fonts, Font Entities
{url} 
The URL of a resource. See Resources
{image-file} 
The {url} of an image file. 
{sound-file} 
The {url} of a sound file. 
{media-file} 
The {url} of a {image-file} or {sound-file} 
{UJML-file} 
The {url} of a UJML byte code file, a JSP, or some other resource that generates UJML byte code. See Byte Code Files
{key-code} 
One of: 0-9, a-z, A-Z, UP, DOWN, LEFT, RIGHT, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, F1, F2, POUND, STAR. See Key Codes
{visual-element} 
An on-screen visual element. See Visual Elements
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!