Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtdocbook / instant / README
1 /* $XConsortium: README /main/2 1996/07/15 14:09:31 drk $ */
2 #
3 # Copyright (c) 1994  
4 # Open Software Foundation, Inc. 
5 #  
6 # Permission is hereby granted to use, copy, modify and freely distribute 
7 # the software in this file and its documentation for any purpose without 
8 # fee, provided that the above copyright notice appears in all copies and 
9 # that both the copyright notice and this permission notice appear in 
10 # supporting documentation.  Further, provided that the name of Open 
11 # Software Foundation, Inc. ("OSF") not be used in advertising or 
12 # publicity pertaining to distribution of the software without prior 
13 # written permission from OSF.  OSF makes no representations about the 
14 # suitability of this software for any purpose.  It is provided "as is" 
15 # without express or implied warranty. 
16 #
17
18         instant - a formatting application for OSF SGML instances
19 ____________________________________________________________________________
20
21 Requirements
22
23     ANSI C compiler (gcc is one)
24
25     sgmls 1.1 -- sgml parser from James Clark.  Based on Goldfarb's ARC parser.
26
27     Vanilla unix make
28
29     POSIX C libraries
30
31
32 Files for instant program
33
34     Module              Function
35     ------              --------
36     browse.c            interactive browser
37     general.h           general definitions
38     info.c              print information about the instances
39     main.c              main entry, arg parsing, instance reading
40     tables.c            table-specific formatting routines (TeX and tbl)
41     traninit.c          translator initialization (read spec, etc.)
42     translate.c         main translator
43     translate.h         structure definitions for translation code
44     tranvar.c           routines for handling "special variables"
45     util.c              general utilities
46
47
48 Also required
49
50     1. Translation spec (transpec) files.  (../transpecs/*.ts)
51     2. SDATA mapping files for mapping sdata entities.  (../transpecs/*.sdata)
52     3. Character mapping files for mapping characters.  (../transpecs/*.cmap)
53
54
55 Platforms tried on
56
57     OSF1 1.3 (i486)
58     Ultrix 4.2 (mips)
59     HP-UX 9.01 (hp 9000/700)
60     AIX 3.2 (rs6000)
61     SunOS [missing strerror()]
62
63 ____________________________________________________________________________
64
65                         General outline of program
66                         ------- ------- -- -------
67
68 To summarize in a sentence, instant reads the output of sgmls, builds a tree
69 of the instnace in memory, then traverses the tree in in-order, processing
70 the nodes according to a translation spec.
71
72 Element tree storage
73 ------- ---- -------
74
75 The first thing instant must do is read the ESIS (output of sgmls) from the
76 specified file or stdin, forming a tree in memory.  (Nothing makes sense
77 without an instance...)  Each element of the instance is a node in the tree,
78 stored as a structure called Element_t.  Elements contain content (what
79 else?), which is a mixture of data (#PCDATA, #CDATA, #RCDATA - all the same
80 in the ESIS), child elements, and PIs.  Each 'chunk' of content is referred
81 to by a Content_t structure.  A Content_t contains an enum that can point to
82 a string (data or PI), another Element_t.  For example, if a <p> element
83 contains some characters, an <emphasis> element, some more characters,
84 a <function> element, then some more characters, it has 5 Content_t children
85 as an array.
86
87 Element_t's have pointers to their parents, and a next element in a linked
88 list (they're stored as a linked list, for cases when you'd want to quickly
89 travers all the nodes, in no particular order).
90 For convenience, Element_t's have an array of pointers to it's child
91 Element_t's.  These are just pointers to the same thing contained in the
92 Content_t array, without the intervening data or PIs.  This makes it easier
93 for the program to traverse the elements of the tree (it does not have to
94 be concerned with skipping data, etc.).  There is an analagous array of
95 pointers for the data content, an array of (char *)'s.  This makes it easier
96 to consider the immediate character content of an element.
97
98 Attributes are kept as an array of name-value mappings (using the typedef
99 Mapping_t).  ID attributes are also stored in a separate list of ID value -
100 element pointer pairs so that it is quick to find an element by ID.
101
102 Other information kept about each element (in the Element_t struct) includes
103 the line number in the EISI where the element occurs, the input filename.
104 (These depend on sgmls being run with the "-l" option.)  Also stored is
105 an element's order in its parent's collection of children and an element's
106 depth in the tree.
107
108 Translation specs
109 ----------- -----
110
111 A translation spec is read into a linked list in memory.  As the instance
112 tree is traversed, the transpecs are searched in order for a match.  As a
113 rule, one should position the less specific transpecs later in the file.
114 Also, specs for seldom-used element are best placed later in the file, since
115 it takes cpu cycles to skip over them for each of the more-used elements.
116
117 During translation of a particular element, the list of Content_t structures
118 are processed in order.  If a content 'chunk' is data, it is printed to
119 the output stream.  If it is an element, the translation routine is called
120 for that elemen, recursively.  Hence, in-order traversal.
121
122 Miscellaneous information displays
123 ------------- ----------- --------
124
125 There are several informational display options available. They include:
126     -   a list of element usage (-u) -- lists each element in the instance,
127         it's attributes, number of children, parent, data content 'nodes'.
128     -   statistics about elements (-S) -- lists elements, number of times
129         each is used, percent of elements that this is, total char content
130         in that element, average number of characters in they element.
131     -   show context of each element (-x) -- lists each element and its
132         context, looking up the tree (this is the same context that
133         would match the Context field of a transpec).
134     -   show the hierarchy of the instance (-h) -- show an ascii 'tree' of
135         the instance, where elements deeper in the tree are indented more.
136         Numbers after the element name in parentheses are the number of
137         element content nodes and the number of data content nodes.
138
139 Interactive browser
140 ----------- -------
141
142 Originally, the interactive browser was intended as a debugging aid for
143 the code developer.  It was a way to examine a particular node of the
144 instance tree or process a subtree without being distracted by the rest
145 of the instance.  Many of the commands test functionality of the query
146 and search code (such as testing whether a certain element has a given
147 relationship to the current position in the tree).
148
149
150 ____________________________________________________________________________
151