HOME | COMPANY | SOFTWARE | DOCUMENTATION | EDUCATION & TRAINING | SALES & SERVICE

    "The Official Guide to Programming with OmniMark"

Site Map | Search:   
OmniMark Magazine Developer's Forum   

  International Edition   

OmniMark® Programmer's Guide Version 3

18. How Asynchronous Concurrent Context Translations Work

Previous chapter is Chapter 17, "SGML Document and Subdocument Parsing".

Next chapter is Chapter 19, "Customizing OmniMark Behaviour".

This chapter uses a small but complex example to describe how OmniMark behaves when executing a complex context-translation.

The context-translation provides the most powerful mechanism for translating generalized text documents to SGML, and for translating generalized text documents to another form of generalized text document with the aid of a content model.

In a context translation, ELEMENT rules and FIND rules operate concurrently and asynchronously. Complex interactions of OmniMark and the SGML parser make this possible. Each type of rules operates in what is referred to as a domain; the input processor and the output processor. Each domain can be thought of as being on either side of the internal SGML parser. The input processor is on the input side of the SGML parser and the output processor is on the output side of the SGML parser.

OmniMark selects rules and executes actions in one domain or the other at a time.

The following example is designed to illustrate the interactions between the FIND rules and the ELEMENT rules. It is a complete OmniMark program and can be executed. As will be illustrated, OmniMark can switch domains several times during the execution of the actions of a single rule. From the point of view of the OmniMark programmer, the find and output processors are executing concurrently. The asynchronicity is determined by the information requirements, and information generation capability of the SGML parser.

The object of this OmniMark program is to move generalized text information "across" the SGML parser through buffers, from the FIND rule to the ELEMENT rules and vice versa. It is not a practical example in and of itself, but forms the model for existing commercial OmniMark applications.

   CONTEXT-TRANSLATE                              ;  1
                                                  ;  2
   GLOBAL STREAM main                             ;  3
   GLOBAL STREAM find-state                       ;  4
                                                  ;  5
   ELEMENT main                                   ;  6
     OUTPUT find-state                            ;  7
     SET main TO "Processing ELEMENT 'main'%n"    ;  8
     OUTPUT "%c"                                  ;  9
                                                  ; 10
   ELEMENT alpha                                  ; 11
     OUTPUT "%g(find-state)"                      ; 12
     SUPPRESS                                     ; 13
                                                  ; 14
   ELEMENT beta                                   ; 15
     SUPPRESS                                     ; 16
                                                  ; 17
   FIND "\doc"                                    ; 18
     SET find-state TO "Processing FIND 'doc'%n"  ; 19
     OUTPUT "<main>"                           ; 20
     SET find-state TO "%g(main)"                 ; 21
     OUTPUT "<beta>"                           ; 22
                                                  ; 23
   FIND-START                                        ; 24
     OUTPUT "<!doctype main ["                    ; 25
     OUTPUT "<!ELEMENT main  - o (alpha, beta)>"  ; 26
     OUTPUT "<!ELEMENT alpha - o empty>"          ; 27
     OUTPUT "<!ELEMENT beta  - o empty>]>"        ; 28
                                                  ; 29
   SGML-ERROR                                     ; 30

Given a document with the content "\doc", OmniMark will execute this program as follows:

To completely understand the order of events requires some knowledge of exactly how the SGML parser processes SGML. Fundamentally, domain switching occurs when the SGML parser receives a complete SGML token, such as a complete start or end tag, complete processing instructions, or complete external entity references.

Each PUT or OUTPUT action which writes into the #SGML stream is acted upon by the SGML parser immediately after the action ends. The parser determines whether it has sufficient information to return to the output processor or that it must obtain further information from the input processor.

Next chapter is Chapter 19, "Customizing OmniMark Behaviour".

Copyright © OmniMark Technologies Corporation, 1988-1997. All rights reserved.
EUM27, release 2, 1997/04/11.

Home Copyright Information Website Feedback Site Map Search