contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
Context translations: a simple example  
Related Concepts  

Introduction

Although this is a simple example of a context-translation, it effectively illustrates the typical roles of the input and output processors in a context-translation.

This program will convert the following sample input to an SGML document conforming to the element declarations contained in the file "my.dtd" as they are shown here: <!ELEMENT doc - o (chapter+)> <!ELEMENT chapter - o (title, p+)> <!ELEMENT title - o (#PCDATA)> <!ELEMENT p - o (#PCDATA)>

An appropriate input document would look something like this: Context-Translation The find rules in the program just insert the markup. The element rules add white- space to make the document look more readable. The Input Document The input document consists of paragraphs and chapter titles. Chapter titles are preceded and followed by two blank lines to make them stand out. Paragraphs are separated from each other by a single blank line.

The find-start rule ensures that the first line of the document is interpreted as a chapter title. Following that, each single line of text surrounded by blank lines is interpreted as an additional chapter title. ("%n" {2}+ matches a sequence of two or more line-end characters.) All other blocks of text are interpreted as paragraphs.

On the output processor side, the resulting SGML is "cleaned up" as follows:



Sample

  context-translate

  find-start
     output "<!DOCTYPE doc SYSTEM 'my.dtd'>%n"_
            "<DOC><CHAPTER><TITLE>"

  find "%n"{2}+ any-text+ => title-text "%n"{2}+
     output "<chapter><title>%x(title-text)</title><P>"

  find "%n"{2}+
     output "<P>"

  element doc
     output "%c"

  element chapter
     output "<chapter>%n%c"

  element #implied
     output "<%q>%sc</%q>%n"

Related Concepts  
   Context-translations: using XML/SGML as an intermediate form
 
----  

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

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

Copyright © OmniMark Technologies Corporation, 1988-1999.