contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
TeX to SGML conversions  
Related Concepts  

Introduction

This is an example of a program that is useful if you have a large number of TeX files to translate into SGML. To convert them all by hand would be a time-consuming and error-prone task, but it's quite simple to write an OmniMark program to automate the task.

The OmniMark program begins by identifying the translation type. This program is an up-translation, whose result is an SGML document corresponding to a given Document Type Definition. The bulk of the translation consists of find rules.

As it reads the TeX file, OmniMark looks for strings corresponding to the patterns defined by the find rules. When one is found, the actions in the rule are performed. As the output is generated, the SGML parser verifies that it corresponds to the Document Type Definition.

The first rule in the example is a find-start rule that passes the DTD to the SGML parser. It assumes that the file named "file.dtd" contains the DTD used to guide the translation.

The first find rule is

  find "\input glossmac" white-space*
    output "<title>"

This rule tells OmniMark to look for the string "\input glossmac" followed by any number of spaces, tabs, or end-of-line sequences. When the pattern is found, the action within the rule writes the <glossary> start tag. The next rule uses a similar technique to search for the start of the title. The third rule is a little more complicated:

  find "}" "%n"?
    do when element is title
       output "</title>%n"
    else when element is term
       output "</term>%n"
    else when element is def
       output "</def>%n</entry>%n"
    done

This rule searches for a right brace, possibly followed by an end-of-line sequence. The action taken when this pattern is found depends on the context. The appropriate end tags are written according to the state of the SGML parser. This ability to qualify an action distinguishes OmniMark from other pattern-matching languages.



Sample Files

TeX to SGML conversions
TeX to SGML input file sample
TeX to SGML output file sample

Related Concepts  
   Up-translation: translating documents into XML/SGML
 
----  

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:46 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.