tommy online
home euphoria smel bookmarks sitemap info tommy.blog

smel

tutorial

Table of contents

purpose - element - value - comment - directive - document

purpose

The purpose of SMEL is providing a method of structuring data and documents. A SMEL-document consists of elements, values, comments and directives.

Element
An element is a construction that is used to create a hierarchical structure. It usually has a label, it might have some attributes, and it can have children. These children can again be elements, values, comments or directives.
Value
A value is a piece of data that stands alone. It doesn't have any attributes or children. It can be numeric, text or even a sequence.
Comment
A comment is a piece of text that doesn't contain any data, but that is used by the author to comment some of the SMEL-code. It has no effect on the data or document and should be discarded.
Directive
A directive is a construction that doesn't contain any data, but that is used to pass extra information to certain applications that read the data.

element

Examples of elements:

element;
element (attr1="value", attr2="value");
element (attr="value") { "child 1", "child 2", "child 3" }

The first example is an element that has a label (element), but no attributes or children. The second example has a label (element), 2 attributes (attr1 and attr2) and no children. The third example has a label (element), an attribute (attr) and 3 children. These children are all text-values.

Attributes are properties of an element. An element person can have the attributes first_name, last_name and gender. Attributes have a label and a value. An element can't have 2 attributes with the same label. Attributes can be separated by a comma, but that comma is optional.

Children of an element can be: other elements, values, comments or directives. Children of an element can be separated by a comma, but that comma is optional. An example of a table-element with row-elements as children, and text-value as children of those rows:

table(rows=3 columns=3)
{
  row { "A1", "B1", "C1" }
  row { "A2", "B2", "C2" }
  row { "A3", "B3", "C3" }
}

value

Examples of values:

#E8
3.5px
"Some text"
'More text'
[[1

comment

Examples of comments:

/* comments are in C/C++/C#-style */
/* they can span
multiple lines */

directives

Examples of directives:

<smel version="1.1">
<smel:meta author="Tommy Carlier" copyright="Copyright © 2003 Tommy Carlier">

The first example tells every SMEL-application that the document uses version 1.1 of the SMEL-specification. The second example tells every application that the author of the document is Tommy Carlier and what the copyright-string is.

Directives contain no data, but metadata: data about the data. Directives that begin with smel are part of the SMEL-specification and can not be used for other applications. There are special SMEL-directives.

document

A SMEL-document is a unicode-file that has a SMEL-declaration, and a root-element. Before and after the root-element, you can also place comments and directives.

Example of a SMEL-document:

<smel version="1.1" app="DataSmel/1.0"> /* SMEL-declaration: version 1.0
<smel:meta author="Tommy Carlier" description="Address Book">

table(id="data:Persons")
{
  fields(pk=!nr) /* the primary key is nr (number*/")>
  {
    field(id=!nr type="number", unique="true");
    field(id=!first_name type="text" maxlength=100);
    field(id=!last_name type="text" maxlength=100);
    field(id=!mail type="text" maxlength=200);
  }

  data
  {
    row {0, "Tommy", "Carlier", "tommy.carlier@pandora.be"}
    row {1, "John", "Doe", "john@doe.com"}
    row {2, "Bill", "Gates", "bill.gates@microsoft.com"}
  }
}

This is the printed version of a page from tommy online: http://users.telenet.be/tommycarlier
Copyright © 2003 - 2005 Tommy Carlier ()
smel: intro tutorial smel 1.1 <smel:...>
Opera WebBrowser