Generated: January 16, 2003, 23:30:56Copyright ©2003, Kurt NørmarkThe local LAML software home page

Reference Manual of the SGML/XML Document Type Definition Parser

Kurt Nørmark ©    normark@cs.auc.dk    Department of Computer Science    Aalborg University    Denmark    

Source file: tools/dtd-parser/dtd-parser-3.scm
LAML Version 19.00 (January 16, 2003, full)

This tool parses an XML Document Type Definition (DTD). The parsed result is represented as a flat list of element, attribute, and entity descriptors.

Another tool - the XML-in-LAML mirror generation tool - is able to produce a Scheme mirror of the XML language. The mirror generation tool takes as input the list, which is produced by the DTD parser.

There is some internal elucidative documentation of the DTD parser at the LAML development site.

Please consult "XML mirror in Scheme: XML in LAML" (section 2) for a tutorial introduction to the use of the parser.

An earlier versions of this tool was used to parse the HTML4.01 DTD (which is a non-XML DTD).

Table of Contents:
1. Introduction and usage.3. Variables which control the parser.
2. The main parsing function.4. Variables which is assigned to parser output.

Alphabetic index:
attribute-listattribute-listA list of attributes defined by the parser
dtd-parse-verbosedtd-parse-verboseA boolean variable which controls whether the parser should report on the progress while parsing.
element-listelement-listA list of elements defined by the parser
entity-listentity-listA list of entities defined by the parser
forced-inclusion-of-marked-sectionsforced-inclusion-of-marked-sectionsA boolean variable which controls whether to parse ignored marked sections anyway.
parse-dtd(parse-dtd file . non-expanding-entities)Parses a dtd file to Lisp expressions and writes the parsed result to another file.

 

1.   INTRODUCTION AND USAGE.
Here we describe how to use the parser.

  1. Start a Scheme interpreter, such as SCM or MzScheme.
  2. Define the variable laml-dir to the LAML directory path on your computer.
  3. Load this file (dtd-parser.scm in tools/dtd-parser) into a Scheme interpreter, for instance from the directory in which the dtd-parser.scm source file resides.
  4. Call the function (parse-dtd "dtd-file-without-extension"). Additional parameters of parse-dtd are interpreted as non-expanding entities. A call of the function will give you a similar Lisp parsed file with lsp extension. In addition the variables element-list, attribute-list, and entity-list will be defined by the parser. The resulting file contains a "flat" concatenation of these three lists.
We now describe the format of an entity, an attribute, and an element in the parsed result. Each unit in the result of the parsing is either an element, an attribute, or an entity. An element describes, in popular terms, "a single tag" in the markup language. An attribute describes the attribute of an element. Thus, in general, there is a one-to-one correspondance between the element list and the attribute-list. The list of entities are macro expansions, which have been applied to achieve a clean and parsable dtd file. The entity list is of minor importance once the file has been parsed.

The first element in each of the top level form of the parsed result distinguishes this element from each others (tagging).

The start-tag-status and end-tag-status are left overs from SGML and HTML4, see
the HTML4.01 definition. These two status fields are not used for XML. The content model is a string or a list. If it is a string it means that LAML cannot synthesize a validation predicate for it. If it is a list, LAML will automatically generate a validation predicate when a mirror is being produced. The comment field is not used either in XML.

 

2.   THE MAIN PARSING FUNCTION.
There is only one function, parse-dtd, to learn. This function represents and "is" the tool.


parse-dtd


Form
(parse-dtd file . non-expanding-entities)

Description
Parses a dtd file to Lisp expressions and writes the parsed result to another file. The parameter file is without extension. The second parameter is a list of entity names (strings without leading percent chars); no entity in the list will be expanded. This function also defines the lists element-list, attribute-list, and entity-list. The parsed result is the appending of element-list, attribute-list, and entity-list. It is assumed that the DTD file resides on file.dtd. This function writes the result to the file.lsp.


 

3.   VARIABLES WHICH CONTROL THE PARSER.


dtd-parse-verbose


Form
dtd-parse-verbose

Description
A boolean variable which controls whether the parser should report on the progress while parsing. Default #t.


forced-inclusion-of-marked-sections


Form
forced-inclusion-of-marked-sections

Description
A boolean variable which controls whether to parse ignored marked sections anyway. Default #t.


 

4.   VARIABLES WHICH IS ASSIGNED TO PARSER OUTPUT.


entity-list


Form
entity-list

Description
A list of entities defined by the parser


element-list


Form
element-list

Description
A list of elements defined by the parser


attribute-list


Form
attribute-list

Description
A list of attributes defined by the parser


Generated: January 16, 2003, 23:30:56
This documentation has been extracted automatically from the Scheme source file by means of the Schemedoc tool