Generated: Monday, November 14, 2011, 09:18:51 Copyright © 2011 , Kurt Nørmark The local LAML software home page

Reference Manual of the XML-in-LAML library

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

LAML Source file: lib/xml-in-laml/xml-in-laml.scm

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, XHTML1.1, SVG 1.1, LENO, and other similar mirrors.

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

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.

This library is also designed to co-exists with non-validating HTML mirrors, such as Html4.0 (mainly the sake of LENO). However, it cannot be used together with other validating AST-based HTML mirrors, such as Html4.01 transitional validating. You should use a 100% XML-IN-LAML solution instead. 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.

Table of Contents:
1. XML front matters and end matters stuff. 11. XML Processing Instructions. 21. Rendering functions and procedures.
2. XML-in-LAML processing parameters. 12. XML Language Bookkeeping. 22. Element related functions.
3. Other Constants. 13. The Language Map. 23. XML in LAML abstraction functions.
4. AST constructors and basic selector selectors. 14. XML Navigation Information. 24. AST traversal and AST transformation functions.
5. High-level AST selector functions. 15. Mirror Generation Functions. 25. LAML location path and steps.
6. AST Mutators. 16. Contents Validation. 26. Element content models.
7. XML-in-LAML Predicates. 17. Attribute Checking. 27. Action procedure map.
8. Character Entities. 18. Link Checking. 28. Expansion of delayed procedural content items.
9. XML Comments. 19. XML validation procedures. 29. Other useful functions.
10. XML CDATA Sections. 20. XML warning procedures.

Alphabetic index:
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.
activator-via-language-map (activator-via-language-map language) Return an activator function for language.
and-steps (and-steps . location-step-procedure-list) A higher-order function that conjuncts (ands) some location steps to a single location step.
apply-transformation-on (apply-transformation-on source-items) Do recursive transformation on a content source item, or a list of content source items (such as an AST, or a list of ASTs).
ast-attribute (ast-attribute ast name [default-attribute-value]) Return the value of the attribute name in ast, or #f if no such attribute exists.
ast-attributes (ast-attributes ast) Return the list of attributes of the ast.
ast-copy (ast-copy ast) Return a copy of ast.
ast-element-name (ast-element-name ast) Return the root element name of ast.
ast-internal-attribute (ast-internal-attribute ast name [default-attribute-value]) Return the value of the internal attribute name in ast, or #f if the internal attribute does not exist.
ast-internal-attributes (ast-internal-attributes ast) Return the list of internal attributes of the ast.
ast-kind (ast-kind ast) Return the kind of the ast.
ast-language (ast-language ast) Return the language of the ast.
ast-node (ast-node) Generates a location step that tests for x being a node.
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-text-containing (ast-text-containing str) Generates a location step that test if str is part of the immediate textual content.
ast-text-deep (ast-text-deep ast) Return a string of the aggregated CDATA contents of ast.
ast-text-deep-containing (ast-text-deep-containing str) Generates a location step that tests if str is part of the deep textual content.
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.
base-url-extractor-of-xml-language (base-url-extractor-of-xml-language xml-language) Return the registered base-url-extractor function of xml-language.
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-section (cdata-section . cdata-text-list) Construct an XML CDATA section and return it.
cdata-section-contents (cdata-section-contents cdata-section) Return the cdata text of an XML comment.
cdata-section? (cdata-section? x) Is x an XML CDATA section?
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.
check-absolute-url-list! (check-absolute-url-list! absolute-urls) Checks the existense of the resources addressed by the urls in absoute-urls.
check-id-and-idref-attributes! (check-id-and-idref-attributes!) Check that the ID and IDREF attribute values are used according to the XML 1.0 specification.
check-relative-url-list! (check-relative-url-list! relative-urls) Checks the existense of the resources addressed by the urls in relative-urls Some of the elements may be boolean #f, which signals that they should not be checked.
collect-links-for-later-checking-in-ast! (collect-links-for-later-checking-in-ast! xml-ast absolute-target-html-file) Collect the urls in xml-ast, which are about to be written to the file absolute-target-html-file (full path).
compact-end-tag-rendering? compact-end-tag-rendering? A boolean variable that controls how end tags are rendered when pretty printing is applied.
compose-steps (compose-steps . location-step-procedure-list) Compose the locatation steps in location-step-procedure-list to a single location step.
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-strong? (contents-data-strong? x [language]) Is the parameter x a contents element item, with ASTs recognized in the strong form (using ast-strong?)
contents-data? (contents-data? x [language]) Is the parameter x a contents element item.
copy-ast-mutate-attributes (copy-ast-mutate-attributes ast . new-attributes) Shallow copy ast and replace selected attributes of ast with new attributes.
delayed-procedural-contents-element? (delayed-procedural-contents-element? x) Is x a delayed procedural content element?
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.
end-laml (end-laml) A redefinition of end-laml from the fundamental LAML library.
end-tag-of (end-tag-of xml-clause) Render the end-tag of xml-clause (a LAML AST) and return the rendered string.
expand-procedural-content-items-in-ast (expand-procedural-content-items-in-ast ast) Expand all delayed procedural content items (recursively) inside the ast.
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.
extraordinary-allow-element? (extraordinary-allow-element? element-name context-element-name) Is element-name extraordinarily allowed within context-element-name (both symbols).
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.
free-double-element (free-double-element element-name) Generates a function that returns a potentially non-standard double AST for element-name in xml-language.
free-single-element (free-single-element element-name) Generates a function that returns a potentially non-standard single AST for element-name in xml-language.
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.
has-ast-attribute? (has-ast-attribute? ast name) Return if the ast has a name attribute
has-internal-ast-attribute? (has-internal-ast-attribute? ast name) Does the internal ast attribute called name exist?
has-procedural-content-items-deep? (has-procedural-content-items-deep? ast) Is there any procedure content items in ast.
has-procedural-content-items? (has-procedural-content-items? x) Is there any procedure content items among the immediate constituents of x (usually an AST).
identifier-of-predicate (identifier-of-predicate p) Return the identifier function of the predicate p.
indentation-delta indentation-delta An integer which gives the level of indentation for pretty printed output.
laml-character-encoding laml-character-encoding The character encoding used together with XML in LAML.
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.
laml-xml-version laml-xml-version The version of XML used together with LAML.
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.
location-step (location-step axis [node-test filtering]) Generates and returns a location step procedure for a given axis, name, and filtering.
make-ast (make-ast element-name contents attributes kind language [internal-attributes]) Make an AST given element-name, contents, a property list of attributes, a kind (single/double), and an XML language name.
match-ast (match-ast ast . locator-list) Apply each function in locator-list sequentially on the list of ASTs resulting from previous location step.
negate-step (negate-step location-step-procedure) A higher-order function that negates a single location-step procedure.
nt:attribute (nt:attribute name value) A filtering function that tests if the node has an attribute name with the given value.
nt:child-name (nt:child-name name) A filtering function that tests if the node has name.
nt:child-number (nt:child-number q) A filtering function that tests if the node is number q in its context.
nt:for-which (nt:for-which . location-steps) A filtering function which test if the list of location steps leads success (leads to a non-empty result).
nt:for-which-predidate-holds (nt:for-which-predidate-holds pred . location-steps) A filtering function which applies a list of location steps on the node, a passes the results of these steps to the predicate pred.
nt:last (nt:last) A filtering function that tests if the node is the last in its context.
or-steps (or-steps . location-step-procedure-list) A higher-order function that disjuncts (ors) some location steps to a single location step.
positive-to-negative-ast-spacing (positive-to-negative-ast-spacing ast) Given an AST with positive white spacing (such as an AST returned by mirror function).
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 (a 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.
processing-instruction (processing-instruction pi-target . text-list) Construct an XML processing instruction and return it.
processing-instruction-contents (processing-instruction-contents pi) Return the processing instruction text part of the processing instruction pi.
processing-instruction-target (processing-instruction-target pi) Return the processing instruction pi-target of the processing instruction pi.
processing-instruction? (processing-instruction? x) Is x an XML processing instruction?
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.
remove-ast-attribute! (remove-ast-attribute! ast name) Remove the attribute name and its value from the attribute list of ast.
remove-ast-attributes! (remove-ast-attributes! ast name-list) Remove all the attributes in name-list and their values from the attribute list of ast.
remove-internal-ast-attribute! (remove-internal-ast-attribute! ast name) Remove the internal attribute name and its value from the internal attribute list of ast.
render-as-laml-string (render-as-laml-new xml-clause [prolog epilog]) Render the xml-clause (a LAML AST) as a (non-pretty printed) LAML source text to output-port and return the rendered string.
render-as-laml-to-output-port (render-as-laml-to-output xml-clause output-port) Render the XML clause (an AST) as a (non-pretty printed) LAML source text to output-port.
render-end-tag-to-output-port (render-end-tag-to-output-port xml-clause output-port) Render the end-tag of xml-clause (a LAML AST) and return the rendered string.
render-start-tag-to-output-port (render-start-tag-to-output-port xml-clause output-port) Render the start-tag of xml-clause (a LAML AST) to output-port.
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.
selected-internal-attributes (selected-internal-attributes ast prefix) Return those of the internal attributes of ast whose attribute name are prefixed with prefix.
set-ast-attribute! (set-ast-attribute! ast name value) Mutate the value of the ast attribute name to value.
set-ast-attributes! (set-ast-attributes! ast prop-list) Replace the attributes of ast with the attributes in prop-list (a property list).
set-internal-ast-attribute! (set-internal-ast-attribute! ast name value) Mutate the value of the internal ast attribute name to value.
set-internal-ast-attributes! (set-internal-ast-attributes! ast prop-list) Replace the internal attributes of ast with the attributes in prop-list (a property list).
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-link-checking-functions (set-xml-link-checking-functions xml-language url-extractor-function base-url-extractor-function) Register url-extractor-function and base-url-extractor-function in the XML link checking map of xml-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.
start-tag-of (start-tag-of xml-clause) Render the start-tag of xml-clause (a LAML AST) and return the rendered string.
terminal-ast-node? (terminal-ast-node? x) Is x an ast nodes without subtrees?
transform-ast (transform-ast transform-specs source-items) Transform source item(s) 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.
url-extractor-of-xml-language (url-extractor-of-xml-language xml-language) Return the registered url-extractor function of xml-language.
use-empty-tags-for-elements-without-contents use-empty-tags-for-elements-without-contents A boolean variable that controls how elements without contents are rendered.
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 finte 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.
with-xml-language (with-xml-languge language-name . forms) A macro which globally establishes the name bindings of xml-language and evaluate forms in this state.
with-xml-language! (with-xml-languge! language-name minus-elements . forms) A macro which globally establishes the name bindings of xml-language and evaluate forms in this state.
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-comment (xml-comment . comment-text-list) Construct an XML comment and return it.
xml-comment-contents (xml-comment-contents xml-comment) Return the comment text of an XML comment.
xml-comment? (xml-comment? x) Is x an XML comment?
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-duplicated-attribute-handling (xml-duplicated-attribute-handling language) This value controls the handling of attributes that occur more than once in an XML attribute list.
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 language]) 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 language]) 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 language]) 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-link-checking xml-link-checking Defines the amount of link checing that is to be carried out by LAML.
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 (a LAML AST) and return the rendered string.
xml-render-as-laml (xml-render-as-laml contents) An rendering function which delivers a source-like Scheme expression as result (as a text string).
xml-render-as-simple-text (xml-render-as-simple-text contents) Pure textual rendering of contents.
xml-render-cdata-section (xml-render-cdata-section cdata-section) Render the cdata section with space in between the individual cdata text elements.
xml-render-processing-instruction (xml-render-processing-instruction pi) Render the processing instruction pi.
xml-render-xml-comment (xml-render-xml-comment xml-comment) Render the xml-comment with space in between the individual comment text elements.
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-root-node xml-root-node The XML root node, used to determine some of the reverse axes.
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.
_ _ The symbolic name of explicit white space suppress.


1 XML front matters and end matters stuff.
This section contains the XML declaration and other XML front matter stuff. In addition it holds the end-laml function.

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 Scheme source file standard-prolog
applied function xml-declaration
applied function xml-document-type-declaration-in
applied function copyright-clause

laml-xml-version
Form laml-xml-version
Description The version of XML used together with LAML. A string.
See also Scheme source file laml-xml-version

laml-character-encoding
Form laml-character-encoding
Description The character encoding used together with XML in LAML. Goes into the xml declaration. A string.
See also Scheme source file laml-character-encoding

xml-declaration
Form (xml-declaration)
Description Return the xml declaration
See also Scheme source file xml-declaration

end-laml
Form (end-laml)
Description A redefinition of end-laml from the fundamental LAML library. This redefined function calls the function check-id-and-idref-attributes!, which reports on possible violations of ID and IDREF(S) attribute constraints. It also checks relative and absolute links, if desired. Calls the original end-laml function as the last action.
See also Scheme source file end-laml
original end-laml laml.scm
ID and IDREF check function check-id-and-idref-attributes!
Control of link checking xml-link-checking


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.
See also Scheme source file laml-internal-representation

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.
See also Scheme source file xml-check-attributes?

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.
See also Scheme source file xml-validate-contents?

xml-link-checking
Form xml-link-checking
Description Defines the amount of link checing that is to be carried out by LAML. Possible values are none, relative-urls, absolute-urls, and all (symbols), none: No link checking is done at alle. relative-urls: Only relative urls are checked. absolute-urls: Only absolute urls are checked. This includes URLs that are formed relative to a given base-url. all: All URLs, both absolute and relative, are checked. The default value is relative-urls. The use of the value all requires that url-target-exists? target is implemented. In the current version of LAML, url-target-exists? is only implemented when LAML is used with MzScheme (via the lib/url-read.scm).
See also Scheme source file xml-link-checking
link checking functions collect-links-for-later-checking-in-ast! check-relative-url-list! check-absolute-url-list!
About link checking in LAML Note

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 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.
See also Scheme source file xml-check-language-overlap?

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 Scheme source file xml-transliterate-character-data-in?
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 Scheme source file set-xml-transliterate-character-data-in
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
Internal remark 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 Scheme source file xml-char-transformation-table-in
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 Scheme source file set-xml-char-transformation-table-in
table getter xml-char-transformation-table-in
exceptions xml-non-transliteration-elements-in
transformation table laml.scm
Internal remark 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 Scheme source file xml-non-transliteration-elements-in
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.
See also Scheme source file xml-preformatted-text-elements-in

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.
See also Scheme source file xml-error-truncation-length

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 Scheme source file xml-pass-default-dtd-attributes-in?
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). If this function returns #t, only strings are allowed as attribute values. If it returns #f, LAML will attempt to convert the attribute value to a string using the function as-string. (Certain lists, which internally represents ASTs etc) are not converted, however). If no language information is present (i.e., if the language parameter is #f) always return #t.
Parameters language The name of an XML language (a symbol)
See also Scheme source file xml-accept-only-string-valued-attributes-in?
setter set-xml-accept-only-string-valued-attributes-in
Note The default value returned by this function is defined as a parameter of the mirror generation script.

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 Scheme source file set-xml-accept-only-string-valued-attributes-in
getter xml-accept-only-string-valued-attributes-in?
Note Overwrites the default value, as defined by mirror generation script.
Internal remark 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.
Parameters language The name of an XML language (a symbol)
See also Scheme source file xml-accept-extended-contents-in?
setter set-xml-accept-extended-contents-in
Note The default value returned by this function is defined as a parameter of the mirror generation script.

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 Scheme source file set-xml-accept-extended-contents-in
getter xml-accept-extended-contents-in?
Note Overwrites the default value, as defined by mirror generation script.

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.
See also Scheme source file xml-document-type-declaration-in

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.
See also Scheme source file xml-represent-white-space-in?

xml-duplicated-attribute-handling
Form (xml-duplicated-attribute-handling language)
Description This value controls the handling of attributes that occur more than once in an XML attribute list. If the function returns keep-all, the attribute list is not affected at all; All attributes are passed to the application. If the function returns keep-first, only the first attribute name/value pair is passed for further processing, and only the first is passed on to the validation procedure. If the function returns keep-last, only the last attribute name/value pair is passed for further processing, and only the last is passed on to the validation procedure. The value of this function is locked and bound at mirror generation time.
Returns either keep-all, keep-first, keep-last (a symbol)
See also Scheme source file xml-duplicated-attribute-handling

set-xml-link-checking-functions
Form (set-xml-link-checking-functions xml-language url-extractor-function base-url-extractor-function)
Description Register url-extractor-function and base-url-extractor-function in the XML link checking map of xml-language. The XML link checking map maps an XML language name to a list of two functions: url-extractor-function base-url-extractor-function. The url-extractor-function can be applied on an XML AST in order to deliver a list of URLs that appear in that language. The base-url-extractor-function can also be applied on an XML AST. It delivers a possible base url (for use when resolving relative URLs) of the AST, of #f in no such base URL occurs.
Parameters xml-language The name of the XML language (a symbol).
url-extractor-function A URL extraction function (takes an AST parameter), or #f if no such function is provided.
base-url-extractor-function A base URL extraction function (takes an AST parameter), or #f if no such function is provided.
See also Scheme source file set-xml-link-checking-functions

url-extractor-of-xml-language
Form (url-extractor-of-xml-language xml-language)
Description Return the registered url-extractor function of xml-language. The url-extractor function can be applied on an XML-ast and it delivers a list of URLs that occur in the AST.
See also Scheme source file url-extractor-of-xml-language
applied by collect-links-for-later-checking-in-ast!
About link checking in LAML Note

base-url-extractor-of-xml-language
Form (base-url-extractor-of-xml-language xml-language)
Description Return the registered base-url-extractor function of xml-language. The base-url-extractor function can be applied on an XML-ast and it delivers a possible base url (for use when resolving relative URLs) in the AST.
See also Scheme source file base-url-extractor-of-xml-language
applied by collect-links-for-later-checking-in-ast!
About link checking in LAML Note


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.
See also Scheme source file explicit-space

explicit-space-suppress
Form explicit-space-suppress
Description The explicit white space suppress value. The default value is boolean #f.
See also Scheme source file explicit-space-suppress

_
Form _
Description The symbolic name of explicit white space suppress.
Examples (ast-text (a 'href "some-url" 'target "some-target" "anchor" _ "text")) => "anchortext"
(white-space-suppress? _) => #t
(white-space-related? _) => #t
(xml-sort-tag-parameters (list "this" _ "is" 'href "url" "end") "a" 'xhtml10-transitional) => (("this" "is" #t "end") href "url")
(xml-sort-superficially-tag-parameters (list "this" _ "is" 'href "url" "end") "a" 'xhtml10-transitional) => (("this" #f "is" #t "end") href "url")
See also Scheme source file _

preferred-maximum-width
Form preferred-maximum-width
Description An integer that expresses the prefered maximum column width for pretty printed ouput.
See also Scheme source file preferred-maximum-width

indentation-delta
Form indentation-delta
Description An integer which gives the level of indentation for pretty printed output.
See also Scheme source file indentation-delta

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 Scheme source file xml-always-render-white-space?
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. An AST copy function is also included in this section. 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 (make-ast element-name contents attributes kind language [internal-attributes])
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?, forced-white-space?, delayed-procedural-contents-element?, char-ref?, xml-comment?, cdata-section?, or processing-instruction? 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 XML attributes represented as a property list.
kind The symbol double or single. The kind single represents empty XML elements.
language A symbol or string that represent the XML-in-LAML language name.
internal-attributes A collection of internal attributes represented as a property list. Internal attributes can be used as arbitrary annotations of an XML document. Internal attributes do not affect the document rendering. Use internal attributes for AST annotations that cannot easily be made via use of XML attributes.
See also Scheme source file make-ast

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
Examples (ast-element-name (html (head (title "ttt")) (body (p "ppp")))) => "html"
See also Scheme source file ast-element-name

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
Examples (ast-subtrees (html (head (title "ttt")) (body (p "ppp")))) => ((ast "head" ((ast "title" ("ttt") () double xhtml10-transitional ())) () double xhtml10-transitional ()) #t (ast "body" ((ast "p" ("ppp") () double xhtml10-transitional ())) () double xhtml10-transitional ()))
See also Scheme source file ast-subtrees
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.
Examples (ast-attributes (html (head (title "ttt")) (body (p "ppp")))) => ()
(ast-attributes (a 'href "some-url" 'target "some-target" "anchor")) => (href "some-url" target "some-target")
See also Scheme source file ast-attributes
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
Examples (ast-kind (br)) => single
(ast-kind (a 'href "some-url" 'target "some-target" "anchor")) => double
See also Scheme source file ast-kind

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
Examples (ast-language (html (head (title "ttt")) (body (p "ppp")))) => xhtml10-transitional
See also Scheme source file ast-language

ast-internal-attributes
Form (ast-internal-attributes ast)
Description Return the list of internal attributes of the ast. These are non XML attributes which can annotate the ast.
Precondition ast is an abstract syntax tree that satisfies the ast? predicate
Returns The list of internal attributes, as a property list.
Examples (ast-internal-attributes (html (head (title "ttt")) (body (p "ppp")))) => ()
See also Scheme source file ast-internal-attributes
internal attribute mutators ast-mutators
convenient accessors ast-internal-attribute has-internal-ast-attribute?

ast-copy
Form (ast-copy ast)
Description Return a copy of ast. This involves a shallow copy of both the attribute list and the internal attribute list. Strings constituents are not copied. If the parameter, ast, happens not to an AST, just return it uncopied.
See also Scheme source file ast-copy
Similar Function copy-ast-mutate-attributes

free-single-element
Form (free-single-element element-name)
Description Generates a function that returns a potentially non-standard single AST for element-name in xml-language. The generated function disregards any document contents; It only passes the attributes to make-ast. The generated function obeys XML-in-LAML parameter passing conventions. The first parameter of the generated function is the name of the xml language (a symbol).
Parameters element-name The name of the new element. A string.
See also Scheme source file free-single-element
Note Intended for ad hoc definition of a non-standard element in an XML language, such as embed in XHTML.

free-double-element
Form (free-double-element element-name)
Description Generates a function that returns a potentially non-standard double AST for element-name in xml-language. The generated function obeys XML-in-LAML parameter passing conventions. The first parameter of the generated function is the name of the xml language (a symbol).
Parameters element-name The name of the new element. A string.
See also Scheme source file free-double-element


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
Examples (ast-subtree (html (head (title "ttt")) (body (p "ppp"))) "head") => (ast "head" ((ast "title" ("ttt") () double xhtml10-transitional ())) () double xhtml10-transitional ())
(ast-subtree (html (head (title "ttt")) (body (p "ppp"))) "body") => (ast "body" ((ast "p" ("ppp") () double xhtml10-transitional ())) () double xhtml10-transitional ())
(ast-subtree (html (head (title "ttt")) (body (p "ppp"))) "title") => #f
See also Scheme source file ast-subtree
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, or #f if no such attribute exists. Only the 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.
Examples (ast-attribute (a 'href "some-url" 'target "some-target" "anchor") 'href) => "some-url"
(ast-attribute (a 'href "some-url" 'target "some-target" "anchor") 'target) => "some-target"
See also Scheme source file ast-attribute
basic selector ast-attributes
related function unique-ast-attribute

has-ast-attribute?
Form (has-ast-attribute? ast name)
Description Return if the ast has a name attribute
See also Scheme source file has-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.
Examples ((attribute-getter 'href) (a 'href "some-url" 'target "some-target" "anchor")) => "some-url"
See also Scheme source file attribute-getter
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 do not contribute in this aggregation.
Returns The immediate aggregated textual contents of ast. Returns the empty string, in case there is no contents.
Examples (ast-text (a 'href "some-url" 'target "some-target" "anchor" _ "text")) => "anchortext"
(ast-text (a 'href "some-url" 'target "some-target" "anchor" "text")) => "anchor text"
See also Scheme source file ast-text

ast-text-deep
Form (ast-text-deep ast)
Description Return a string of the aggregated CDATA contents of ast. Ast subtrees of ast contribute recursively in this aggregation. White space markers are also taken into account.
Returns The full aggregated textual contents of ast. Returns the empty string, in case there is no contents.
Examples (ast-text-deep (html (head (title "ttt")) (body (p "ppp")))) => "ttt ppp"
See also Scheme source file ast-text-deep

ast-internal-attribute
Form (ast-internal-attribute ast name [default-attribute-value])
Description Return the value of the internal attribute name in ast, or #f if the internal attribute does not exist. This function is a convenient shortcut of (defauted-get-prop name (ast-internal-attributes ast) default-value). The optional parameter serves as the internal attribute value in case no name attribute is found in the attribute list of ast.
Parameters ast An AST.
name The name of an internal attribute (a symbol).
default-attribute-value The default value, used if no attribute of name is found. Of arbitrary type.
Examples (ast-internal-attribute (a 'href "some-url" 'target "some-target" "anchor") 'href) => #f
See also Scheme source file ast-internal-attribute
basic selector ast-internal-attributes
internal attribute mutators ast-mutators

has-internal-ast-attribute?
Form (has-internal-ast-attribute? ast name)
Description Does the internal ast attribute called name exist?
Returns A boolean answer (#t or #f).
Examples (has-internal-ast-attribute? (a 'href "some-url" 'target "some-target" "anchor") 'href) => #f
See also Scheme source file has-internal-ast-attribute?
basic selector ast-internal-attributes
internal attribute mutators ast-mutators

selected-internal-attributes
Form (selected-internal-attributes ast prefix)
Description Return those of the internal attributes of ast whose attribute name are prefixed with prefix. The attribute names are truncated, by removing the prefix from them. (This may lead to empty attribut names in case some attribute names are equal to prefix). This function is convenient if you need to extract a subset of systematically prefixed internal attributes and pass the non-prefixed attributes on to another function.
Parameters ast An AST.
prefix A string.
Returns A property list of attributes. The prefix has been romoved from the attribute names.
See also Scheme source file selected-internal-attributes


6 AST Mutators.
Both the attributes and the internal attributes of an AST can be mutated imperatively. In this section you will find procedures for attribute mutation. The name of the procedures include an exclamation mark to emphasize their imperative nature. Don't use them if you do not really need them! In addition we provide a functional attribute mutator called copy-ast-mutate-attributes.

copy-ast-mutate-attributes
Form (copy-ast-mutate-attributes ast . new-attributes)
Description Shallow copy ast and replace selected attributes of ast with new attributes. If the attributes in new-attributes do not exist in ast, the new attributes are just added. Only one AST node is copied by this function.
Parameters ast An AST
new-attributes A property list of attributes which should replace existing attributes of ast.
Returns A copy of AST in which the attributes in new-attributes replaces attributes in the original AST.
Examples (copy-ast-mutate-attributes (a 'href "url" 'target "target") 'href "111" 'target "222" 'xxx "333") => (ast "a" () (href "111" target "222" xxx "333") double xhtml10-transitional ())
(copy-ast-mutate-attributes (a 'href "url" 'target "target") 'href "111") => (ast "a" () (href "111" target "target") double xhtml10-transitional ())
(copy-ast-mutate-attributes (a 'href "url" 'target "target")) => (ast "a" () (href "url" target "target") double xhtml10-transitional ())
See also Scheme source file copy-ast-mutate-attributes
Similar Function ast-copy

set-internal-ast-attributes!
Form (set-internal-ast-attributes! ast prop-list)
Description Replace the internal attributes of ast with the attributes in prop-list (a property list). Using this procedure, all existing internal attributes are replaced by a new set of attributes. A procedure, not a function.
See also Scheme source file set-internal-ast-attributes!

set-ast-attributes!
Form (set-ast-attributes! ast prop-list)
Description Replace the attributes of ast with the attributes in prop-list (a property list). Using this procedure, all existing attributes are replaced by a new set of attributes. A procedure, not a function.
See also Scheme source file set-ast-attributes!

set-ast-attribute!
Form (set-ast-attribute! ast name value)
Description Mutate the value of the ast attribute name to value. If name does not exist as an attribute of ast, this function inserts the attribute in the attribute list (as the first key value pair).
See also Scheme source file set-ast-attribute!

set-internal-ast-attribute!
Form (set-internal-ast-attribute! ast name value)
Description Mutate the value of the internal ast attribute name to value. If name does not exist as an internal attribute of ast, this function inserts the attribute in the internal attribute list (as the first key value pair).
See also Scheme source file set-internal-ast-attribute!

remove-internal-ast-attribute!
Form (remove-internal-ast-attribute! ast name)
Description Remove the internal attribute name and its value from the internal attribute list of ast. If the attribute called name exists more than once in ast, remove them all.
See also Scheme source file remove-internal-ast-attribute!

remove-ast-attribute!
Form (remove-ast-attribute! ast name)
Description Remove the attribute name and its value from the attribute list of ast. If the attribute called name exists more than once in ast, remove them all.
See also Scheme source file remove-ast-attribute!

remove-ast-attributes!
Form (remove-ast-attributes! ast name-list)
Description Remove all the attributes in name-list and their values from the attribute list of ast. If an attribute in name-list exists more than once in ast, remove them all.
See also Scheme source file remove-ast-attributes!


7 XML-in-LAML 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.
Examples (ast? "txt") => #f
(ast? (a 'href "some-url" 'target "some-target" "anchor")) => #t
See also Scheme source file 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.
Examples (ast-strong? (a 'href "some-url" 'target "some-target" "anchor")) => #t
(ast-strong? "txt") => #f
See also Scheme source file ast-strong?

cdata?
Form (cdata? x)
Description Is the parameter x CDATA
Examples (cdata? "txt") => #t
See also Scheme source file 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.
Examples (contents-data? "txt") => #t
(contents-data? (a 'href "some-url" 'target "some-target" "anchor")) => #t
(contents-data? 5) => #f
(contents-data? #\5) => #f
See also Scheme source file contents-data?

contents-data-strong?
Form (contents-data-strong? x [language])
Description Is the parameter x a contents element item, with ASTs recognized in the strong form (using ast-strong?)
See also Scheme source file contents-data-strong?
strong ASTs ast-strong?

delayed-procedural-contents-element?
Form (delayed-procedural-contents-element? x)
Description Is x a delayed procedural content element?
See also Scheme source file delayed-procedural-contents-element?

char-ref?
Form (char-ref? x)
Description Is x a character reference.
Examples (char-ref? (char-ref 5)) => #t
(char-ref? (char-ref 169)) => #t
(char-ref? (char-ref "copy")) => #t
See also Scheme source file char-ref?

forced-white-space?
Form (forced-white-space? x)
Description Is the parameter x a white space mark.
Examples (forced-white-space? " ") => #f
(forced-white-space? #t) => #t
(forced-white-space? #f) => #f
See also Scheme source file forced-white-space?

white-space-suppress?
Form (white-space-suppress? x)
Description Is the parameter x a white suppress space mark.
Examples (white-space-suppress? _) => #t
(white-space-suppress? #f) => #t
(white-space-suppress? #t) => #f
See also Scheme source file white-space-suppress?

white-space-related?
Form (white-space-related? x)
Description Is the parameter x white space related?
Examples (white-space-related? _) => #t
(white-space-related? #f) => #t
(white-space-related? #t) => #t
(white-space-related? " ") => #f
See also Scheme source file white-space-related?

terminal-ast-node?
Form (terminal-ast-node? x)
Description Is x an ast nodes without subtrees?
Examples (terminal-ast-node? (a 'href "some-url" 'target "some-target" "anchor")) => #f
(terminal-ast-node? (br)) => #t
(terminal-ast-node? (html (head (title "ttt")) (body (p "ppp")))) => #f
See also Scheme source file terminal-ast-node?

xml-comment?
Form (xml-comment? x)
Description Is x an XML comment?
Examples (xml-comment? (xml-comment "ccc")) => #t
(xml-comment? "ccc") => #f
See also Scheme source file xml-comment?

cdata-section?
Form (cdata-section? x)
Description Is x an XML CDATA section?
Examples (cdata-section? (cdata-section "xxx" 5 #\5)) => #t
(cdata-section? "xxx") => #f
See also Scheme source file cdata-section?

processing-instruction?
Form (processing-instruction? x)
Description Is x an XML processing instruction?
Examples (processing-instruction? (processing-instruction "i" "xxx" "yyy")) => #t
See also Scheme source file processing-instruction?

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 applied on a non-AST, the predicate always returns false. 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.
Parameters type One of the symbols element-name, kind, or language.
name The element-name, the kind-name (double or single), or the language-name, depending on the value of the parameter type. A string.
Returns A specialized AST predicate.
Examples ((ast-of-type? 'element-name "a") (a 'href "some-url" 'target "some-target" "anchor")) => #t
((ast-of-type? 'kind "double") (a 'href "some-url" 'target "some-target" "anchor")) => #t
((ast-of-type? 'language "xhtml10-transitional") (a 'href "some-url" 'target "some-target" "anchor")) => #t
((ast-of-type? 'xxx "yyy") (a 'href "some-url" 'target "some-target" "anchor")): ERROR
See also Scheme source file ast-of-type?


8 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.
Examples (char-ref 169) => (char-ref 169)
(char-ref "copy") => (char-ref copy)
See also Scheme source file char-ref

char-ref-value
Form (char-ref-value char-ref-structure)
Description Return the number or symbol of char-ref-structure.
Examples (char-ref-value (char-ref "copy")) => copy
See also Scheme source file char-ref-value


9 XML Comments.
The xml-comment form documented below allows for native XML comments in an XML-in-LAML document. Use the xml-comment form if it is important for you that LAML outputs native XML comments. In other cases, you may use Scheme comments in your LAML document. XML comments are not rendered if they occur in empty elements.

xml-comment
Form (xml-comment . comment-text-list)
Description Construct an XML comment and return it. This function accepts a list of comment text elements, which together form the aggregated comment text. In this context, a comment text element is a string, or a value which can be converted to a string via use of the function as-string.
Precondition The substring "--" does not occur as part of a comment text element.
Examples (xml-comment "ccc") => (xml-comment ("ccc"))
See also Scheme source file xml-comment

xml-comment-contents
Form (xml-comment-contents xml-comment)
Description Return the comment text of an XML comment.
Returns a list of strings.
Examples (xml-comment-contents (xml-comment "ccc")) => ("ccc")
(xml-comment-contents (xml-comment "ccc" "ddd" 5)) => ("ccc" "ddd" "5")
See also Scheme source file xml-comment-contents

xml-render-xml-comment
Form (xml-render-xml-comment xml-comment)
Description Render the xml-comment with space in between the individual comment text elements.
Returns The rendered string.
See also Scheme source file xml-render-xml-comment


10 XML CDATA Sections.
CDATA sections are typically used in script and style elements, to protect the characters '<', '>', and others. Most browsers do not render CDATA sections, if they appear within the textual contents.

cdata-section
Form (cdata-section . cdata-text-list)
Description Construct an XML CDATA section and return it. This function accepts a list of comment text elements, which together form the aggregated CDATA section text. In this context, a CDATA text element is a string, or a value which can be converted to a string via use of the function as-string.
Precondition The substring "]]>" does not occur as part of a CDATA text element.
Examples (cdata-section "xxx" "yyy") => (cdata-section ("xxx" "yyy"))
See also Scheme source file cdata-section

cdata-section-contents
Form (cdata-section-contents cdata-section)
Description Return the cdata text of an XML comment.
Returns a list of strings.
Examples (cdata-section-contents (cdata-section "xxx" "yyy")) => ("xxx" "yyy")
(cdata-section-contents (cdata-section "xxx" 5 #\5)) => ("xxx" "5" "5")
See also Scheme source file cdata-section-contents

xml-render-cdata-section
Form (xml-render-cdata-section cdata-section)
Description Render the cdata section with space in between the individual cdata text elements.
Returns The rendered string.
See also Scheme source file xml-render-cdata-section


11 XML Processing Instructions.
A processing instruction is an XML technicality for telling something to an application, which processes the document. Processing instructions are only rendered if they occur in non-empty elements.

processing-instruction
Form (processing-instruction pi-target . text-list)
Description Construct an XML processing instruction and return it. This function accepts a pitarget and a list of text elements. In this context, text element is a string, or a value which can be converted to a string via use of the function as-string.
Precondition The substring "?>" does not occur as part of a CDATA text element. The pi-target is not "XML" (using upper or lower cases).
Parameters pi-target A name used to identify the application, towards which the instruction is targeted.
text-list Additional text (a list)
Examples (processing-instruction "i" "xxx" "yyy") => (processing-instruction "i" ("xxx" "yyy"))
See also Scheme source file processing-instruction

processing-instruction-target
Form (processing-instruction-target pi)
Description Return the processing instruction pi-target of the processing instruction pi.
Returns a text string.
See also Scheme source file processing-instruction-target

processing-instruction-contents
Form (processing-instruction-contents pi)
Description Return the processing instruction text part of the processing instruction pi.
Returns a list of strings.
Examples (processing-instruction-contents (processing-instruction "i" "xxx" "yyy")) => ("xxx" "yyy")
See also Scheme source file processing-instruction-contents

xml-render-processing-instruction
Form (xml-render-processing-instruction pi)
Description Render the processing instruction pi.
Returns The rendered string.
See also Scheme source file xml-render-processing-instruction


12 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.
See also Scheme source file xml-in-laml-name-clashes

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.
See also Scheme source file register-xml-in-laml-language

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.
See also Scheme source file language-map-of

language-in-use?
Form (language-in-use? language)
Description Is language in use - is it registered as an xml-in-laml language?
Examples (language-in-use? 'xhtml10-transitional) => #t
See also Scheme source file language-in-use?

languages-in-use
Form (languages-in-use)
Description Return the list of language in used, as registered by register-xml-in-laml-language.
Examples (languages-in-use) => (xhtml10-transitional)
See also Scheme source file languages-in-use

element-names-of-language
Form (element-names-of-language language)
Description Return the element names of language, as defined by its language map.
Examples (element-names-of-language 'xhtml10-transitional) => (td th tr col colgroup tbody tfoot thead caption table isindex button legend fieldset textarea option optgroup select input label form area map img applet param object font basefont strike s u small big b i tt sup sub q acronym abbr cite var kbd samp code dfn strong em br bdo span a del ins center blockquote pre hr address dd dt dl li dir menu ol ul h6 h5 h4 h3 h2 h1 p div body noframes iframe noscript script style link meta base title head html)
See also Scheme source file element-names-of-language

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?
See also Scheme source file causes-xml-in-laml-name-clash?

activator-via-language-map
Form (activator-via-language-map language)
Description Return an activator function for language.
Parameters language The name of an XML language (a symbol).
Returns A function which given an XML element name (a string or a symbol) in language returns the appropriate mirror function.
See also Scheme source file activator-via-language-map

with-xml-language
Form (with-xml-languge language-name . forms)
Description A macro which globally establishes the name bindings of xml-language and evaluate forms in this state. Does also handle separate checking of ID and IDREF attributes in forms. Works in a manner similar to a fluid-let. As a matter of optimization, only assign the names in the overlap between the XML languages in use. Defined as a syntactical abstraction.
Parameters language-name The name of a language map (a symbol).
forms A number of Scheme forms presumably involving mirror function names from the XML language language-name.
Returns The value of the last expression in forms
See also Scheme source file with-xml-language
similar function with-xml-language!
Note If the overlap between the XML languages in use includes central Scheme functions, such as map or filter, you should use with-xml-language! instead (and put the central Scheme functions in the minus-elements).

with-xml-language!
Form (with-xml-languge! language-name minus-elements . forms)
Description A macro which globally establishes the name bindings of xml-language and evaluate forms in this state. Does also handle separate checking of ID and IDREF attributes in forms. Works in a manner similar to a fluid-let. All elements of xml-language are redefined, except the explictly given minus elements.
Parameters language-name The name of a language map (a symbol).
minus-elements The list of element names which are not allowed to be reassigned.
forms A number of Scheme forms presumably involving mirror function names from the XML language language-name.
Returns The value of the last expression in forms
See also Scheme source file with-xml-language!
similar function with-xml-language


13 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.
Parameters element-name The name an XML element. Either a symbol or a string.
Returns The mirror function or #f if no mirror function exists in the map.
See also Scheme source file get-mirror-function

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
See also Scheme source file put-mirror-function


14 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.
See also Scheme source file register-xml-in-laml-navigator

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.
See also Scheme source file xml-navigator-of

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.
Examples (possible-elements-rooted-by-element "html" 'xhtml10-transitional) => (a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dfn dir div dl dt em fieldset font form h1 h2 h3 h4 h5 h6 head hr html i iframe img input ins isindex kbd label legend li link map menu meta noframes noscript object ol optgroup option p param pre q s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var)
(possible-elements-rooted-by-element "title" 'xhtml10-transitional) => (title)
See also Scheme source file possible-elements-rooted-by-element

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.
Examples (possible-attributes-rooted-by-element "br" 'xhtml10-transitional) => (class clear id style title)
See also Scheme source file possible-attributes-rooted-by-element

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).
See also Scheme source file can-have-element-constituent?


15 Mirror Generation Functions.
The function generate-xml-mirror-function is the (higher-order) function that generates the mirror of XML elements in Scheme. In addition, this section contains the function that implement the LAML parameter passing rules of the mirror functions, namely, xml-sort-tag-parameters.

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 is returned as a list contents elements (strings, ASTs, booleans).
Examples (xml-sort-tag-parameters (list "this" _ "is" 'href "url" "end") "a" 'xhtml10-transitional) => (("this" "is" #t "end") href "url")
(xml-sort-tag-parameters (list "this" "is" 'href "url" "end") "a" 'xhtml10-transitional) => (("this" #t "is" #t "end") href "url")
See also Scheme source file xml-sort-tag-parameters
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 function. 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).
Examples (xml-sort-superficially-tag-parameters (list "this" "is" 'href "url" "end") "a" 'xhtml10-transitional) => (("this" #t "is" #t "end") href "url")
(xml-sort-superficially-tag-parameters (list "this" _ "is" 'href "url" "end") "a" 'xhtml10-transitional) => (("this" #f "is" #t "end") href "url")
See also Scheme source file xml-sort-superficially-tag-parameters
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 Scheme source file laml-source-prepare
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. In the generated mirror function, the internal attribute run-action-procedure controls if an action procedure is executed. (The value false of internal:run-action-procedure prevents an associated action procedure to be executed. The default value of the internal attribute is true).
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, the action procedure is taken from the action procedure map. If a procedure, the given procedure is used as the action procedure.
See also Scheme source file generate-xml-mirror-function


16 Contents Validation.
The definitions in this section carry out the content validation. Throughout the procedures in this section it is assumed that delayed procedural content items have been expaneded before content validation is attempted.

validate-contents-by-dfa!
Form (validate-contents-by-dfa! contents dfa tag-name)
Description Apply the deterministic finte 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.
See also Scheme source file validate-contents-by-dfa!

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.
See also Scheme source file validate-as-pcdata!

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 or white space markers.
tag-name The name of the element in which we check the constituents.
symbol-choice-list A list of symbols for the possible choices - a list of symbols.
See also Scheme source file validate-mixed-contents-by-simple-means!

extraordinary-allow-element?
Form (extraordinary-allow-element? element-name context-element-name)
Description Is element-name extraordinarily allowed within context-element-name (both symbols). By redefining this function you may extraordinarily allow element-name to appear within context-element-name. By default, this function always returns the value #f (false).
See also Scheme source file extraordinary-allow-element?


17 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: From LAML version 27: The constrains regarding ID, IDREF, and IDREFS are now handled. See the function check-id-and-idref-attributes!. 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"
See also Scheme source file xml-check-attributes!

check-id-and-idref-attributes!
Form (check-id-and-idref-attributes!)
Description Check that the ID and IDREF attribute values are used according to the XML 1.0 specification. This function is called by the end-laml function, as redefined in this library (lib/xml-in-laml/xml-in-laml.scm). You may also chose to call this function yourself, as part of the processing of your XML document. This procedure resets the variables bookkeeping of ID and IDREF attribute checking such that if the procedure is called again it will not report the same errors again.
See also Scheme source file check-id-and-idref-attributes!


18 Link Checking.
Web documents are able to link to other web documents. As an example, in XHTML the href attribute of the a element represents such a link. The procedures in this section are used to check that links actually address existing resources.

collect-links-for-later-checking-in-ast!
Form (collect-links-for-later-checking-in-ast! xml-ast absolute-target-html-file)
Description Collect the urls in xml-ast, which are about to be written to the file absolute-target-html-file (full path). The urls are collected in the global variables relative-url-list-for-later-checking and absolute-url-list-for-later-checking. The links are intended to be checked at a later point in time. Each XML language L comes with an URL extraction function, returned by (url-extractor-of-xml-language L), which returns a list of URLs when applied on an AST. Similarly, theres is a function (url-extractor-of-xml-language L) for handling of base URLs.
See also Scheme source file collect-links-for-later-checking-in-ast!
URL extraction url-extractor-of-xml-language base-url-extractor-of-xml-language
About link checking in LAML Note

check-relative-url-list!
Form (check-relative-url-list! relative-urls)
Description Checks the existense of the resources addressed by the urls in relative-urls Some of the elements may be boolean #f, which signals that they should not be checked. In a typical checking sessions, the same file or directory may be checked more than once. As an alternative to the current implementation of this function, we could eliminate duplicate entries in relative-url-list before the existence check is done.
See also Scheme source file check-relative-url-list!
About link checking in LAML Note

check-absolute-url-list!
Form (check-absolute-url-list! absolute-urls)
Description Checks the existense of the resources addressed by the urls in absoute-urls. A given URL in the list is only checked once. Also increment the counter absolute-url-problem-count in case of problems with absolute-urls. Requires the function url-target-exists? which is one of the LAML compatibility functions. Currently, we do not a have a good implementation of url-target-exists? in the LAML distribution.
See also Scheme source file check-absolute-url-list!
About link checking in LAML Note


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. Thus, the procedures in this section use the functions from the sections Contents Validation and Attribute Checking.

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)
See also Scheme source file validation-procedure-map-of

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 validation procedure map, return #f
Parameters element-name The name of the element (string or symbol)
language The name of the language (string or symbol)
See also Scheme source file validation-procedure-of

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.
See also Scheme source file register-xml-in-laml-validators

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 Scheme source file validate-ast!
error function xml-check-error


20 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.
See also Scheme source file display-xml-warning

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 Scheme source file xml-check-error
default value display-xml-warning
alternative value laml-error


21 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) which can be delivered in various ways (as strings or in streams). Both pretty printed and non pretty printed renderings are supported. In the start of the section we document a couple of variable that controls aspects of the

compact-end-tag-rendering?
Form compact-end-tag-rendering?
Description A boolean variable that controls how end tags are rendered when pretty printing is applied. If the value of the variable is true (#t) there will be no newline character and no indentation in front of an end tag. Use of the value true implies that a number of end tags will follow each other on the same line, and immediately after the element contents. This is not a nice pretty printing, but it is necessary to obtain a correct rendering in most browsers. If the value of the variable is false (#f) the end tag will be nicely aligned with the start tag. We recommend the value false (#f) because most browsers leaves a trace of white space before end tags. The default value is false (#f).
See also Scheme source file compact-end-tag-rendering?

use-empty-tags-for-elements-without-contents
Form use-empty-tags-for-elements-without-contents
Description A boolean variable that controls how elements without contents are rendered. If the value of the variable is true (#t) always use the empty element tag for elements that happen to have no contents. If the value of the variable is false (#f), only use the empty element tag for elements that are statically declared to be empty. For reasons of interoperability with old browsers we recommend the value false (#f). The default value is false (#f).
See also Scheme source file use-empty-tags-for-elements-without-contents

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 Scheme source file render-to-output-port
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 Scheme source file pretty-render-to-output-port
standard-prolog laml.scm
standard-epilog laml.scm

render-start-tag-to-output-port
Form (render-start-tag-to-output-port xml-clause output-port)
Description Render the start-tag of xml-clause (a LAML AST) to output-port. With this function, only the start tag and the attributes of the top-level element is rendered to the port. This function is primarily useful for stepwise imperative processing of an XML document.
Parameters xml-clause an AST
output-port an open output port
See also Scheme source file render-start-tag-to-output-port

render-end-tag-to-output-port
Form (render-end-tag-to-output-port xml-clause output-port)
Description Render the end-tag of xml-clause (a LAML AST) and return the rendered string. With this function, only the end tag of the top-level element is rendered to the port. This function is primarily useful for stepwise imperative processing of an XML document.
Parameters xml-clause an AST
output-port an open output port
See also Scheme source file render-end-tag-to-output-port

xml-render
Form (xml-render xml-clause [prolog epilog])
Description Render the xml-clause (a 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
See also Scheme source file xml-render

pretty-xml-render
Form (pretty-xml-render xml-clause [prolog epilog])
Description Pretty print xml-clause (a 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
See also Scheme source file pretty-xml-render

start-tag-of
Form (start-tag-of xml-clause)
Description Render the start-tag of xml-clause (a LAML AST) and return the rendered string. With this function, only the start tag and the attributes of the top-level element is rendered and returned. This function is primarily useful for stepwise imperative processing of an XML document.
See also Scheme source file start-tag-of

end-tag-of
Form (end-tag-of xml-clause)
Description Render the end-tag of xml-clause (a LAML AST) and return the rendered string. With this function, only the end tag of the top-level element is rendered and returned. This function is primarily useful for stepwise imperative processing of an XML document.
See also Scheme source file end-tag-of

xml-render-as-laml
Form (xml-render-as-laml contents)
Description An rendering function which delivers a source-like Scheme expression as result (as a text string). Can be used for error message purposes, and other purposes as well. This function is slow due to use of heavy recursive string concatenation. See the faster alternative referred below. If you write the resulting string to a file, with write-text-file, it is often useful to pretty-print this file with scheme-pp.
Parameters contents An AST, textual contents (a string) (and others), or a list of such content items.
Returns A text string.
See also Scheme source file xml-render-as-laml
Faster alternative render-as-laml-string
Output port alternative render-as-laml-to-output-port
Writing text string to file write-text-file
Useful post processing function scheme-pp
Note This function actually accepts an optional parameter, which we do not document.

render-as-laml-to-output-port
Form (render-as-laml-to-output xml-clause output-port)
Description Render the XML clause (an AST) as a (non-pretty printed) LAML source text to output-port. output-port is assumed to be open. output-port will not be closed by this procedure. As of June 2007, this function is still experimental. Some aspects of the AST may not yet be handled correctly.
Parameters xml-clause an AST
output-port an open output port
prolog a prolog string to be inserted (a prefix)
epilog an epilog string to be inserted (a suffix)
See also Scheme source file render-as-laml-to-output-port
A variant that returns a string render-as-laml-string

render-as-laml-string
Form (render-as-laml-new xml-clause [prolog epilog])
Description Render the xml-clause (a LAML AST) as a (non-pretty printed) LAML source text to output-port and return the rendered string. As of June 2007, this function is still experimental. Some aspects of the AST may not yet be handled correctly.
Parameters xml-clause an AST
prolog A prolog string to be inserted
epilog An epilog string to be inserted
See also Scheme source file render-as-laml-string
A much slower version xml-render-as-laml
A variant that renders to port render-as-laml-to-output-port

xml-render-as-simple-text
Form (xml-render-as-simple-text contents)
Description Pure textual rendering of contents. Strips all markup. Suppress all superfluous white spacing. No formatting is provided at all.
Parameters contents An AST, textual contents (a string, CDATA), char-ref, etc, and a list of such content items.
Returns a text string without markup and without any formatting.
See also Scheme source file xml-render-as-simple-text


22 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
Examples (define a-main (modify-element a 'target "main"))
See also Scheme source file xml-modify-element
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 Scheme source file xml-modify-element-prepend
similar function xml-modify-element


23 XML in LAML 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. The most useful function is xml-in-laml-abstraction. xml-in-laml-positional-abstraction is a generalized version of xml-in-laml-abstraction. The function xml-in-laml-parametrization is only useful if you want to interface between XML-in-LAML parameter passing rules and a function with simple, conventional, positional parameter passing.

xml-in-laml-abstraction
Form (xml-in-laml-abstraction f [parameter-validator! f-name language])
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. Defaults to a validator that always returns #t.
f-name The name of the abstraction - used for error message purposes only. A string.
language The name of the XML language to which the generated xml-in-laml abstraction belongs. If you wish the most precise warnings or error messages you should pass this parameter. A symbol.
See also Scheme source file xml-in-laml-abstraction
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 language])
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.
language The name of the XML language to which the generated xml-in-laml abstraction belongs. If you wish the most precise warnings or error messages you should pass this parameter. A symbol.
See also Scheme source file xml-in-laml-positional-abstraction
specialized function xml-in-laml-abstraction
useful par. validator required-implied-attributes

xml-in-laml-parametrization
Form (xml-in-laml-parametrization f parameter-mediator [parameter-validator! f-name language])
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.
language The name of the XML language to which the generated xml-in-laml parametrization belongs.
See also Scheme source file xml-in-laml-parametrization
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.

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 Scheme source file required-implied-attributes
relevant context of use xml-in-laml-abstraction xml-in-laml-parametrization
error function xml-check-error


24 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. The "find" and "transverse-and-collect" functions in this section constitute a 'minimalistic transformation framework' in LAML, which is useful for target-controlled transformation of an AST. The function transform-ast is useful for comprehensive, recursive, source-controlled transformation of an AST (similar to a typical use of XSLT). The following section contains more sophisticated locator functions.

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. 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 transformed ASTs.
See also Scheme source file find-asts
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. 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 A transformed AST, or #f
See also Scheme source file find-first-ast
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 Scheme source file unique-ast-attribute
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, and delayed procedural content items are not taken into account. The traversal is done in pre-order.
Parameters ast-tree The AST to be traversed. May also be a content list (such as a list of ASTs) as returned by the function ast-subtrees.
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 Scheme source file traverse-and-collect-all-from-ast
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. May also be a content list (such as a list of ASTs) as returned by the function ast-subtrees.
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 Scheme source file traverse-and-collect-first-from-ast
useful as parameter ast-of-type?
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
Form (transform-ast transform-specs source-items)
Description Transform source item(s) by means of transform-specs. The first applicable transformation in transform-specs is applied. Applies the function positive-to-negative-ast-spacing on any AST before the transformation process. Recursive transformations, initiated in the transformation functions of transform-specs, should be done by means of the function apply-transformation-on.
Precondition ASTs in source are positive spaced. At least one transformation in the transform-spec MUST be applicable.
Parameters source-items A content item, a list of content items. This can be an AST, or a list of ASTs. It can also be CDATA (a text string or a list of text strings).
transform-spec A list of transformation specifications. Each transformation specification is itself a list of length 2: (input-predicate transformation-function).
Returns The transformed source (such as an AST or a list of ASTs).
See also Scheme source file transform-ast
recursive transformation apply-transformation-on
applied function positive-to-negative-ast-spacing
Note Notice that it is up to the transformation specifications to decide if recursive transformation is done. Organize transformation-spec with the most specialized transformations first, and the most general transformations last. Be sure that at least one transformation is applicable. It is possible to to ignore 'non-matched source items' by having (list (lambda (x) #t) (lambda (source) '())) as the last element in the transformation specification.

apply-transformation-on
Form (apply-transformation-on source-items)
Description Do recursive transformation on a content source item, or a list of content source items (such as an AST, or a list of ASTs). At top level, always apply the function transform-ast. Within the transformation functions (of a transform-specs of transform-ast) perform recursive transformations by apply-transformation-on. This function uses the same transformation specification as the original call of transform-ast.
Parameters source-items A content item, a list of content items. This includes an AST, and a list of ASTs.
See also Scheme source file apply-transformation-on
top-level transformation transform-ast

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 (not copied) without being transformed. No recursive transformations are 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 Scheme source file transform-ast-list
similar, and better 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?
Note This is an older, ad-hoc transformation function. I recommend that you use the function transform-ast instead.

positive-to-negative-ast-spacing
Form (positive-to-negative-ast-spacing ast)
Description Given an AST with positive white spacing (such as an AST returned by mirror function). Thus, the input AST may hold a number of explicit-space values (#t values), but no explicit-space-suppress values (no #f values). Return a copy of the AST with negative white spacing, akin to the source forms of the mirror functions. Thus, the output AST may hold a number of explicit-space-suppress values (#f values), but no explicit-space values (no #t values)
See also Scheme source file positive-to-negative-ast-spacing


25 LAML location path and steps.
This section contains Xpath inspirred matching, extraction, and transformation functions. The definitions in this section make up an alternative to the minimalistic AST traversal and transformation functions in the previous section. Eventually, there will be additional documentation and examples of the LAML location path framework.

match-ast
Form (match-ast ast . locator-list)
Description Apply each function in locator-list sequentially on the list of ASTs resulting from previous location step. Flatten the resulting lists, and ensure that a given content element is at most returned once. A locator function is a function from content element (such as an AST) to a single content element, or (more typcially) to a list of content elements. A locator function may, in fact, perform some tranformation on the list of content elements. This function sets the variable xml-root-node to ast, if the variable is not already assigned explitly. If this function assigns xml-root-node, it also resets xml-root-node to value #f afterwards.
Parameters ast A single AST that represents a single XML document.
locator-list is a list of AST locator functions. Each such function works on a single content element (an AST for instance) and it returns a list of content elements. (For convenience, it is also possible to return a single contents element, which automatically is nested into a list). The function location-step is the primary generator of locator-path functions.
Returns A list of content elements (ASTs, for instance).
See also Scheme source file match-ast
locator path generation function location-step

xml-root-node
Form xml-root-node
Description The XML root node, used to determine some of the reverse axes. It is possible to assign xml-root-node explicitly via set!. If you set xml-root-node explicitly, remember to reset its value to #f when you are done.
See also Scheme source file xml-root-node

location-step
Form (location-step axis [node-test filtering])
Description Generates and returns a location step procedure for a given axis, name, and filtering. Use of the axes following-sibling, preceding-sibling, following, preceding, ancestor, and parent requires that the xml-root-node is assigned in advance. These axes correspond to the axes known from Xpath.
Parameters axis One of the axes self, child, descendant, attribute, following-sibling, preceding-sibling, following, preceding, ancestor, and parent (a symbol).
node-test A node test which is relevant in the context of the axis. Typcically a name of an XML element, or an attribute name.
filtering Some filtering applied realtive to axis and name. Typically a boolean function from (content-element node-position context-size). For the attribute axis, filtering may be a text string (the attribute value).
See also Scheme source file location-step

negate-step
Form (negate-step location-step-procedure)
Description A higher-order function that negates a single location-step procedure. Negated steps are primarily useful in filtering contexts, because it is not possible to turn an empty result back to something useful.
See also Scheme source file negate-step

and-steps
Form (and-steps . location-step-procedure-list)
Description A higher-order function that conjuncts (ands) some location steps to a single location step. Does each location step in location-step-procedure-list succeed? Returns a boolean-like result: If yes, return (list #t), else return (). Only useful within the filtering position in a location step.
See also Scheme source file and-steps

or-steps
Form (or-steps . location-step-procedure-list)
Description A higher-order function that disjuncts (ors) some location steps to a single location step. Does at least one location step in location-step-procedure-list succeed? Returns a boolean-like result: If yes, return (list #t), else return (). Only useful within the filtering position in a location step.
See also Scheme source file or-steps

compose-steps
Form (compose-steps . location-step-procedure-list)
Description Compose the locatation steps in location-step-procedure-list to a single location step. Useful in contexts where only a single location step is allowed.
See also Scheme source file compose-steps

identifier-of-predicate
Form (identifier-of-predicate p)
Description Return the identifier function of the predicate p. An identifier function returns x if p holds on x, else the it returns the empty list. Via this function, a predicate can act as a location step.
See also Scheme source file identifier-of-predicate

ast-text-containing
Form (ast-text-containing str)
Description Generates a location step that test if str is part of the immediate textual content. The generated procedure can be used as the last step in location path (a list of location steps).
See also Scheme source file ast-text-containing

ast-text-deep-containing
Form (ast-text-deep-containing str)
Description Generates a location step that tests if str is part of the deep textual content. The generated procedure can be used as the last step in location path (a list of location steps).
See also Scheme source file ast-text-deep-containing

ast-node
Form (ast-node)
Description Generates a location step that tests for x being a node.
See also Scheme source file ast-node

nt:last
Form (nt:last)
Description A filtering function that tests if the node is the last in its context. Filtering functions are used in location steps.
See also Scheme source file nt:last

nt:child-number
Form (nt:child-number q)
Description A filtering function that tests if the node is number q in its context. Filtering functions are used in location steps.
See also Scheme source file nt:child-number

nt:child-name
Form (nt:child-name name)
Description A filtering function that tests if the node has name. Filtering functions are used in location steps.
See also Scheme source file nt:child-name

nt:attribute
Form (nt:attribute name value)
Description A filtering function that tests if the node has an attribute name with the given value. Filtering functions are used in location steps.
See also Scheme source file nt:attribute

nt:for-which-predidate-holds
Form (nt:for-which-predidate-holds pred . location-steps)
Description A filtering function which applies a list of location steps on the node, a passes the results of these steps to the predicate pred. Operationally: Apply location steps on node in question (n), giving a list of results. Test if the result fulfills the predicate pred (which must be some list predicate). Filtering functions are used in location steps.
See also Scheme source file nt:for-which-predidate-holds

nt:for-which
Form (nt:for-which . location-steps)
Description A filtering function which test if the list of location steps leads success (leads to a non-empty result). Filtering functions are used in location steps.
See also Scheme source file nt:for-which


26 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.
See also Scheme source file content-model-map-of

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.
See also Scheme source file content-model-of

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.
See also Scheme source file register-xml-in-laml-content-models


27 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.
See also Scheme source file action-procedure-map-of

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.
See also Scheme source file action-procedure-of-language

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.
See also Scheme source file action-procedure-of-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 (strings) 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.
See also Scheme source file register-xml-in-laml-action-procedures

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 Scheme source file process-ast!
action procedure access action-procedure-map-of


28 Expansion of delayed procedural content items.
It is possible to embed a Scheme procedure (with a certain given signature) in an XML-in-LAML document. This allows for simple and direct handling of context-sensitive aspects of a document. The function expand-procedural-content-items-in-ast calls such procedures, hereby expanding the AST.

expand-procedural-content-items-in-ast
Form (expand-procedural-content-items-in-ast ast)
Description Expand all delayed procedural content items (recursively) inside the ast. Traverses the entire ast and looks for procedural content item constituents. Return an expanded AST (a copy of ast) in which procedural content elements have been activated and thereby expanded. If ast does not contain any delayed procedural content items, ast is just returned (without copying it).
See also Scheme source file expand-procedural-content-items-in-ast

has-procedural-content-items-deep?
Form (has-procedural-content-items-deep? ast)
Description Is there any procedure content items in ast. Traverses the entire ast if necessary.
See also Scheme source file has-procedural-content-items-deep?

has-procedural-content-items?
Form (has-procedural-content-items? x)
Description Is there any procedure content items among the immediate constituents of x (usually an AST). No AST traversal is involved to find out. This function also work on a (flat) element content list x (of text, space, comment, CDATA etc).
See also Scheme source file has-procedural-content-items?


29 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.
See also Scheme source file ast-to-parse-tree
Note To load html-support: (laml-tool-load "xml-html-support/html-support.scm")

Generated: Monday, November 14, 2011, 09:18:53
Generated by LAML SchemeDoc using LAML Version 38.0 (November 14, 2011, full)