Home Page   We Generate Your Software.
Products Services Company Technology Demo Contact Site Map Search
Please note: this document is currently under revision.
The information herein contained, while still valid, does not reflect the latest state of the described technology.
The Somusar/SoProTech[tm] Booklet Series
Volume IV

"somusar/Tefigel: A Tutorial Introduction"

Printer friendly


Contents
1. Introduction
2. Language Summary
3. Text File Components
4. Text File Processing
5. Modularity
6. Multilanguage Applicability
7. Generating Object-oriented Languages
8. Generating Internet-oriented Languages and Protocols
8.1 HTML
8.2 XML
8.3 SOAP
8.4 PHP
9. Generating Procedural Languages
10. Generating Scripting or Special-purpose Languages
11. Advanced Features and Topics
12. A More Extensive Example
13. Further Reading

Chapter 8 - Generating Internet-oriented Languages and Protocols

8.1 - HTML        top

Code Example 24 - Generating HTML
Generate a set of homogeneous buttons for an HTML form. Lines 6-9 show an example of variable number of arguments provided to a Tefigel subroutine.
Source code - File "language/html/formbuttons"
    1      #
    2      #   HTML document browsing buttons
    3      #
    4        <table cellpadding=0 cellspacing=0>
    5          <tr>
    6      @     language/html/formbutton(First)
    7      @     language/html/formbutton(Prev,Prev.)
    8      @     language/html/formbutton(Next)
    9      @     language/html/formbutton(Last)
   10          </tr>
   11        </table>
	       
Output of "/opt/somusar/bin/tefigel language/html/formbuttons"
    1        <table cellpadding=0 cellspacing=0>
    2          <tr>
    3            <td>
    4              <input type="BUTTON" width=60 name="First" value="First">
    5            </td>
    6            <td>
    7              <input type="BUTTON" width=60 name="Prev" value="Prev.">
    8            </td>
    9            <td>
   10              <input type="BUTTON" width=60 name="Next" value="Next">
   11            </td>
   12            <td>
   13              <input type="BUTTON" width=60 name="Last" value="Last">
   14            </td>
   15          </tr>
   16        </table>
	       

HTML subroutine - File "language/html/formbutton"
    1      #
    2      #   HTML form button
    3      #
    4      @ interface(NAME,label)
    5      @ if label=
    6      @    set label=NAME
    7      @ endif
    8      @ set WIDTH=60
    9            <td>
   10              <input type="BUTTON" width=WIDTH name="NAME" value="label">
   11            </td>
	       

8.2 - XML        top

Code Example 25 - Generating XML
Produce two sets of XML nested tags, complete with values. Depth depends on the number of input parameters.
Source code - File "language/xml.in"
    1      @ dash $
    2      @ language/xml(Tag1=Value1,Tag2=Value2)
    3      
    4      @ linebreak \
    5      @ language/xml(\
    6      TagA=ValueA,\
    7      TagB=ValueB,\
    8      TagC=ValueC,\
    9      TagD=ValueD)
   10      
	       
Output of "/opt/somusar/bin/tefigel language/xml.in"
    1      <Tag1>
    2          Value1
    3          <Tag2>
    4              Value2
    5          </Tag2>
    6      </Tag1>
    7      
    8      <TagA>
    9          ValueA
   10          <TagB>
   11              ValueB
   12              <TagC>
   13                  ValueC
   14                  <TagD>
   15                      ValueD
   16                  </TagD>
   17              </TagC>
   18          </TagB>
   19      </TagA>
   20      
	       

XML subroutine - File "language/xml"
    1      @ set I=0
    2      @ set INDENT=
    3      @ set BLANKS=    
    4      #
    5      #    Scan list of arguments, printing
    6      #    out indented open tag clause and value
    7      #
    8      @ while I<REG_COUNT
    9      @    set  ITEM=REG_$I
   10      @    set TAG$I=~field(ITEM,0,=)
   11      @    set VAL$I=~field(ITEM,1,=)
   12      @    set IND$I=INDENT
   13      INDENT<~value(TAG$I)>
   14      INDENT$BLANKS~value(VAL$I)
   15      @    set INDENT=~value(IND$I)BLANKS
   16      @    add I 1
   17      @ endwhile
   18      #
   19      #    Scan list of arguments backward, printing
   20      #    out indented close tag clause
   21      #
   22      @ while I>0
   23      @    sub I 1
   24      ~value(IND$I)</~value(TAG$I)>
   25      @ endwhile
	       

8.3 - SOAP        top

Code Example 26 - Generating SOAP
Generate a short SOAP request and response, as per Example 1 of document http://www.w3.org/TR/2000/NOTE-SOAP-20000508
Source code - File "language/soap"
    1      ---- Simple SOAP Request ----
    2      @ language/soap_code(GetLastTradePrice,symbol/DIS)
    3      ---- Simple SOAP Response ----
    4      @ language/soap_code(GetLastTradePriceResponse,Price/34.5)
	       
Output of "/opt/somusar/bin/tefigel language/soap"
    1      ---- Simple SOAP Request ----
    2      <SOAP-ENV:Envelope
    3       xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    4       SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    5       <SOAP-ENV:Body>
    6         <m:GetLastTradePrice xmlns:m="Some-URI">
    7           <symbol>DIS</symbol>
    8         </m:GetLastTradePrice>
    9       </SOAP-ENV:Body>
   10      </SOAP-ENV:Envelope>
   11      ---- Simple SOAP Response ----
   12      <SOAP-ENV:Envelope
   13       xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   14       SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   15       <SOAP-ENV:Body>
   16         <m:GetLastTradePriceResponse xmlns:m="Some-URI">
   17           <Price>34.5</Price>
   18         </m:GetLastTradePriceResponse>
   19       </SOAP-ENV:Body>
   20      </SOAP-ENV:Envelope>
	       

SOAP request/response fragment - File "language/soap_code"
    1      #
    2      #   REQUEST_RESPONSE_ID contains id of request or response
    3      #
    4      @ interface(REQUEST_RESPONSE_ID,PARAM_INFO)
    5      #
    6      #   PARAM_INFO contains tag/id of parameter #1 - note "/" used as a separator
    7      #
    8      @ set PARAM_TAG_1=~field(PARAM_INFO,0,/)
    9      @ set  PARAM_ID_1=~field(PARAM_INFO,1,/)
   10      <SOAP-ENV:Envelope
   11       xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   12       SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   13       <SOAP-ENV:Body>
   14         <m:REQUEST_RESPONSE_ID xmlns:m="Some-URI">
   15           <PARAM_TAG_1>PARAM_ID_1</PARAM_TAG_1>
   16         </m:REQUEST_RESPONSE_ID>
   17       </SOAP-ENV:Body>
   18      </SOAP-ENV:Envelope>
	       

8.4 - PHP        top

Code Example 27 - Generating PHP
Generating a PHP fragment that in turn will generate some HTML.
Source code - File "language/php"
    1      @ set TITLEHEADER=<h4>
    2      @ set TITLE=Generated PHP fragment
    3      <?php
    4      // Small fragment of PHP, printing out some HTML
    5      print "TITLEHEADER\n";
    6      print "TITLE\n";
    7      ?>
	       
Output of "/opt/somusar/bin/tefigel language/php"
    1      <?php
    2      // Small fragment of PHP, printing out some HTML
    3      print "<h4>\n";
    4      print "Generated PHP fragment\n";
    5      ?>
	       

[Previous chapter]    [Next chapter]    [Back to top]

http:// www.somusar.com  / doc  / booklets  / tefigel_tut  - Powered by SoProMach
Copyright © 2003-2012 Somusar - Trademarks - Legal - Privacy - Webmaster