Generated: August 27, 2003, 22:48:59 | Copyright ©2003, Kurt Nørmark |  |
Reference Manual of the 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-4.scm
LAML Version 21.00 (August 27, 2003, PP edition)
| This tool parses an XML Document Type Definition (DTD). The parsed result is represented as a flat list of element, attribute,
and entity descriptors.
This version of the XML DTD parser also parses the content models of the XML elements. This is the basis for the fully automatic synthesis of
final state automata for validation of XML-in-LAML documents at document generation time.
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 mirrors in Scheme: XML in LAML" (section 2)
for a tutorial introduction to the use of the parser.
The DTD parser is not perfect, but we steadily improve it when it is needed. See the README file in the directory of the source files
for details and progress.
An earlier (and now obsolete) version of this tool was used to parse the HTML4.01 DTD (which is a non-XML DTD).
|
|
Table of Contents:
Alphabetic index:
| attribute-list | attribute-list | A list of attributes defined by the parser
| dtd-parse-verbose | dtd-parse-verbose | A boolean variable which controls whether the parser should report on the progress while parsing. | element-list | element-list | A list of elements defined by the parser
| entity-list | entity-list | A list of entities defined by the parser
| forced-inclusion-of-marked-sections | forced-inclusion-of-marked-sections | A 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. | parse-rhs-string | (parse-rhs-string rhs-str) | Top level rhs parser function. |
|
1. INTRODUCTION AND USAGE.
Here we describe how to use the parser.
- Start a Scheme interpreter, such as SCM or MzScheme.
- Define the variable laml-dir to the LAML directory path on your computer.
- 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.
- 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).
- Element format:
(element name start-tag-status end-tag-status content-model comment)
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 symbol (any or empty) or a list prefixed with either mixed-content or element-content.
Mixed contents list have the form
(mixed-content pcdata)
(mixed-content (choice zero-or-more pcdata NAME-STRING NAME-STRING ... NAME-STRING))
Element contents lists have the form
(element-contents CONT)
where
CONT ::= ( KIND MULTIPLICITY DATA+ )
KIND ::= name | seq | choice | empty
MULTIPLICITY ::= one | optional | zero-or-more | one-or-more
DATA ::= NAME-STRING | CONT
and where NAME-STRING is a placeholder for a string constant.
Here is information about the parsed formats of attributes and entities:
- Attribute format:
(attribute name list-of-attribute-triples).
An attribute triple consist of
attribute name, attribute type (most basic type, no entities), and "availability status".
- Entity name:
(entity name entity-expansion).
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
| 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
| Description | | A list of entities defined by the parser
|
|
element-list
| Description | | A list of elements defined by the parser
|
|
attribute-list
| Description | | A list of attributes defined by the parser
|
|
parse-rhs-string
| Form | | (parse-rhs-string rhs-str) |
|
| Description | | Top level rhs parser function.
|
|
Generated: August 27, 2003, 22:48:59
This documentation has been extracted automatically from the Scheme source file by means of the Schemedoc tool