About Grammar License
 
Commercial & freeware products Try our software for free before purchase Buy now Company news channel Company informations
  Home Products TemlCode Structures  

19.08.2011
SnapDraw is FREE

15.07.2011
101+ Analog Clocks for Android

29.03.2011
101+ Vector Clocks Available

24.02.2011
Announcing Vector Clock Pro

01.01.2011
New beautiful set of Free Vector Clocks

 

TemlCode Structure

Structure is the most basic element for content structuring of any depth and complexity. It is designed to form higher level entities like tables, collumns, databases, groups, trees and so on. The scope of validity of a Structure is either inside of another master Structure or inside a single Section. Section scope is terminal, which means a Structure cannot span over the Section boundaries.

Syntax of Structure Start Tag
~[ ( Id & [Label] | Var ) + [Properties] ]
Label
"@" & ( Name | StringFF )
& [ "." & ( Name | StringFF ) ]*
& [ ":" & ( Name | StringFF ) ]
Var
"#" & Id
Properties
< Parameter [ ";" Parameter ";" ... ";" Parameter [";"] ]>

Structure is the only Markup Tag of TemlCode, which must have it's counterpart closing (exit) element. If an appropriate Structure Exit Tag is missing, data stream is considered to be ill-formed.

Id

Id of Structure Start Tag denotes some class - a general group of use, to which the whole structure relates.

This part of Tag syntax is mandatory.

Label

Label names particular Structure Start Tag in namespace of given Id class. If there are more occurences of the same Id@Label Structure Start Tags, processing application should not accept such occurences, because this ambiguity makes exact referencing impossible.

This part of Tag syntax is optional.

Var

The use of Variable instead of Id@Label pair provides a polymorphic functionality for the underlying structures. Imagine having structure defined as a table with data organized in rows and collumns. Then changing this Structure Variable Start Tag to a different value results in turning table into something else, eg. tabbed notepad. Also note, Structure with Variable Start Tag can only be closed with Short form of Structure Exit Tag (no name referencing).

If choosed, this part of Tag syntax is mandatory.

Properties

Properties allows for additional attribution of aspects related to a particular block of data, which the appropriate structure embraces.

Properties syntax is exactly the same, as described in previous chapter about TemlCode Properties. There is only one little syntactical difference - no prepending "~" Tilde character is used to define properties enclosed in "< ... >".

This part of Tag syntax is optional.
 
 
TemlCode Example of Structure
~[table@"Exchange Rates" <width:px=600;border=*>]
  ~{collumn <width="10%";align=left>}
  ~{collumn <width="60%";align=left>}
  ~{collumn <width="15%";align=right>}
  ~{collumn <width="15%";align=right>}

  ~{row}~<b>Code~>
      ~}~<b>Currency~>
      ~}~<b>Buy~>
      ~}~<b>Sell~>

  ~{row}AUD ~}Australian Dollars ~}1.0221 ~}1.0448
  
~{row}GBP ~}British Pounds     ~}0.4906 ~}0.5015
  
~{row}EUR ~}European Euros     ~}0.6213 ~}0.6351
  
~{row}JPY ~}Japanese Yen       ~}105.16 ~}107.50
  
~{row}CHF ~}Swiss Francs       ~}1.0109 ~}1.0334

~[~table]

 
Structure Exit

Structure Exit Markup Tags can be either in Short form or in Named form. If there aren't a corresponding Structure Exit Tags to their Start Tag counterparts, the TemlCode data stream is considered to be ill-formed.

Short Form

Syntax of Short form of Structure Exit Tag
~]

This short form closes nearby Structure found by tracing back for the first unclosed Structure in the scope of it's master structure or enclosing Section.

This short form is also the only way, how to close a Structure Variable Start Tag, which itself cannot be labeled.
 
 
TemlCode Example of Structure with Variable Start Tag and Short form of Exit Tag
~{&rendering = (tablelistingpicker)}
~{
#colors : &rendering = table }

~[
#colors <description="HTML 16 color names">]
  ~{entry}Aqua    ~}~(&rgb(0x00FFFF))
  ~{entry}Green   ~}~(&rgb(0x008000))
  ~{entry}Navy    ~}~(&rgb(0x000080))
  ~{entry}Silver  ~}~(&rgb(0xC0C0C0))
  ~{entry}Black   ~}~(&rgb(0x000000))
  ~{entry}Grey    ~}~(&rgb(0x808080))
  ~{entry}Olive   ~}~(&rgb(0x808000))
  ~{entry}Teal    ~}~(&rgb(0x008080))
  ~{entry}Blue    ~}~(&rgb(0x0000FF))
  ~{entry}Lime    ~}~(&rgb(0x00FF00))
  ~{entry}Purple  ~}~(&rgb(0x800080))
  ~{entry}White   ~}~(&rgb(0xFFFFFF))
  ~{entry}Fuchsia ~}~(&rgb(0xFF00FF))
  ~{entry}Maroon  ~}~(&rgb(0x800000))
  ~{entry}Red     ~}~(&rgb(0xFF0000))
  ~{entry}Yellow  ~}~(&rgb(0xFFFF00))
~]

 
Example shows polymorphic definition of a higher level structure - an unordered list of colors. This structure could be rendered as table, listing, color picker or anything, the #color variable value indicates. Example also uses Metadata Markup Tags ~{...} & ~} for internal subdivision of structure logic, and Insertables Markup Tags ~(..) for tagging data with direct type of use. This is a common practice in TemlCode. Metadata and Insertables are discussed in consequent chapters.

Named Form

Syntax of Named form of Structure Exit Tag
~[~Id & [Label] ]

This named form closes nearby Structure found by tracing back for the first unclosed Structure, which matches the Id@Label definition. Label is optional and when not present, backtracked for closure is first Structure Start Tag of matching Id class.

All nested structures must be closed in proper logical nesting order. Trying to close structure with named form of Exit Structure Tag over a logical boundary of it's master scope of validity is considered as an error. That's the reason, why named form of Exit Tag for structures is just an informational tool, which can make a complex nesting more human readable, but is not required.
 
 
TemlCode Example of nested Structure with labeled Start Tag and Named forms of Exit Tags
~[recipe@bread <prep_time:min=5cook_time:hr=3>]
  ~{title}Basic bread
  
~[ingredients]
    ~{&units  = (dL;grams;teaspoon)}
    ~{&states = (cold;warm)}
    ~{&record = (amount:double; unit:&units;
                 
name:CharString; state:&states
=cold)}
    ~{entry}8  ~}dL       ~}Flour
    
~{entry}10 ~}grams    ~}Yeast
    
~{entry}4  ~}dL       ~}Water ~}warm
    
~{entry}1  ~}teaspoon ~}Salt
  
~[~ingredients]
  ~[instructions]
    ~{step}Mix all ingredients together.
    
~{step}Knead thoroughly.
    
~{step}Cover with a cloth, and leave for
           one hour in warm room.
    
~{step}Knead again.
    
~{step}Place in a bread baking tin.
    
~{step}Cover with a cloth, and leave for
           one hour in warm room.
    
~{step}Bake in the oven at 180(degrees)C
           for 30 minutes.
  
~[~instructions]
~[~
recipe
@bread]

Here is the same recipe example using XML markup syntax

 <recipe name="bread" prep_time="5 mins" cook_time="3 hours">
   <title>Basic bread</title>
   <ingredient amount="8" unit="dL">Flour</ingredient>
   <ingredient amount="10" unit="grams">Yeast</ingredient>
   <ingredient amount="4" unit="dL" state="warm">Water</ingredient>
   <ingredient amount="1" unit="teaspoon">Salt</ingredient>
   <instructions>
     <step>Mix all ingredients together.</step>
     <step>Knead thoroughly.</step>
     <step>Cover with a cloth, and leave for one hour in warm room.</step>
     <step>Knead again.</step>
     <step>Place in a bread baking tin.</step>
     <step>Cover with a cloth, and leave for one hour in warm room.</step>
     <step>Bake in the oven at 180(degrees)C for 30 minutes.</step>
   </instructions>
 </recipe>

As can be seen here, TemlCode syntax notation allows for data type definitions in place. These types are recognized by parser. In XML version, parser provides attribute values as a strings, which must be additionally converted to appropriate data types by user.
 


Tell Us What You Think

Your Name
Your Email
Your Message
We accept anonymous messages. However, if you wish to receive a response, please include your email and name.

Next Chapter

TemlCode Metadata

  Generated from TemlCode based document. Graphics on this page is rendered with CrossGL SDK. Last page update: 19.8.2011