Generated: July 9, 2004, 14:31:30 Copyright © 2004 , Kurt Nørmark The local LAML software home page

Reference Manual of the XML-in-LAML library

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

Source file: lib/xml-in-laml/xml-in-laml.scm
LAML Version 24.00 (July 9 2004, beta 5, full)

The XML-in-LAML common parts, which are shared between all XML-in-LAML languages. The library is used together with XHTML 1.0 transitional, XHTML 1.0 strict, XHTML 1.0 frameset, SVG 1.0, LENO (XML-in-LAML), and other similar mirrors.

This library is also designed to co-exists with non-validating HTML mirrors (mainly the sake of LENO, for instance). However, it cannot be used together with other validating AST-based HTML mirrors, such as Html4.01 transitional validating. You should use an all XML-IN-LAML solution. By that we mean a solution, where also the HTML stuff is based on XML-in-LAML. In practical terms, it means that you should use one of the XHTML mirrors mentioned above.

This library loads the the LAML finite state automation library for the sake of full document validation at document generation time.

At the tool end, The XML-in-LAML Mirror Generation tool is able to create a set of Scheme mirror functions for a given XML DTD. The generated mirror functions together with the shared XML-in-LAML common library (this file) make up the effective mirror of an XML language.

Table of Contents:
1. XML front matter stuff. 9. The language map. 17. XML in LAML parametrization and abstraction functions.
2. XML-in-LAML processing parameters. 10. XML navigation information. 18. AST traversal and AST transformation functions.
3. Other Constants. 11. Mirror generation functions. 19. XML validation procedures.
4. AST constructors and basic selector selectors. 12. Contents validation. 20. Element content models.
5. High-level AST selector functions. 13. Attribute checking. 21. Action procedure map.
6. AST predicates. 14. XML warning procedures. 22. Other useful functions.
7. Character entities. 15. Rendering functions and procedures.
8. XML language bookkeeping. 16. Element related functions.

Alphabetic index:
_ _ The symbolic name of explicit white space suppress.
action-procedure-map-of (action-procedure-map-of language) Return the action procedure map of the XML language.
action-procedure-of-language (action-procedure-of-language element-name language) Return the action procedure of the XML element named element-name in the XML language.
action-procedure-of-map (action-procedure-of-map element-name action-procedure-map) Return the action procedure of the XML element named element-name relative to the action procedure map action-procedure-map.
ast-attribute (ast-attribute ast name [default-attribute-value]) Return the value of the attribute name in ast.
ast-attributes (ast-attributes ast) Return the list of attributes of the ast.
ast-element-name (ast-element-name ast) Return the root element name of ast.
ast-kind (ast-kind ast) Return the kind of the ast.
ast-language (ast-language ast) Return the language of the ast.
ast-of-type? (ast-of-type? type name) A higher-order function that returns an AST predicate, which checks if the type of the AST is name.
ast-strong? (ast-strong? x) Is the parameter x an AST in a stronger interpretation than ast? Using the native LAML representation, ast-strong? and ast? are identical.
ast-subtree (ast-subtree ast el-name [n]) Return a specific subtree of ast, namely the n'th subtree with element-name el-name.
ast-subtrees (ast-subtrees ast) Return the list of substrees of ast.
ast-text (ast-text ast) Return a string of the aggregated CDATA contents of ast.
ast-to-parse-tree (ast-to-parse-tree ast) Convert an abtract syntax tree to a parse tree.
ast? (ast? x) Is the parameter x an AST.
attribute-getter (attribute-getter attribute-name [default-value]) A higher-order function which returns an attribute getter function on ASTs.
can-have-element-constituent? (can-have-element-constituent? ast el-name) Can ast have a direct or indirect constituent (sub-ast) with element name el-name.
causes-xml-in-laml-name-clash? (causes-xml-in-laml-name-clash? name) Is name involved in a name clash among the registered xml-in-laml languages?
cdata? (cdata? x) Is the parameter x CDATA
char-ref (char-ref x) Return a character reference value for x.
char-ref-value (char-ref-value char-ref-structure) Return the number or symbol of char-ref-structure.
char-ref? (char-ref? x) Is x a character reference.
content-model-map-of (content-model-map-of language) Returns the content model map (an association list) of a given XML language.
content-model-of (content-model-of element-name language) Return the content model of the element named element-name in XML language.
contents-data? (contents-data? x [language]) Is the parameter x a contents element item.
display-xml-warning (display-xml-warning . messages) A variant of display-warning which prefixes the warning text with a 'XML Warning' prefix.
element-names-of-language (element-names-of-language language) Return the element names of language, as defined by its language map.
explicit-space explicit-space The explicit white space value, as used internally in ast.
explicit-space-suppress explicit-space-suppress The explicit white space suppress value.
find-asts (find-asts ast el-name [ast-transformer]) Find and return a list of transformed sub ASTs of ast (first parameter) each with a root element of name el-name.
find-first-ast (find-first-ast ast el-name [ast-transformer]) Find and return a sub-AST of ast (first parameter) with a root element of name el-name.
forced-white-space? (forced-white-space? x) Is the parameter x a white space mark.
generate-xml-mirror-function (generate-xml-mirror-function validation-procedure tag-name default-dtd-attributes single-double-kind language overlap-check? action-procedure) Return an XML mirror surface function, in which textual content parameters and attribute value pairs can be given in a very liberal fashion.
get-mirror-function (get-mirror-function language-map element-name) Return the mirror function based on element-name from language map.
indentation-delta indentation-delta An integer which gives the level of indentation for pretty printed output.
laml-internal-representation laml-internal-representation A variable that determines the internal representation used for XML-in-LAML.
laml-source-prepare (laml-source-prepare laml-lst) Prepare laml-list to be used as input to a mirror function.
language-in-use? (language-in-use? language) is language in use - is it registered as an xml-in-laml language?
language-map-of (language-map-of language) Return the language map of language.
languages-in-use (languages-in-use) Return the list of language in used, as registered by register-xml-in-laml-language.
make-ast (laml-make-ast element-name contents attributes kind language) Make an AST given element-name, contents, a property list of attributes, a kind (single/double), and an XML language name.
possible-attributes-rooted-by-element (possible-attributes-rooted-by-element element-name language) Return a list of attribute names that can appear as direct or indirect constituents of an AST rooted by element-name.
possible-elements-rooted-by-element (possible-elements-rooted-by-element element-name language) Return a list of element names that can appear as direct or indirect constituents of an AST rooted by element-name.
preferred-maximum-width preferred-maximum-width An integer that expresses the prefered maximum column width for pretty printed ouput.
pretty-render-to-output-port (pretty-render-to-output-port xml-clause output-port [prolog epilog]) Pretty print the XML clause (an AST) to output-port.
pretty-xml-render (pretty-xml-render xml-clause [prolog epilog]) Pretty print xml-clause (an LAML AST) and return the rendered string.
process-ast! (process-ast! ast [given-language action-map]) Process the ast, the internal document representation, by means of the action procedures in action-map.
put-mirror-function (put-mirror-function language-map element-name mirror-function) Update the language map by the association of element-name and mirror function.
register-xml-in-laml-action-procedures (register-xml-in-laml-action-procedures language action-procedure-structure) Register the action procedure structure for XML language.
register-xml-in-laml-content-models (register-xml-in-laml-content-models language content-model-structure) Register the content model structure for XML language.
register-xml-in-laml-language (register-xml-in-laml-language language language-map) Register that language (the first parameter) is an XML language in use in the current LAML session.
register-xml-in-laml-navigator (register-xml-in-laml-navigator language navigator-structure) Register navigator-structure and an XML-in-LAML navigator for language.
register-xml-in-laml-validators (register-xml-in-laml-validators language validator-structure) Register validator-structure for language.
render-to-output-port (render-to-output xml-clause output-port [prolog epilog]) Render the XML clause (an AST) to output-port.
required-implied-attributes (required-implied-attributes required-attribute-names implied-attribute-names [tag-name]) A higher-order function which returns an attribute checker.
set-xml-accept-extended-contents-in (set-xml-accept-extended-contents-in language new-value) Controls the handling of LAML element contents items in language.
set-xml-accept-only-string-valued-attributes-in (set-xml-accept-only-string-valued-attributes-in language new-value) Controls the handling of LAML attribute values in language.
set-xml-char-transformation-table-in (set-xml-char-transformation-table-in language new-value) Set the HTML/XML character transformation table used for language.
set-xml-transliterate-character-data-in (set-xml-transliterate-character-data-in language new-value) Ask for transliteration of all CDATA characters via an HTML/XML character transformation table.
standard-prolog (standard-prolog [language]) The standard-prolog function as redefined for XML.
terminal-ast-node? (terminal-ast-node? x) Is x an ast nodes without subtrees?
transform-ast (transform-ast ast . transform-specs) Transform ast recursively by means of transform-specs.
transform-ast-list (transform-ast-list input-list . transform-specs) Apply the transformation-specs on input-list and return a list of transformed input elements.
traverse-and-collect-all-from-ast (traverse-and-collect-all-from-ast ast-tree node-interesting? ast-transformer) Traverse all nodes of the AST ast-tree, and return transformed subtrees that satisfy the node-interesting? predicate.
traverse-and-collect-first-from-ast (traverse-and-collect-first-from-ast ast-tree node-interesting? ast-transformer) Traverse the AST ast-tree, and return a transformation of the first subtree which satisfies the predicate node-interesting.
unique-ast-attribute (unique-ast-attribute ast name [default-attribute-value]) Return the value of the attribute name in ast, or in one of the subtrees of ast.
validate-as-pcdata! (validate-as-pcdata! contents tag-name) Validate that contents is pure PCDATA.
validate-ast! (validate-ast! ast [given-language language-overlap-check?]) Validate ast.
validate-contents-by-dfa! (validate-contents-by-dfa! contents dfa tag-name) Apply the deterministic final state automaton dfa on contents.
validate-mixed-contents-by-simple-means! (validate-mixed-contents-by-simple-means! contents symbol-choice-list tag-name) Validate that contents corresponds to mixed contents.
validation-procedure-map-of (validation-procedure-map-of language) A validation procedure map of an XML language is a sorted, associative vector that maps element names to XML validation procedures.
validation-procedure-of (validation-procedure-of element-name language) Return the XML validation procedure of the element named element-name in language.
white-space-related? (white-space-related? x) Is the parameter x white space related?
white-space-suppress? (white-space-suppress? x) Is the parameter x a white suppress space mark.
xml-accept-extended-contents-in? (xml-accept-extended-contents-in? language) A boolean variable that controls how rigid LAML handles element contents items.
xml-accept-only-string-valued-attributes-in? (xml-accept-only-string-valued-attributes-in? language) A boolean variable that controls how rigid LAML handles attribute values in language (first parameter).
xml-always-render-white-space? xml-always-render-white-space? Controls the rendering of white space in the textual contents.
xml-char-transformation-table-in (xml-char-transformation-table-in language) Return the HTML/XML character transformation table used for language.
xml-check-attributes! (xml-check-attributes! attributes dtd-attribute-definition number-of-req-attributes tag-name) Check the attributes (first par) in the calling form against the attribute definitions taken from the DTD file (second par).
xml-check-attributes? xml-check-attributes? A boolean variable which controls the checking of element attributes.
xml-check-error (xml-check-error . messages) The procedure that reports XML validation errors.
xml-check-language-overlap? xml-check-language-overlap? A boolean variable that controls the check of XML language overlap.
xml-declaration (xml-declaration) Return the xml declaration
xml-document-type-declaration-in (xml-document-type-declaration-in language) Return the document type declaration of language.
xml-error-truncation-length xml-error-truncation-length How many characters of the validation error messages to be presented.
xml-in-laml-abstraction (xml-in-laml-abstraction f [parameter-validator! f-name]) Generate a function with XML-in-LAML parameter passing rules, which passes its contents to the first parameter of f, and its attributes to the second parameter of f.
xml-in-laml-name-clashes xml-in-laml-name-clashes The list of names (symbols) which causes name clashes relative to the current set of languages in use.
xml-in-laml-parametrization (xml-in-laml-parametrization f parameter-mediator [parameter-validator! f-name]) Generate a function with XML-in-LAML parameter passing rules which sends its input to an ordinary function, f, with positional parameters via a parameter mediator.
xml-in-laml-positional-abstraction (xml-in-laml-positional-abstraction n m f [parameter-validator! f-name]) Generate a function with XML-in-LAML parameter passing rules, together with a number of required parameters before and after the XML-in-LAML parameters.
xml-modify-element (xml-modify-element element . attributes-and-contents) Bind some attributes content elements of element (the first parameter) and return a new, 'modified element function'.
xml-modify-element-prepend (xml-modify-element-prepend element . attributes-and-contents) A function similar to xml-modify-element, but instead of appending attributes-and-contents to the actual parameters of the modified function, it prepends attributes-and-contents.
xml-navigator-of (xml-navigator-of language) Return the XML navigator structure of language.
xml-non-transliteration-elements-in (xml-non-transliteration-elements-in language) Return the list of element names, for which we do not carry out the character transliteration in language.
xml-pass-default-dtd-attributes-in? (xml-pass-default-dtd-attributes-in? language) Controls whether the default attribute values, as specified in the DTD, are passed explicitly as attribute values in every instance of the element.
xml-preformatted-text-elements-in (xml-preformatted-text-elements-in language) Return the list of element names, for which we consistenly render all white space content characters as given in the input.
xml-render (xml-render xml-clause [prolog epilog]) Render the xml-clause (an LAML AST) and return the rendered string.
xml-represent-white-space-in? (xml-represent-white-space-in? language) This value controls the representation of white space in the internal AST representation of a document.
xml-sort-superficially-tag-parameters (xml-sort-superficially-tag-parameters parameters tag-name [language]) Like xml-sort-tag-parameters, but collect the content contribution in a relatively raw surface form.
xml-sort-tag-parameters (xml-sort-tag-parameters parameters tag-name [language]) Separates parameters according to the mirror rules of LAML.
xml-transliterate-character-data-in? (xml-transliterate-character-data-in? language) Return if CDATA (Character data) is transformed through an HTML/XML character transformation table.
xml-validate-contents? xml-validate-contents? A boolean variable that controls the XML validation.

1 XML front matter stuff.
This section contains the XML declaration and other XML front matter stuff

standard-prolog
Form (standard-prolog [language])
Description The standard-prolog function as redefined for XML. It returns the xml-declaration, the document type declaration, and a copyright comment. The standard prolog is the document part before the document root element. A default version of the standard-prolog is found in laml.scm. The present function relies on another function, xml-document-type-declaration-in, which returns an appropriate document type declaration
See also applied function xml-declaration
applied function xml-document-type-declaration-in
applied function copyright-clause

xml-declaration
Form (xml-declaration)
Description Return the xml declaration

2 XML-in-LAML processing parameters.
The variables and functions in this part control a number of general properties of XML-in-LAML processing. Some of these are generic for all XML-in-LAML languages; Others are specific to a single language. A number of the properties are related to the checking, validation, and error reporting of the XML mirror functions.

laml-internal-representation
Form laml-internal-representation
Description A variable that determines the internal representation used for XML-in-LAML. Possible values: laml and sxml. The value laml implies usage of the original LAML ASTs. The value sxml implies usage of the SXML list representation of XML. Use of the value sxml is still somewhat experimental. If the value of this variable is changed, the xml-in-laml library must be reloaded.

xml-check-attributes?
Form xml-check-attributes?
Description A boolean variable which controls the checking of element attributes. If true, check the element attributes against the attributes as defined in the DTD file. This variable is generic and common for all XML-in-LAML languages. The default value is true.

xml-validate-contents?
Form xml-validate-contents?
Description A boolean variable that controls the XML validation. If true, do validate the generated XML document against the DTD. This variable is generic and common for all XML-in-LAML languages. The default value is true.

xml-check-language-overlap?
Form xml-check-language-overlap?
Description A boolean variable that controls the check of XML language overlap. If true, check that that no elements are used via ambiguous simple names. Quite naturally, this variable is generic and common for XML-in-LAML loaded at the same time.

xml-transliterate-character-data-in?
Form (xml-transliterate-character-data-in? language)
Description Return if CDATA (Character data) is transformed through an HTML/XML character transformation table. The value is boolean, and normally true.
See also mutator set-xml-transliterate-character-data-in
transformation table laml.scm

set-xml-transliterate-character-data-in
Form (set-xml-transliterate-character-data-in language new-value)
Description Ask for transliteration of all CDATA characters via an HTML/XML character transformation table. new-value must be boolean.
Parameters language The name of the XML-in-LAML language - see the first few lines of relevant mirror library manuals - a symbol.
new-value A boolean value.
See also selector xml-transliterate-character-data-in?
table getter xml-char-transformation-table-in
table setter set-xml-char-transformation-table-in
exceptions xml-non-transliteration-elements-in
transformation table laml.scm
Note Consider macro implementation.

xml-char-transformation-table-in
Form (xml-char-transformation-table-in language)
Description Return the HTML/XML character transformation table used for language.
Returns A character transformation table.
See also transformation table laml.scm
table setter set-xml-char-transformation-table-in
exceptions xml-non-transliteration-elements-in

set-xml-char-transformation-table-in
Form (set-xml-char-transformation-table-in language new-value)
Description Set the HTML/XML character transformation table used for language. The value must be a character transformation table.
Parameters language The name of the XML-in-LAML language - see the first few lines of relevant mirror library manuals - a symbol.
new-value A character transformation table.
See also table getter xml-char-transformation-table-in
exceptions xml-non-transliteration-elements-in
transformation table laml.scm
Note Consider macro implementation.

xml-non-transliteration-elements-in
Form (xml-non-transliteration-elements-in language)
Description Return the list of element names, for which we do not carry out the character transliteration in language. In XHTML, the list typically include the elements style and script. The value is a list of strings. The value of this function is locked and bound at mirror generation time.
See also transliteration xml-transliterate-character-data-in?

xml-preformatted-text-elements-in
Form (xml-preformatted-text-elements-in language)
Description Return the list of element names, for which we consistenly render all white space content characters as given in the input. In XHTML, the list typically include the pre element. The value is a list of strings. The value of this function is locked and bound at mirror generation time.

xml-error-truncation-length
Form xml-error-truncation-length
Description How many characters of the validation error messages to be presented. If you want longer error messages, just increase the value of this variable. The default value is currently 130.

xml-pass-default-dtd-attributes-in?
Form (xml-pass-default-dtd-attributes-in? language)
Description Controls whether the default attribute values, as specified in the DTD, are passed explicitly as attribute values in every instance of the element. The value is boolean, and normally false. A true value in most cases give problems relative to the XML attribute validation. The value of this function is locked and bound at mirror generation time.
See also validation control xml-check-attributes?

xml-accept-only-string-valued-attributes-in?
Form (xml-accept-only-string-valued-attributes-in? language)
Description A boolean variable that controls how rigid LAML handles attribute values in language (first parameter). As the name indicates, the value controls if only string valued attributes are allowed in the language. If no language information is present (i.e., if the language parameter is #f) always return #t.
See also setter set-xml-accept-only-string-valued-attributes-in

set-xml-accept-only-string-valued-attributes-in
Form (set-xml-accept-only-string-valued-attributes-in language new-value)
Description Controls the handling of LAML attribute values in language. If new-value is true, LAML only accept string valued XML attribute. If new-value is false, LAML string converts whatever follows an attribute symbol. The value must be a boolean value. True is recommended.
Parameters language The name of the XML-in-LAML language - see the first few lines of relevant mirror library manuals - a symbol.
new-value A boolean value.
See also getter xml-accept-only-string-valued-attributes-in?
Note Consider macro implementation.

xml-accept-extended-contents-in?
Form (xml-accept-extended-contents-in? language)
Description A boolean variable that controls how rigid LAML handles element contents items. If the value returned is #t, numbers and characters are accepted as element content items in addition to strings, ASTs, and character references. If no language information is present (i.e., if the language parameter is #f) always return #f.
See also setter set-xml-accept-extended-contents-in

set-xml-accept-extended-contents-in
Form (set-xml-accept-extended-contents-in language new-value)
Description Controls the handling of LAML element contents items in language. If new-value is true, LAML accepts characters and numbers of contents items in addition to strings, ASTs and character references. If new-value is false, LAML only accept strings, ASTs, and character references as element contents items. The value must be a boolean value.
Parameters language The name of the XML-in-LAML language - see the first few lines of relevant mirror library manuals - a symbol.
new-value A boolean value.
See also getter xml-accept-extended-contents-in?

xml-document-type-declaration-in
Form (xml-document-type-declaration-in language)
Description Return the document type declaration of language. The empty string signals that no document type declaration is available. The value of this function is locked and bound at mirror generation time.

xml-represent-white-space-in?
Form (xml-represent-white-space-in? language)
Description This value controls the representation of white space in the internal AST representation of a document. If true, white space markers are inserted. If false, a clean AST without any white space marking is produced. In some languages, white space handling is essential. This is the case in XHTML. In XML languages that are not related to presentation at all, white space handling is not relevant. The value of this function is locked and bound at mirror generation time.

3 Other Constants.

explicit-space
Form explicit-space
Description The explicit white space value, as used internally in ast. The default value is boolean #t.

explicit-space-suppress
Form explicit-space-suppress
Description The explicit white space suppress value. The default value is boolean #f.

_
Form _
Description The symbolic name of explicit white space suppress.

preferred-maximum-width
Form preferred-maximum-width
Description An integer that expresses the prefered maximum column width for pretty printed ouput.

indentation-delta
Form indentation-delta
Description An integer which gives the level of indentation for pretty printed output.

xml-always-render-white-space?
Form xml-always-render-white-space?
Description Controls the rendering of white space in the textual contents. If #t, white space characters are rendered exactly as they are present in the textual content. If #f, white space is eliminated to the minimal amount when rendering. In normal use, always use #f. In situations where HTML formatting (especially PRE) is present as textual elements, it may be useful to use #t. In this context, notice the concept of preformatted text elements, as returned by the function xml-preformatted-text-elements-in.
See also relevant function xml-preformatted-text-elements-in

4 AST constructors and basic selector selectors.
In this section we document the functions that work on abstract syntax trees (ASTs). More specifically, we describe the AST constructor function and the most basic functions that select a constituent of an AST. Abstract syntax trees make up the internal representation of XML documents in LAML. All XML mirror functions return abstract syntax trees, and as such they can be thought as convenient, high level AST constructors. Notice that the implementation of the functions in this section depend heavily on the value of the variable laml-internal-representation.

make-ast
Form (laml-make-ast element-name contents attributes kind language)
Description Make an AST given element-name, contents, a property list of attributes, a kind (single/double), and an XML language name. The parameter contents may be a list of subtrees. It may also be an element which satisfies either ast?, cdata? or forced-white-space?. In these cases, we embed the single element into a list. attributes is the list of attributes on property list format (such as '(a1 "v1" a2 "v2")). attribute names are always symbols, and attribute values are normally strings.
Parameters element-name A symbol or a string.
contents A list of contents in term of CDATA (strings), white space markers, or other ASTs.
attributes The attributes represented as a property list
kind The symbol double or single
language A symbol or string that represent the XML-in-LAL language name.

ast-element-name
Form (ast-element-name ast)
Description Return the root element name of ast. The type of the returned value is a string.
Precondition ast is an abstract syntax tree that satisfies the ast? predicate

ast-subtrees
Form (ast-subtrees ast)
Description Return the list of substrees of ast. This is also known as the contents of the ast. It is a list of CDATA (strings), ASTs, and white space markers.
Precondition ast is an abstract syntax tree that satisfies the ast? predicate
See also similar function ast-subtree

ast-attributes
Form (ast-attributes ast)
Description Return the list of attributes of the ast.
Precondition ast is an abstract syntax tree that satisfies the ast? predicate
Returns The list of attributes, as a property list.
See also Relevant function get-prop
Relevant function defaulted-get-prop
high-level selector ast-attribute
high-order selector attribute-getter
Note The functions get-prop and defaulted-get-prop are useful for accessing the individual attribute values in the returned property list.

ast-kind
Form (ast-kind ast)
Description Return the kind of the ast. The type of the returned value is a symbol, either single or double. ASTs of type single are also known as empty elements. Tells whether the ast is to be rendered as a single or double tag.
Precondition ast is an abstract syntax tree that satisfies the ast? predicate

ast-language
Form (ast-language ast)
Description Return the language of the ast. The type of the returned value is a symbol.
Precondition ast is an abstract syntax tree that satisfies the ast? predicate

5 High-level AST selector functions.
In this section we describe a set of more elaborate functions that access the constituents of an AST. In many contexts, the functions in this section are more convenient than the basic selector functions from the previous section.

ast-subtree
Form (ast-subtree ast el-name [n])
Description Return a specific subtree of ast, namely the n'th subtree with element-name el-name. If no such subtree exists, return #f. The first subtree of a given name counts as number 1 (not 0).
Precondition n > 0
Parameters ast The ast in which to locate a subtree
el-name The ast element name of a subtree of ast (string or symbol)
n The constituent number regarding el-name subtrees (an integer). Defaults to 1.
Returns A subtree of AST (if located) or #f
See also basic selector ast-subtrees
generalized accessors traverse-and-collect-all-from-ast traverse-and-collect-first-from-ast

ast-attribute
Form (ast-attribute ast name [default-attribute-value])
Description Return the value of the attribute name in ast. Only attributes of ast are considered. This function is a convenient shortcut of (defauted-get-prop name (ast-attributes ast) default-value). The optional parameter serves as the attribute value in case no name attribute is found in the attribute list of ast.
Parameters ast An AST.
name The name of an attribute (a symbol).
default-attribute-value The default value, used if no attribute of name is found. A string.
See also basic selector ast-attributes
related function unique-ast-attribute

attribute-getter
Form (attribute-getter attribute-name [default-value])
Description A higher-order function which returns an attribute getter function on ASTs. The returned function takes an AST as parameter.
Parameters attribute-name the attribute name - a symbol.
default-value the default value returned if there is no attribute named attribute-name in the attribute-list.
See also lower-order function ast-attribute

ast-text
Form (ast-text ast)
Description Return a string of the aggregated CDATA contents of ast. White space markers are taken into account, but ast subtrees of ast are ignored.

6 AST predicates.
The functions in this section are predicates that work on ASTs and their constituents.

ast?
Form (ast? x)
Description Is the parameter x an AST.

ast-strong?
Form (ast-strong? x)
Description Is the parameter x an AST in a stronger interpretation than ast? Using the native LAML representation, ast-strong? and ast? are identical. Using the SXML representation, (ast-strong? T) requires that the tree T has attribute and aux information. This corresponds to the 3. normal form of SXML. The strong predicate is used during the interpretation of parameters to the mirror functions. Rationale: If the weak ast predicate is used for interpretation of the mirror parameters, ambiguities will occur between lists of contents/attributes and AST structures.

cdata?
Form (cdata? x)
Description Is the parameter x CDATA

contents-data?
Form (contents-data? x [language])
Description Is the parameter x a contents element item. In other words, is x either an ast, a character reference, or a string. If the optional language parameter is passed, and if this language accepts extended contents, also numbers and characters are considered as contents data.

char-ref?
Form (char-ref? x)
Description Is x a character reference.

forced-white-space?
Form (forced-white-space? x)
Description Is the parameter x a white space mark.

white-space-suppress?
Form (white-space-suppress? x)
Description Is the parameter x a white suppress space mark.

white-space-related?
Form (white-space-related? x)
Description Is the parameter x white space related?

terminal-ast-node?
Form (terminal-ast-node? x)
Description Is x an ast nodes without subtrees?

ast-of-type?
Form (ast-of-type? type name)
Description A higher-order function that returns an AST predicate, which checks if the type of the AST is name. The type is either element-name, kind, or language (a symbol). The resulting predicate may be applied on both ASTs and non-ASTs. If type is the symbol element-name, the generated predicate checks if a given AST has that element name at top level. If type is the symbol kind, the generated predicate checks if a given AST is either double or single. If type is the symbol language, the generated predicate checks if a given AST belongs to the language.

7 Character entities.
The function char-ref returns a character-reference. In XML, character references are used to denote characters which are not directly accessible from normal input devices. Notice that the predicated char-ref? is located in the AST predicate section.

char-ref
Form (char-ref x)
Description Return a character reference value for x. The parameter may be a positive, decimal integer or a symbolic name (string or symbol), such as amp, gt, or lt. Character references are represented internally as an appropriate list structure, similar to an AST list structure. In xml-render, these structures are converted to XML's character notation. With this we avoid a conflict with character transformation using the HTML transformation tables.

char-ref-value
Form (char-ref-value char-ref-structure)
Description Return the number or symbol of char-ref-structure.

8 XML language bookkeeping.
XML-in-LAML keeps track of the XML-in-LAML languages in use, and it will warn you if an ambiguously named mirror function is used. The boolean variable xml-check-language-overlap? can be used to control the reporting of language overlaps (use of ambiguous mirror functions.)

Each XML language has a name when used in LAML. The names of all loaded mirrors is returned by the parameter-less function languages-in-use. If N is the name of an XML-in-LAML language, (N 'el-name) returns the mirror function named el-name in N.

A language map is an association list that maps mirror function names to the mirror functions. Via use of a language map, it is always possible to acces a mirror function independt of name clashes with other XML language mirrors.


xml-in-laml-name-clashes
Form xml-in-laml-name-clashes
Description The list of names (symbols) which causes name clashes relative to the current set of languages in use. Assigned by register-xml-in-laml-language. Thus, this variable is always up-to-date in between registrations of languages. Be careful not to redefine this variable by double loading this file.

register-xml-in-laml-language
Form (register-xml-in-laml-language language language-map)
Description Register that language (the first parameter) is an XML language in use in the current LAML session. This function is called by the mirror function libraries. The first parameter, language, is a symbol. The second parameter, language-map, is the language map of the language. As a precondition it is assumed that we do not register the same language more than once.

language-map-of
Form (language-map-of language)
Description Return the language map of language. If language is not registered via register-xml-in-laml-language, return #f. The parameter language is a symbol.

language-in-use?
Form (language-in-use? language)
Description Is language in use - is it registered as an xml-in-laml language?

languages-in-use
Form (languages-in-use)
Description Return the list of language in used, as registered by register-xml-in-laml-language.

element-names-of-language
Form (element-names-of-language language)
Description Return the element names of language, as defined by its language map.

causes-xml-in-laml-name-clash?
Form (causes-xml-in-laml-name-clash? name)
Description Is name involved in a name clash among the registered xml-in-laml languages?

9 The language map.
The language map is a mapping that allows us to access the element mirror functions independent of any name clash. In this version of LAML the language map is an association that maps element names (symbols) to function objects. In the longer run, it should be a more efficient search structure.

get-mirror-function
Form (get-mirror-function language-map element-name)
Description Return the mirror function based on element-name from language map. Return #f if no mirror function exists in the map. The parameter element-name is either a symbol or a string.

put-mirror-function
Form (put-mirror-function language-map element-name mirror-function)
Description Update the language map by the association of element-name and mirror function. Returns the updated map. The parameter element-name is either a symbol or a string. Causes an error if there already is an entry for element-name

10 XML navigation information.
XML navigation information provides for "smart searching" of XML ASTs. The smartness is based on the following knowledge: (1) The possible direct and indirect sub-elements of a given element. (2) The possible attributes of an element and its direct and indirect sub-elements. This information is pre-computed in the XML-in-LAML mirror generation tool. The functions in this section provides access to this pre-computed information. Notice that the functions in this section Return static information, as derived from the DTD.

register-xml-in-laml-navigator
Form (register-xml-in-laml-navigator language navigator-structure)
Description Register navigator-structure and an XML-in-LAML navigator for language. This function is called "automatically" when the mirror functions are loaded.

xml-navigator-of
Form (xml-navigator-of language)
Description Return the XML navigator structure of language. If language is not registered via register-xml-in-laml-language, return #f. The parameter language is a symbol.

possible-elements-rooted-by-element
Form (possible-elements-rooted-by-element element-name language)
Description Return a list of element names that can appear as direct or indirect constituents of an AST rooted by element-name. Reflexively, element-name will always be returned as part of the result.
Precondition language is a registered XML language in the enclosing LAML session, and element-name is an existing name of an element in language.
Returns The list of possible elements names (a list of symbols). The list is sorted alphabetically.

possible-attributes-rooted-by-element
Form (possible-attributes-rooted-by-element element-name language)
Description Return a list of attribute names that can appear as direct or indirect constituents of an AST rooted by element-name. Reflexively, the attributes of element-names are always parts of the result.
Precondition language is a registered XML language in the enclosing LAML session, and element-name is an existing name of an element in language.
Returns The list of possible attribute names (a list of symbols). The list is sorted alphabetically.

can-have-element-constituent?
Form (can-have-element-constituent? ast el-name)
Description Can ast have a direct or indirect constituent (sub-ast) with element name el-name. The result is always true if (ast-element-name ast) equals to el-name.
Parameters ast An AST
el-name is the name of an element in the language of ast (a string or a symbol).

11 Mirror generation functions.
The functions in this sections are the important and 'heavy' mirror generation functions.

xml-sort-tag-parameters
Form (xml-sort-tag-parameters parameters tag-name [language])
Description Separates parameters according to the mirror rules of LAML. In other words, this is the function which implements the central LAML mirror function rules. Returns a cons cell of contents and attributes. Attributes are returned in property list format. Contents are returned as a list contents elements (strings, ASTs, booleans).
See also similar function xml-sort-superficially-tag-parameters

xml-sort-superficially-tag-parameters
Form (xml-sort-superficially-tag-parameters parameters tag-name [language])
Description Like xml-sort-tag-parameters, but collect the content contribution in a relatively raw surface form. Handle attributes in the same way as xml-sort-tag-parameters. As a contrast to xml-sort-tag-parameters, white space related values are passed unchanged by this funnction. Use this kind of 'sorting' to obtain XML-in-LAML parameter passing in abstractions, which transfer data to XML-in-LAML mirror functions (which in turn use xml-sort-tag-parameters).
See also similar function xml-sort-tag-parameters

laml-source-prepare
Form (laml-source-prepare laml-lst)
Description Prepare laml-list to be used as input to a mirror function. This function is useful when the result of transform-ast-list is passed as input to a XML mirror function. Elimiate forced-white-space markers, and introduce explict-space-suppres when necessary.
See also in relation to transform-ast-list

generate-xml-mirror-function
Form (generate-xml-mirror-function validation-procedure tag-name default-dtd-attributes single-double-kind language overlap-check? action-procedure)
Description Return an XML mirror surface function, in which textual content parameters and attribute value pairs can be given in a very liberal fashion.
Parameters validation-procedure the procedure that validates all aspects of the application of the element mirror function.
tag-name a string which represents the name of the tag (used for error message purposes).
default-dtd-attributes an alist of attribute key value pairs, as specified in the DTD.
single-double-kind either the symbol single, double or possible-single.
language the language in use (a symbol).
overlap-check? controls whether to check for name clashes in between the registered XML-in-LAML languages.
action-procedure serves both as a boolean and a procedure. If #f, no action procedure is supplied. If #t, an action procedure exists. If a procedure, it is the action procedure.

12 Contents validation.
The definitions in this section carry out the content validation.

validate-contents-by-dfa!
Form (validate-contents-by-dfa! contents dfa tag-name)
Description Apply the deterministic final state automaton dfa on contents. If contents is not accepted call xml-check-error for an appropriate reporting of the validation error.
Parameters contents A list of content items, such as strings, ASTs and white space markers.
dfa A deterministic final state automation which controls the acceptance.
tag-name The name of the element - used for error message purposes.

validate-as-pcdata!
Form (validate-as-pcdata! contents tag-name)
Description Validate that contents is pure PCDATA.
Parameters contents A list of content items, such as strings, ASTs and white space markers.
tag-name The name of the element - used for error message purposes.

validate-mixed-contents-by-simple-means!
Form (validate-mixed-contents-by-simple-means! contents symbol-choice-list tag-name)
Description Validate that contents corresponds to mixed contents. Mixed contents includes PCDATA a number of other choices in a 'zero-or-more' structure. It means that it is PCDATA or one of a number of possible ASTs.
Parameters contents A list of content items, such as strings, ASTs and white space markers.
tag-name The name of the element - used for error message purposes.
symbol-choice-list A list of symbols for the possible choices - a list of symbols.

13 Attribute checking.
The definitions in this section is used by the validation procedures, which are specific for each supported XML language. Current status of attribute checking: TokenizedTypes are not checked (ID, IDREFS, ...). In reality there is probably not much to check (besides some lexical checks which we can easily deal with, and some contraints which are much harder). NotationTypes are not dealt with - mostly because I have never encountered them, so the motivation to program check for this special enumeration type is not high. The #FIXED default keyword is present in the parsed DTD information, but we do not carry out any check against it (which is: If the attribute is given it must have the fixed default value). The attribute value normalization called for in section 3.3.3 of the XML specificaiton is not done either. Attribute duplication is checked for, as well as presence of angle characters in attribute values.

xml-check-attributes!
Form (xml-check-attributes! attributes dtd-attribute-definition number-of-req-attributes tag-name)
Description Check the attributes (first par) in the calling form against the attribute definitions taken from the DTD file (second par). The first parameter, attribute, is the attributes of the calling form, on property list form: (a1 v1 ... an vn). ai is a symbol and vi is a string. The second parameter dtd-attribute-definition is the attributes as defined in the dtd for the element in question. The third parameter number-of-req-attributes is the number of required attributes in dtd-attr-definitions. It happens to be the case that all the required attributes are located in the front of dtd-attribute-definition. The fourth parameter, tag-name, is the name of the enclosing tag. dtd-attribute-definition is a list of triples (attr-name attr-type require-status). attr-name is a string, attr-type is a string or a list of strings (possibilities), and require-status is a string such as "#IMPLIED" or "#REQUIRED"

14 XML warning procedures.

display-xml-warning
Form (display-xml-warning . messages)
Description A variant of display-warning which prefixes the warning text with a 'XML Warning' prefix.

xml-check-error
Form (xml-check-error . messages)
Description The procedure that reports XML validation errors. The default is display-xml-warning, which issues non-fatal warning messages. As an alternative you can use laml-error which provides for fatal error messaging. Both of these accept an arbitrary number of parameters, which are string converted prior to string appending them.
See also default value display-xml-warning
alternative value laml-error

15 Rendering functions and procedures.
The functions and procedures in this section transform the internal document representation (abstract syntax trees) to a textual form (text strings).

render-to-output-port
Form (render-to-output xml-clause output-port [prolog epilog])
Description Render the XML clause (an AST) to output-port. output-port is assumed to be open. output-port will not be closed by this procedure.
Parameters xml-clause an AST
output-port an open output port
prolog The symbol prolog, in which case (standard-prolog) is inserted, or a prolog string to be inserted
epilog The symbol epilog in which case (standard-epilog) is inserted, or a epilog string to be inserted
See also standard-prolog laml.scm
standard-epilog laml.scm

pretty-render-to-output-port
Form (pretty-render-to-output-port xml-clause output-port [prolog epilog])
Description Pretty print the XML clause (an AST) to output-port. output-port is assumed to be open. output-port will not be closed by this procedure. The constants preferred-maximum-width and indentation-delta affect the pretty printing.
Parameters xml-clause an AST
output-port an open output port
prolog The symbol prolog, in which case (standard-prolog) is inserted, or a prolog string to be inserted
epilog The symbol epilog in which case (standard-epilog) is inserted, or a epilog string to be inserted
See also standard-prolog laml.scm
standard-epilog laml.scm

xml-render
Form (xml-render xml-clause [prolog epilog])
Description Render the xml-clause (an LAML AST) and return the rendered string. In this context, rendering means linearization of the AST to its textual form.
Parameters xml-clause an AST
prolog The symbol prolog, in which case (standard-prolog) is inserted, or a prolog string to be inserted
epilog The symbol epilog in which case (standard-epilog) is inserted, or a epilog string to be inserted

pretty-xml-render
Form (pretty-xml-render xml-clause [prolog epilog])
Description Pretty print xml-clause (an LAML AST) and return the rendered string. In this context, rendering means linearization of the AST to its textual, pretty printed form. The constants preferred-maximum-width and indentation-delta affect the pretty printing.
Parameters xml-clause an AST
prolog The symbol prolog, in which case (standard-prolog) is inserted, or a prolog string to be inserted
epilog The symbol epilog in which case (standard-epilog) is inserted, or a epilog string to be inserted

16 Element related functions.
This section contains (mostly) higher-order functions that are related to the mirrors of the XML elements.

xml-modify-element
Form (xml-modify-element element . attributes-and-contents)
Description Bind some attributes content elements of element (the first parameter) and return a new, 'modified element function'. With this, some attributes and some content elements are pre-bound to certain values in the modified element. The parameter attributes-and-contents is of the same form as the parameters to a LAML surface mirror functions. In fact, attributes-and-contents is appended to the actual parameters, which are passed to the modified element function.
Returns an attribute-modified mirror function
Example
(define a-main (modify-element a 'target "main"))
See also similar function xml-modify-element-prepend

xml-modify-element-prepend
Form (xml-modify-element-prepend element . attributes-and-contents)
Description A function similar to xml-modify-element, but instead of appending attributes-and-contents to the actual parameters of the modified function, it prepends attributes-and-contents.
See also similar function xml-modify-element

17 XML in LAML parametrization and abstraction functions.
The functions in this category are higher-order functions which generate functions that obey XML-in-LAML parameter passing rules. In other words, the function that are generated use the same parameter conventions as the mirror functions of the HTML and XML elements.

xml-in-laml-parametrization
Form (xml-in-laml-parametrization f parameter-mediator [parameter-validator! f-name])
Description Generate a function with XML-in-LAML parameter passing rules which sends its input to an ordinary function, f, with positional parameters via a parameter mediator. The first parameter, f, is typically a web-related function with positional parameter correspondence (such as an existing, old-style 'conveninece function'). The parameter parameter-mediator is a function that generates a parameter list for f from content-list and the attributes property list, which is produced by the function xml-sort-tag-parameters. Thus, the parameter-mediator function translates the 'new parameter profile' to the 'old one', which is associated with f. The optional procedure parameter-validator! validates the contents-list and the attribute-list by reporting problems via xml-check-error. The optional f-name parameter is a string corresponding to the name of f (used for error message purposes only).
Parameters f An 'old style' fuction web function with positional parameters. Is applied on the result of parameter-mediator.
parameter-mediator a function of two parameters (contents-list and attribute property list) which transforms the new style parameters to the old style. f is applied on the output of parameter-mediator!
parameter-validator! a procedure of two parameters (contents-list and attribute property list) which validates the input of the generated function.
f-name The name of the generated function. Solely used for error message purposes.
See also applied function xml-sort-tag-parameters
similar function xml-in-laml-abstraction
useful par. validator required-implied-attributes
LAML tutorial Web authoring with higher-order functions
Note See the LAML tutorial referenced above for additional discussion and examples.

xml-in-laml-abstraction
Form (xml-in-laml-abstraction f [parameter-validator! f-name])
Description Generate a function with XML-in-LAML parameter passing rules, which passes its contents to the first parameter of f, and its attributes to the second parameter of f. The function f can call and XML-in-LAML mirror function, or another XML-in-LAML abstraction.
Parameters f A transformer function of two parameters - contents and the attribute property list. The generated function returns the value of f applied on contents and attributes.
parameter-validator! A checking procedure of two parameters - contents and the attribute property list. Must report errors explicitly by xml-check-error.
f-name The name of the abstraction - used for error message purposes only.
See also internally applied function xml-sort-superficially-tag-parameters
similar function xml-in-laml-parametrization
generalized function xml-in-laml-positional-abstraction
useful par. validator required-implied-attributes
LAML tutorial Web authoring with higher-order functions
Note See the LAML tutorial referenced above for additional discussion and examples.

xml-in-laml-positional-abstraction
Form (xml-in-laml-positional-abstraction n m f [parameter-validator! f-name])
Description Generate a function with XML-in-LAML parameter passing rules, together with a number of required parameters before and after the XML-in-LAML parameters.
Precondition n + m is less than or equal to the length of parameterlist of the generated function. (Condition checked by this function).
Parameters n The number of positional parameters before the XML-in-LAML parameter section.
m The number of positional parameters after the XML-in-LAML parameter section.
f A transformer function of n + 2 + m parameters. The two parameters in the middle are the contents and the attributes. The generated function returns the value of f applied on contents and attributes together with the positional parameters.
parameter-validator! A checking procedure of two parameters - contents and the attribute property list. Must report errors explicitly by xml-check-error. Cannot validate the positional parameters.
f-name The name of the abstraction - used for error message purposes only.
See also specialized function xml-in-laml-abstraction
useful par. validator required-implied-attributes

required-implied-attributes
Form (required-implied-attributes required-attribute-names implied-attribute-names [tag-name])
Description A higher-order function which returns an attribute checker. Report problems via xml-check-error. Check that all required-attribute-names are present and that the actual attributes are covered by required-attribute-names and implied-attribute-names together. The generated functions can be used as parameter valdiator procedures in xml-in-laml-abstraction and xml-in-laml-parametrization
Parameters required-attribute-names A list of attribute names (symbols) which are required.
implied-attribute-names A list of additional attribute names (symbols) which are allowed, or the list (*) - a singleton list with the symbol * - in the meaning of any attribute.
See also relevant context of use xml-in-laml-abstraction xml-in-laml-parametrization
error function xml-check-error

18 AST traversal and AST transformation functions.
The AST traversal functions extract information from AST by means of traversal and searching. The "find" functions use guided search, aided by the XML navigation information which is derived from the XML DTD. The "traverse-and-collect" functions are slightly more general (with a node-interesting? predicate), but they do not (and cannot) make use of the XML navigation information. Thus, these function do an exhaustive search.

find-asts
Form (find-asts ast el-name [ast-transformer])
Description Find and return a list of transformed sub ASTs of ast (first parameter) each with a root element of name el-name. The search is guided by the XML navigation information, hereby pruning the tree traversal. Apart from the pruning, the AST is traversed in pre-order. The transformation of the resulting sub-ASTS is done by the optional ast-transformer. If a sub-ast is returned as a part of the result then the sub-ast is not searched internally for recursive matches.
Parameters ast An AST.
el-name A name of an element in the language of ast (a string or symbol).
ast-transformer An optional AST transformation function, which defaults to the identity function id-1.
Returns A list of ASTs, each with element name el-name.
See also similar function traverse-and-collect-all-from-ast traverse-and-collect-first-from-ast find-first-ast
related functions traverse-and-collect-first-from-ast find-first-ast

find-first-ast
Form (find-first-ast ast el-name [ast-transformer])
Description Find and return a sub-AST of ast (first parameter) with a root element of name el-name. The search is guided by the XML navigation information, hereby pruning the tree traversal. Apart from the pruning, the AST is traversed in pre-order. When an appropriate sub-AST is found, the search is terminated. The transformation of the resulting sub-ASTS is done by the optional ast-transformer.
Parameters ast An AST.
el-name A name of an element in the language of ast (a string or symbol).
ast-transformer An optional AST transformation function, which defaults to the identity function id-1.
Returns An AST of with element-name el-name, else #f
See also similar function traverse-and-collect-first-from-ast
related functions traverse-and-collect-all-from-ast find-asts

unique-ast-attribute
Form (unique-ast-attribute ast name [default-attribute-value])
Description Return the value of the attribute name in ast, or in one of the subtrees of ast. If, from a static consideration, the attribute is not unique in ast, a fatal error occurs. The default attribute value is only applied if the attribute could occur, but if it does NOT in the actual AST. This function is useful for extraction of deep attributes given the fact that they only can occur once in the document, according to both the actual document structure and the statically extracted XML navigation information. The navigation towards a deep, unique attribute is efficient.
Precondition Statically, only one occurence of attr-name can appear in ast.
Parameters ast The AST in which to look for the attribute
name The name of the attribute (symbol or string)
default-attribute-value The default value, used if no attribute of name is found, but only if it is allowed to occur. A string.
See also related function ast-attribute

traverse-and-collect-all-from-ast
Form (traverse-and-collect-all-from-ast ast-tree node-interesting? ast-transformer)
Description Traverse all nodes of the AST ast-tree, and return transformed subtrees that satisfy the node-interesting? predicate. No traversal takes place inside subtrees that sastify the node-interesting? predicate. The transformation of the interesting subtree is done with ast-transformer (the third parameter). Non-AST constituents of the AST (CDATA and white space markers) are not visited during the traversal. The traversal is done in pre-order.
Parameters ast-tree The AST to be traversed.
node-interesting? The AST predicate that identifies the ASTs of interest.
ast-transformer The function which is applied on the ASTs identified by node-interesting?
Returns The mapping of the function ast-transformer on the list of interesting subtrees.
See also useful as parameter ast-of-type?
sibling function traverse-and-collect-first-from-ast
similar function find-asts
Note The higher-order function ast-of-type? generates useful node-interesting? functions.

traverse-and-collect-first-from-ast
Form (traverse-and-collect-first-from-ast ast-tree node-interesting? ast-transformer)
Description Traverse the AST ast-tree, and return a transformation of the first subtree which satisfies the predicate node-interesting. The transformation of the interesting subtree is done with ast-transformer (the third parameter). Non-AST constituents of the AST (CDATA and white space markers) are not visited during the traversal. The traversal is done in pre-order. Return #f in case no match is found. In fact, return the transformed AST, applying ast-transformer on the returned tree.
Parameters ast-tree The AST to be traversed.
node-interesting? The AST predicate that identifies the ASTs of interest.
ast-transformer The function which is applied on the ASTs identified by node-interesting?
Returns (ast-transformer TR), where TR is the first encounted tree matched by node-interesting? or #f if no tree is matched.
See also useful as parameter ast-of-type?
more restricted accessor ast-subtree
sibling function traverse-and-collect-all-from-ast
similar function find-first-ast
Note The higher-order function ast-of-type? generates useful node-interesting? functions.

transform-ast-list
Form (transform-ast-list input-list . transform-specs)
Description Apply the transformation-specs on input-list and return a list of transformed input elements. This function can, for instance, be applied on the subtree list of an AST. A single transformation spec is a list of two element: A predicate and a transformation function. A transformation function is applied if the corresponding predicate holds on the input element. If no predicate holds on an input element, the input element is returned without being transformed. No recursive transformations is done by this function.
Parameters input-list Each element in input-list can be an AST, a string, a character reference, or a white space related marker
transform-spec A list of transformation specifications, each of which is a list of length 2: (input-predicate transformation-function)
Returns A list of the same length of input-list. Some elements in the returned list are transformed as requested by transform-spec.
See also similar function transform-ast
related functions traverse-and-collect-all-from-ast traverse-and-collect-first-from-ast
usefully applied on results of ast-subtrees traverse-and-collect-all-from-ast
useful predicate generator ast-of-type?

transform-ast
Form (transform-ast ast . transform-specs)
Description Transform ast recursively by means of transform-specs. The parameter transform-specs is of the same kind as in the function transform-ast-list. During the transformation, AST nodes which are not matched by the transform-specs are copied. When some sub AST has been transformed, the transformed sub AST is not recursively transformed.
Parameters ast The data to be transformed. Either an AST, textual contents, or a white space marker.
transform-spec A list of transformation specifications, each of which is a list of length 2: (input-predicate transformation-function)
Returns The transformed AST.
See also similar function transform-ast-list
useful predicate generator ast-of-type?

19 XML validation procedures.
The functions in this section provide access to the XML-in-LAML validation procedures. The validation functions are part of the mirrors of a given XML language in Scheme. In normal and native use of XML-in-LAML, the validation procedures are called by the mirror functions. If the internal AST structure is created by other means (for instance authored directly, or made via a parser) it is relevant to get access to the validation procedures. This is the rationale behind the functions in this section.

validation-procedure-map-of
Form (validation-procedure-map-of language)
Description A validation procedure map of an XML language is a sorted, associative vector that maps element names to XML validation procedures. The validation procedures are produced by the XML-in-LAML mirror generation tool. This function returns the sorted associative vector of language. If no validation procedure map exists for language, this function returns false.
Parameters language The name of the language (string or symbol)

validation-procedure-of
Form (validation-procedure-of element-name language)
Description Return the XML validation procedure of the element named element-name in language. A validation procedure is created by the XML-in-LAML mirror generation tool on basis of an XML DTD of language. A validation procedure takes four parameters: element-name (string), attributes (property list), element content item list, and a boolean (XML language overlap check or not). If language does not make sense, or if the element is unknown in the map, return #f
Parameters element-name The name of the element (string or symbol)
language The name of the language (string or symbol)

register-xml-in-laml-validators
Form (register-xml-in-laml-validators language validator-structure)
Description Register validator-structure for language. This function is called "automatically" when the mirror functions are loaded.

validate-ast!
Form (validate-ast! ast [given-language language-overlap-check?])
Description Validate ast. XML validation is integrated in the mirrors of the XML elements in Scheme. Thus, this procedure is only useful if the AST is created by other means (manually, or via a parser, for instance). Validation problems are reported by the procedure xml-check-error. This is a procedure that produces errors or warnings (depending on xml-check-error). The ast is valid if no error messages or warnings are produced by this function.
Parameters ast The internal representation of the document to be checked
given-language The XML language to which ast belongs. Defaults to (ast-language ast). A symbol.
language-overlap-check? Check for mutual naming overlap among the loaded XML languages. A boolean. Defaults to #t.
See also error function xml-check-error

20 Element content models.
The functions in this section make the content models of the XML elements available. As an example, this allows us to find out if an element is empty. The element content models are defined by the XML DTDs, and as such they are used for generation of the XML validation procedures.

content-model-map-of
Form (content-model-map-of language)
Description Returns the content model map (an association list) of a given XML language. A content model map of an XML language is an sorted associative vector that maps element names (strings) to the parsed content models of the element, as provided by the the LAML XML-DTD parser.

content-model-of
Form (content-model-of element-name language)
Description Return the content model of the element named element-name in XML language. The content model is the parsed content model, as delivered by the LAML XML-DTD parser. If the content model is not available for some reason (unknown element-name, unknown XML language) return #f.

register-xml-in-laml-content-models
Form (register-xml-in-laml-content-models language content-model-structure)
Description Register the content model structure for XML language. This function is called "automatically" when the Scheme mirror of the XML language is loaded.

21 Action procedure map.
An action procedure map is a sorted associative vector that maps certain element names to action procedures.

action-procedure-map-of
Form (action-procedure-map-of language)
Description Return the action procedure map of the XML language.

action-procedure-of-language
Form (action-procedure-of-language element-name language)
Description Return the action procedure of the XML element named element-name in the XML language. If there is no action procedure associated with the element, or if the action procedure structure is not available for language, return #f.

action-procedure-of-map
Form (action-procedure-of-map element-name action-procedure-map)
Description Return the action procedure of the XML element named element-name relative to the action procedure map action-procedure-map.

register-xml-in-laml-action-procedures
Form (register-xml-in-laml-action-procedures language action-procedure-structure)
Description Register the action procedure structure for XML language. An action procedure structure is a sorted, associative vector that maps XML elements (stings) to their action procedures. Notice that this is only a partial mapping. This function is called "automatically" when the Scheme mirror of the XML language is loaded.

process-ast!
Form (process-ast! ast [given-language action-map])
Description Process the ast, the internal document representation, by means of the action procedures in action-map. The action map is a sorted associative vector that maps element names to action procedures. The default value of action-map is (action-procedure-map-of given-language).
Parameters ast The internal representation of the document to be processed.
given-language The language to which ast belongs. Bound at root level. Defaults to (ast-language ast). A symbol.
action-map The action map that maps elements in the XML language to action procedure. Defaults to (action-procedure-map-of given-language). A sorted associative vector.
See also action procedure access action-procedure-map-of

22 Other useful functions.
In this section there are non-mirror functions which are useful in in the context of XML and LAML.

ast-to-parse-tree
Form (ast-to-parse-tree ast)
Description Convert an abtract syntax tree to a parse tree. Abstract syntax trees are produced by the validating mirror functions. Parse trees are used as an internal format in the HTML and the XML pretty printing procedures. You can use the function pretty-print-html-parse-tree on the parse tree returned by ast-to-parse-tree.
Precondition The LAML tool html-support (for parsing and pretty printing) must be loaded for this function to work.
Note To load html-support: (laml-tool-load "xml-html-support/html-support.scm")


Generated: July 9, 2004, 14:31:37
Generated by LAML SchemeDoc .