Generated: April 17, 2005, 13:58:17 | Copyright © 2005 , Kurt Nørmark | ![]() |
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).
1. Introduction and usage. | 3. Variables which control the parser. | |
2. The main parsing function. | 4. Variables which is assigned to parser output. |
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. |
notation-list | notation-list | A list of notations defined by the parser |
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. | |||
The easiest way to parse an XML DTD is to use the procedure
xml-dtd-parse
located in laml.scm in the root of LAML distribution.
This procedure can be called from a LAML prompt. Here is another slightly more low-level way to use the parser.
The first element in each of the top level form of the parsed result distinguishes this element from each others (tagging).
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 | CONTand where NAME-STRING is a placeholder for a string constant. Here is information about the parsed formats of attributes and entities:
| |||
![]() ![]() ![]() 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 | ||
notation-list | |||
Form | notation-list | ||
Description | A list of notations defined by the parser | ||
parse-rhs-string | |||
Form | (parse-rhs-string rhs-str) | ||
Description | Top level rhs parser function. | ||