Unotal Examples
Example A Simple Configuration File
config.unotal
< user = [jane myers]
pass = [moaJi71Amx]
host = [network_pc]
home = [/home/jane]
last = [2003-09-07] >
Example A Configuration File
The following file is not a Unotal file. It is listed here as a source for the following translation to Unotal.
compiler.config
[Project]
FileName=C:\dev\Schalter.dev
Name=Schalter
Use_gpp=1
UnitCount=3
ResFiles=C:\dev\rsrc.rc
NoConsole=0
IsDll=0
Icon=C:\PROGRAMS\DEV-C++\Bin\Mainicon.ico
[Unit2]
FileName=C:\dev\Switch.h
FileTime=761047318
[Unit3]
FileName=C:\dev\Client.cpp
[Unit1]
FileName=C:\dev\Switch.cpp
The information from the file above can be written as follows using Unotal .
While the brackets are not required around the section names in Unotal in the cases below, the might used to make the Unotal representation look similar to the ini-file above.
compiler.unotal
< [Project] =
< FileName=[C:\dev\Schalter.dev]
Name=Schalter
Use_gpp=1
UnitCount=3
ResFiles=[C:\dev\rsrc.rc]
NoConsole=0
IsDll=0
Icon=[C:\PROGRAMS\DEV-C++\Bin\Mainicon.ico] >
[Unit2] =
< FileName=[C:\dev\Switch.h]
FileTime=761047318 >
[Unit3] =
< FileName=[C:\dev\Client.cpp] >
[Unit1] =
< FileName=[C:\dev\Switch.cpp] >>
Example A Database Table
persons.unotal
persons =
< 0 = < &person name = [peter] phone = [1234567] )
1 = < &person name = [mary] phone = [9876543] )
2 = < &person name = [frank] phone = [4329876] )
3 = < &person name = [alice] phone = [7463957] )
4 = < &person name = [andrew] phone = [8328839] )>
When the format is fixed and known, a shorter representation is possible.
persons1.unotal
< < mary 9876543 >
< frank 4329876 >
< alice 7463957 >
< andrew 8328839 >>
Example An XHTML Anchor
An XHTML anchor.
anchor.xhtml
<a href="http://example.com">example.com</a>
This can be written as in listing "anchor.unotal".
anchor.unotal
< &a href=[http://example.com] [example.com] >
A more free interpretation might look as follows.
anchor1.unotal
< &anchor target=[http://example.com] text=[example.com] >
Example XML -Attributes and XML -Subelements
The distinction between XML -attributes and XML -subelements can be preserved, when an XML -element is converted to Unotal.
element1.xhtml
<alpha beta="gamma"><beta>gamma</beta></alpha>
element1.unotal
< &alpha beta=gamma < &beta gamma >>
element2.xhtml
<alpha beta="gamma"><beta>gamma</beta><beta>gamma</beta></alpha>
element2.unotal
< &alpha beta=gamma < &beta gamma >< &beta gamma >>
A Unotal -entry converted from an XML -element can be converted back to an XML -element again.
Example An XHTML Element
A simple XHTML element.
element.xhtml
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Virtual Library</title></head>
<body><p>Moved to <a href="http://example.org/">example.org</a>.</p></body>
</html>
This is converted to Unotal as follows.
element.unotal
< &html xmlns=[http://www.w3.org/1999/xhtml] xml:lang=en lang=en
head =< title=[Virtual Library] >
body =< &p [Moved to ] <&a href=[http://example.org] [example.org] > [.] >>
One can see that several types of parentheses (braces, brackets, angle brackets) are used in the Unotal representation. This is so, because Unotal has finer semantics than XML, so that two XML structure types (elements and attributes) are mapped to more Unotal structure types.
In Unotal, attributes might be structured like element contents in XML. This allows to write the head and body properties of the XHTML -element as attributes. In XHTML one is forced to write them as subelements, because they need to be structured.
The above Unotal space can not be converted to an XML directly, because the structured attributes can not be expressed as XHTML -elements. A special XML -writer is in internal use, which will accepts the following syntax and converts properties written with a tilde to XHTML -subelements.
- An XHTML -document written in Unotal-X
< &xml .xmldecl = [version = "1.0" encoding="UTF-8"] .doctype = [html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"] html - < xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" head - < title - [Virtual Library] > body - < &p [Moved to ]
< &a href=[http://vlib.org/] [vlib.org] > [.] >>
(The Wreboc -specification is using this notation to create a draft document.)
Example A Program
The following is an arbitrary example for a Unotal-based programming language. A programming language based on Unotal, however, might also look completely different than the following example.
element.unotal
< &program
name = listintegers
description = [this program prints the integers from 0 to 9]
< &var i integer >
< &loop start=< &set i 0 > while=< &isless i 10 > < &print i >>>
This Unotal program might look as follows when written in Pascal.
element.pas
PROGRAM
listintegers( Input, Output );
{ this program prints the integers from 0 to 9 }
VAR i: Integer; BEGIN
i := 0 ; WHILE
i < 10 DO
WriteLn( i ); END.
Example A LISP-List
list.lisp
( alpha beta gamma )
The application of the first entry "alpha" to the rest, it is written in Unotal as in "list1.unotal".
list1.unotal
< &alpha beta gamma >
Example A quoted LISP-List
list.lisp
'( alpha beta gamma )
If the list is meant to be a (quoted) sequence, it is written as in "list2.unotal".
list2.unotal
< alpha beta gamma >
Example An Expression
expression
sin( 4 + 2 x )
This might be written in Unotal as follows.
expression.unotal
< &sin < &plus 4 < × 2 x >>>
Infix-notation is possible as well, as long as one also keeps the angle brackets. Because in Unotal the type of a room is marked by an ampersand "&", it can be positioned freely within the room.
expression1.unotal
< &sin < 4 &plus < 2 × x >>>
Postfix-notation:
expression2.unotal
< < 4 < 2 x × > &plus> &sin >
The room "expression.unotal", the room "expression1.unotal", and the room "expression2.unotal" have the same meaning in Unotal, because the position of the type has no significance.
Example RSS 3.0
document in RSS 3.0
title: Spec Introduced
created: 2002-09-06
guid: 00795648-C1E0-11D6-9AA6-003065F376B6
description:
The spec was introduced to the world.
A few people noticed.document in Unotal
< &rss3d0
title=[Spec Introduced]
created=[2002-09-06]
guid=[00795648-C1E0-11D6-9AA6-003065F376B6]
description=< &a:text
< &a:paragraph [The spec was introduced to the world.]>
< &a:paragraph [A few people noticed.]>>>
Example SDL
The term “SDL” here refers to the “Simple Data Language” of the project “HiveMind”.
Here, some information is given in XML, SDL and Unotal.
The following schema written in XML was taken from the URI "http://jakarta.apache.org/hivemind/sdl.html" as of 2004-05-21.
- A Schema in XML
<schema> <element name="processor"> <attribute name="name" required="true"/> <attribute name="service-id" required="true" translator="service"/> <attribute name="before"/> <attribute name="after"/> <conversion class="some.module.PipelineContribution"> <map property="controlService" attribute="service-id"/> </conversion> </element> </schema>
The following translation to SDL was taken from the URI "http://jakarta.apache.org/hivemind/sdl.html" as of 2004-05-21.
- A Schema in SDL
schema { element (name=processor) { attribute (name=name required=true) attribute (name=service-id required=true) attribute (name=before) attribute (name=after) conversion (class=some.module.PipelineContribution) { map (property=controlService attribute=service-id translator=service) } } }
The following text is the translation of the above XML document to Unotal. Notice how the structured attribute values of Unotal allow to write "attribute (name=after)" as "after = < &attribute >".
- A Schema in Unotal
< &schema processor = < &element name = < &attribute required=true >
service-id = < &attribute required=true translator=service >
before = < &attribute >
after = < &attribute > < &conversion class=some.module.PipelineContribution
< &map property=controlService attribute=service-id >>>>
Example HUTN
The following example of HUTN was taken from the Human-UsableTextual Notation (HUTN) Specification (December 2002 Final Adopted Specification ptc/02-12-01).
- A family description in HUTN
Family “The McDonalds” { address: “7 Main Street” migrants familyFriends: “The Smiths” petFish: female Fish “Wanda”; petDog: “Spike” CarOwnership: “755-BDL” { state: QLD make: “Mitsubishi Magna” year: 1992 } }
The translation to Unotal is done somewhat freely, doing things as they might be done in Unotal.
- A family definition in Unotal
< [The McDonalds] = < &family &definition address = [7 Main Street] migrants = true friend = < &family &reference [The Smiths] > pet =
{ < &fish &description name=Wanda sex=female >
< &dog &description name=Spike >} car = < &car &description 755-BDL state=QLD make=[Mitsubishi Magna] year=1992 >>>
Example PHP Arrays-Reports
PHP prints arrays using the function "print_r" in a way somewhat similar to Unotal, because it looks like using structured attributes. In the special example below the array even does have a “body attribute” (as used by some Unotal -implementations to store the body of a room). It also uses the brackets for some strings similar to Unotal.
- An array report by PHP
Array ( [code] => 200 [headers] => Array ( [Connection] => close [Content-Length] => 51 ) [body] => Invalid Document Format )
- An array report in Unotal
< code = 200 headers = < Connection = close Content-Length = 51 > body = [Invalid Document Format] >