home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / sgml / unix / sgmlh / arctech.doc < prev    next >
Encoding:
Text File  |  1991-07-03  |  9.7 KB  |  197 lines

  1.                     TECHNICAL NOTES ON ARCSGML 1.0
  2.  
  3. NOTE: ISO 8879 (Standard Generalized Markup Language) is
  4.       required reading for anyone attempting to implement an SGML
  5.       application.  Its complete official text, incorporating
  6.       the 1988 amendment, extensively annotated and cross-referenced
  7.       and with additional tutorial material, can be found in my
  8.       book, The SGML Handbook, published by Oxford University
  9.       Press, ISBN 0-19-85373-9.  It is available at bookstores and
  10.       through the SGML Users' Group.
  11.  
  12. A. Compilation and Such
  13.  
  14.                      All Characters are Unsigned
  15.  
  16. Work on ARCSGML began in 1983, at the dawn of PC C compiler
  17. technology, so a number of compilers have been used over the years.
  18. As a result, some occurrences of the "char" type are coded with the
  19. typedef "UNCH", which stands for "unsigned character".  As compilers
  20. came along that offered compile-time switches to make all "chars"
  21. unsigned, I stopped using "UNCH" in places.  The bottom line is that
  22. all chars must be unsigned -- how you accomplish it depends on your
  23. coding style and the facilities of your compiler.
  24.  
  25.                            Non-DOS SGML I/O
  26.  
  27. NDSGMLIO.SRC is a version of SGMLIO.C with alternative encodings for
  28. other compilers and operating systems.  They are chosen by defining
  29. the following preprocessor names:
  30.  
  31. TURBOC    Borland C++ 2.0  (same code as in SGMLIO.C)
  32. MICROC    Microsoft C 5.1
  33. IBMC      IBM C for mainframes (not tested)
  34. C88       DeSmet C88 (not tested recently)
  35.  
  36. SGMLIO.C uses a Borland-specific DOS-specific function called
  37. "searchpath".  Some alternatives for other environments can be found
  38. in NDSGMLIO.SRC.
  39.  
  40. When NDSGMLIO.SRC is consulted, NDENVCB.SRC will also be of interest.
  41.  
  42.                                  Lint
  43.  
  44. Conventional comments for lint are for PC-Lint 2.11 by Gimpel
  45. Software.  However, lint was not run for the SGMLUG original
  46. distribution (ARCSGML 1.0) because Borland C appears to provide
  47. sufficient checking.
  48.  
  49. Borland C was run with ALL warnings enabled, which required lots of
  50. explicit type casting.  No warnings or errors were issued.
  51.  
  52. B. Sample Applications ("Text Processors")
  53.  
  54. The sample text processor that performs markup validation is called
  55. VM2.C or VM2.EXE.  If invoked with the /S option, it will print an
  56. excruciatingly detailed report of the parsing process (see VM2HELP.DOC
  57. for details).  This text processor is used for testing the internal
  58. functions of the parser, so it needs access to "non-ESIS" information
  59. not provided through the usual API.  As such, it is a poor model for
  60. normal text processors, which access the parser control block data
  61. through a friendlier interface provided by SGMLAPI.C.  (See
  62. ARCSGML.DOC for details of the program architecture.)
  63.  
  64. The sample text processor called APIMODEL is a better model (although
  65. presently untested), as it uses only the normal interfaces of SGMLAPI.
  66. It reads an SGML document and produces a slightly reformatted version.
  67. Although it is not complete, it is easy to see how to use it as a
  68. model for other "translation" applications, such as SGML to a word
  69. processor file.
  70.  
  71. C. System Declaration Information
  72.  
  73. A parser constructed with ARCSGML, when used in a conforming SGML
  74. system on an ASCII machine (e.g., PC or PS2), should be capable of
  75. conforming to the following system declaration:
  76.  
  77.                   SYSTEM "ISO 8879:1986"
  78.                           CHARSET
  79. BASESET  "ISO 646:1983//CHARSET
  80.           International Reference Version (IRV)//ESC 2/5 4/0"
  81. DESCSET  0 128 0
  82.  
  83. CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN"
  84. SCOPE    DOCUMENT
  85. SYNTAX   PUBLIC "ISO 8879:1986//SYNTAX Reference//EN"
  86.  
  87.                          FEATURES
  88. MINIMIZE DATATAG NO  OMITTAG  YES  RANK     NO  SHORTTAG YES
  89. LINK     SIMPLE  NO  IMPLICIT NO   EXPLICIT NO
  90. OTHER    CONCUR  NO  SUBDOC   NO   FORMAL   YES
  91.  
  92.                          VALIDATE GENERAL YES
  93. MODEL    NO   EXCLUDE  YES  CAPACITY YES
  94. NONSGML  YES  SGML     NO   FORMAL   YES
  95.  
  96. D. Interface Specification Notes
  97.  
  98. The function calls from the text processor to the parser are documented
  99. in SGMLAPI.H.  That file also describes the C structures with which the
  100. API returns information from the parser.  Other parser control blocks 
  101. (with which the text processor normally need not be concerned) are
  102. documented in the other header files.  The following notes supplement the
  103. information in SGMLAPI.H:
  104.  
  105.    1. Attribute values and SDATA
  106.       entities could contain delimited processing instructions.
  107.    2. Attribute values and CDATA, SDATA, and PI entities could contain
  108.       non-SGML characters (as can content data, described below).
  109.    3. Inline processing instructions are not parsed (except for PIC),
  110.       so character references are not recognized, and non-SGML characters
  111.       cannot occur validly (i.e., through character references).
  112.    4. There are three internal delimiters
  113.       that SGML will insert into returned data:
  114.       tpsw.delcdata brackets a CDATA entity returned in an
  115.                     attribute value.
  116.       tpsw.delsdata brackets an SDATA entity so returned.
  117.       tpsw.delnonch precedes a non-SGML character (see below).
  118.       In addition, an offset,
  119.       tpsw.addnonch, is added to a non-SGML character (modulo 256).
  120.       The delimiters and offset are set in the switch structure; they must
  121.       be non-SGML characters other than 0 8 9 10 13 26 and 28.
  122.       (29, 30, and 31 are the recommended delimiters; 64 us the offset.)
  123.       The CDATA and SDATA brackets can be removed when the data
  124.       is to be formatted.
  125.       The NONCHAR prefix might be needed until the last moment
  126.       for those NONCHARs that have special meaning to a text
  127.       processor, so tpsw.delnonch should be chosen accordingly.
  128.    5. When the recommended delimiters and offset are in use,
  129.       non-SGML characters will be returned as 31,char+64 (modulo 256).
  130.       For example: decimal 22 will be returned as decimal 31, followed
  131.       by decimal 86; decimal 255 as 31 63.
  132.    6. SGML returns resolved notation identifier with NOTATION attribute as
  133.       ADDATA(n).  It is a pointer to a NOTATION control block (see below).
  134.    7. When a start-tag is returned, IDREFL(n) is 1 if the corresponding IDREF
  135.       token refers to an existing ID; it is 0 if the ID hasn't been defined.
  136.    8. When parser returns a start-tag with attributes, an attribute that
  137.       must always be a single token is treated as CDATA, as distinguished
  138.       from a list that just happens to be one token long.
  139.    9. PUBLIC identifier is passed to SGMLIO in ipbfile.ipbp1
  140.       when resolving external identifiers for entities and data content
  141.       notations (programs that access non-SGML data entities).
  142.    10.For RCBDAF returns: if NDESW is on, data ptr is to NDATA entity
  143.       control block.  For AENTITY attributes, ADDATA(i) points to NDATA
  144.       ecb.  The NDATA ecb (struct ne in ADL.H) in turn points to a NOTATION
  145.       control block (struct dcncb in ENTITY.H).  There is code in VM2.C
  146.       that shows how to handle these control blocks.  (You can imbed
  147.       image and graphic entities anywhere that a character entity could
  148.       be referenced.)
  149.    11.You can support device-dependent versions of
  150.       PUBLIC entities (e.g., non-keyable graphic characters), according
  151.       to the syntax of formal public identifiers as defined by the Standard.
  152.       The parser indicates in the FILENAME ipb four entity type codes
  153.       for when a public identifier is versionless and the best available
  154.       version should be substituted.  SGMLIO must find the
  155.       best available version.  (See SGMLCB.H and SGMLIO.C for details.)
  156.    12.If the document element terminates other than by its own end-tag
  157.       or by the end of the document entity, an error message (89) is issued
  158.       and the parser returns an EOD rcb.  Any remaining text in the
  159.       primary entity is ignored.
  160.    13.Multiple passes are supported.  The
  161.       ptrs to rc and rcb in the text processor are passed in
  162.       the switches structure, whose address is sent to the parser
  163.       in the SGMLSET ipb.  At the
  164.       end of the run, SGMLEND must be sent to allow final
  165.       cleanup by the parser.  (See VM2.C for the details.)
  166.    14.SGML keeps a buffer only for the current file.  SGMLIO saves and
  167.       restores the location when a nested file is opened.
  168.    15.Stack of positions (source control blocks) is returned when an error
  169.       occurs, so full entity trace can be printed in error messages.
  170.    16.Trailing RE RS suppression and leading RS insertion for external entities
  171.       set by user parameter (overridable in system ID of ENTITY declaration).
  172.  
  173. E. Debugging Aids
  174.  
  175. VM2, because it reveals the internal state of the parser, can be a
  176. useful debugging aid when the /S option is enabled.  In addition, the
  177. TRACESET module contains routines to format and print the parser's
  178. internal control blocks, and to display a vertical "tape" of the
  179. characters parsed and the state transitions they caused.
  180.  
  181. The various traces are enabled by setting environment variables to an
  182. arbitrary value so that the variables will exist (e.g., SET T=1).
  183. There are separate variables for the prolog (for debugging the DTD
  184. parsing) and the document instance.  They are:
  185.  
  186.   Prolog         Instance
  187.     PT               T                  trace state transitions
  188.     PA               A                  trace attribute activity
  189.                      C                  trace context checking
  190.     PD               D                  trace declaration parsing
  191.     PE               E                  trace entity activity
  192.     PG               G                  trace group creations
  193.                      I                  trace ID activity
  194.     PM               M                  trace MS activity
  195.     PN               N                  trace notation activity
  196.  
  197.