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

Reference Manual of the XML-in-LAML library

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

Master index
Source file: lib/xml-in-laml/xml-in-laml.scm
LAML Version 19.00 (January 16, 2003, full)

The XML-in-LAML common parts, which are shared between all XML-in-LAML languages. This library is designed to co-exists with non-validating HTML mirrors (for the sake of LENO, for instance). It cannot be used together with validating ast-based HTML mirrors, such as html4.01-transitional-validating. If you need to, you should use an all xml-in-laml solution. By that we mean a solution, where also the HTML stuff is based on XML-in-LAML. In practical terms, it means that you should use the XML-in-LAML XHTML mirror in lib/xml-in-laml/mirrors/

Table of Contents:
1. XML front matter stuff.6. The language map.11. Element related functions.
2. XML-in-LAML processing parameters.7. Mirror generation functions.12. XML in LAML parametrization and abstraction functions.
3. Other Constants.8. Contents validation.13. AST traversal and attribute getter functions.
4. AST functions.9. Attribute checking.14. Other useful functions.
5. XML language bookkeeping.10. Rendering functions and procedures.

Alphabetic index:
__The symbolic name of explicit white space suppress.
aggregated-ast-cdata-contents(aggregated-ast-cdata-contents ast)Return a string of the aggregated CDATA contents of ast.
ast-attributes(ast-attributes ast)Return the list of attributes of ast, on property list format.
ast-element-name(ast-element-name ast)Return the root element name of ast.
ast-kind(ast-kind ast)Return the kind of the ast.
ast-language(ast-language ast)Return the language of the ast.
ast-of-type?(ast-of-type? type name)A higher-order function that returns an AST predicate, which checks if the type of the AST is name.
ast-subtrees(ast-subtrees ast)Return the list of substrees of ast.
ast-to-parse-tree(ast-to-parse-tree ast)Convert an abtract syntax tree to a parse tree.
ast?(ast? x)Is the parameter x an AST
attribute-getter(attribute-getter attribute-name [default-value])A higher-order function which returns an attribute getter function on ASTs.
causes-xml-in-laml-name-clash?(causes-xml-in-laml-name-clash? name)Is name involed in a name clash among the registered xml-in-laml languages?
cdata?(cdata? x)Is the parameter x CDATA
contents-data?(contents-data? x)Is the parameter x either an ast or a contents string.
display-xml-warning(display-xml-warning . messages)A variant of display-warning which prefixes the warning text with a 'XML Warning' prefix.
element-names-of-language(element-names-of-language language)Return the element names of language, as defined by its language map.
explicit-spaceexplicit-spaceThe explicit white space value, as used internally in ast.
explicit-space-suppressexplicit-space-suppressThe explicit white space suppress value.
forced-white-space?(forced-white-space? x)Is the parameter x a white space mark.
generate-xml-mirror-function(generate-xml-mirror-function validation-procedure tag-name default-dtd-attributes single-double-kind language overlap-check? action-procedure)Return an XML mirror surface function, in which textual content parameters and attribute value pairs can be given in a very liberal fashion.
get-mirror-function(get-mirror-function language-map element-name)Return the mirror function based on element-name from language map.
language-in-use?(language-in-use? language)Is language in use - is it registered as an xml-in-laml language?
language-map-of(language-map-of language)Return the language map of language.
languages-in-use(languages-in-use)Return the list of language in used, as registered by register-xml-in-laml-language.
make-ast(make-ast element-name contents attributes kind language)Make an AST given element-name, contents, a property list of attributes, a kind (single/double) an an XML language name.
one-or-more(one-or-more . element-constituent-list)Return a predicate which checks whether the contents matches one or more instances from element-constituent-list.
pcdata-checker(pcdata-checker contents)A predicate which checks whether the contents is PCDATA.
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-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.
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.
sequence-with-optionals(sequence-with-optionals . rhs-elements)Return a predicate which checks whether the contents match the sequential rhs-elements.
set-xml-accept-only-string-valued-attributes-in(set-xml-accept-only-string-valued-attributes-in language new-value)Controls the handling of LAML attribute values in language.
set-xml-char-transformation-table-in(set-xml-char-transformation-table-in language new-value)Set the HTML/XML character transformation table used for language.
set-xml-transliterate-character-data-in(set-xml-transliterate-character-data-in language new-value)Ask for transliteration of all CDATA characters via an HTML/XML character transformation table.
standard-prolog(standard-prolog [language])The standard-prolog function as redefined for XML.
terminal-ast-node?(terminal-ast-node? x)Is x an ast nodes without subtrees?
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 those 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 the first subtree which satisfies node-interesting.
white-space-related?(white-space-related? x)Is the parameter x white space related?
white-space-suppress?(white-space-suppress? x)Is the parameter x a white suppress space mark.
xml-accept-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-add-problem!(xml-add-problem! error-message)The procedure for reporting validation problems.
xml-char-transformation-table-in(xml-char-transformation-table-in language)Return the HTML/XML character transformation table used for language.
xml-check-attributes!(xml-check-attributes! attributes dtd-attribute-definition number-of-req-attributes tag-name)Check the attributes (first par) in the calling form against the attribute definitions taken from the DTD file (second par).
xml-check-attributes?xml-check-attributes?A boolean variable which controls the checking of element attributes.
xml-check-error(xml-check-error . messages)The procedure that reports XML validation errors.
xml-check-language-overlap?xml-check-language-overlap?A boolean variable that controls the check of XML language overlap.
xml-declaration(xml-declaration)Return the xml declaration
xml-document-type-declaration-in(xml-document-type-declaration-in language)Return the document type declaration of language.
xml-enrich-error-message(xml-enrich-error-message error-message constituent)Enrich an error message with info about a constitutent (AST)
xml-enrich-error-messages(xml-enrich-error-messages error-message-list constituent)Enrich a list of error messages with info about a constitutent (AST)
xml-error-truncation-lengthxml-error-truncation-lengthHow many characters of the validation error messages to be presented.
xml-in-laml-abstraction(xml-in-laml-abstraction f [parameter-validator! f-name])Generate a function with XML-in-LAML parameter passing rules which sends its input to an XML or HTML mirror function, or to another XML-in-LAML abstraction.
xml-in-laml-name-clashesxml-in-laml-name-clashesThe list of names (symbols) which causes name clashes relative to the current set of languages in use.
xml-in-laml-parametrization(xml-in-laml-parametrization f parameter-mediator [parameter-validator! f-name])Generate a function with XML-in-LAML parameter passing rules which sends its input to an ordinary function with positional parameters via a parameter mediator.
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-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-render(render xml-clause [prolog epilog])Render the xml-clause (an AST) and return the rendered string
xml-represent-white-space-in?(xml-represent-white-space-in? language)This value controls the representation of white space in the internal AST representation of a document.
xml-sort-superficially-tag-parameters(xml-sort-superficially-tag-parameters parameters tag-name [language])Like xml-sort-tag-parameters, but collect the content contribution in a relatively raw surface form.
xml-sort-tag-parameters(xml-sort-tag-parameters parameters tag-name [language])Separates the parameter, 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.
zero-or-more(zero-or-more . element-constituent-list)Return a predicate which checks whether the contents matches zero or more instances from element-constituent-list

 

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


standard-prolog


Form
(standard-prolog [language])

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

See also
applied functionxml-declaration    
applied functionxml-document-type-declaration-in    
applied functioncopyright-clause


xml-declaration


Form
(xml-declaration)

Description
Return the xml declaration


 

2.   XML-IN-LAML PROCESSING PARAMETERS.
The variables and functions in this part controls 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.


xml-check-attributes?


Form
xml-check-attributes?

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


xml-validate-contents?


Form
xml-validate-contents?

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


xml-check-language-overlap?


Form
xml-check-language-overlap?

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


xml-transliterate-character-data-in?


Form
(xml-transliterate-character-data-in? language)

Description
Return if CDATA (Character data) is transformed through an HTML/XML character transformation table. The value is boolean, and normally true.

See also
mutatorset-xml-transliterate-character-data-in    
transformation tablelaml.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
languageThe name of the XML-in-LAML language - see the first few linew of relevant mirror library manuals - a symbol.
new-valueA boolean value.

See also
selectorxml-transliterate-character-data-in?    
table getterxml-char-transformation-table-in    
table setterset-xml-char-transformation-table-in    
exceptionsxml-non-transliteration-elements-in    
transformation tablelaml.scm

Note
Consider macro implementation.


xml-char-transformation-table-in


Form
(xml-char-transformation-table-in language)

Description
Return the HTML/XML character transformation table used for language.

Returns
A character transformation table.

See also
transformation tablelaml.scm
table setterset-xml-char-transformation-table-in    
exceptionsxml-non-transliteration-elements-in    
transformation tablelaml.scm


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
languageThe name of the XML-in-LAML language - see the first few linew of relevant mirror library manuals - a symbol.
new-valueA character transformation table.

See also
table getterxml-char-transformation-table-in    
exceptionsxml-non-transliteration-elements-in    
transformation tablelaml.scm

Note
Consider macro implementation.


xml-non-transliteration-elements-in


Form
(xml-non-transliteration-elements-in language)

Description
Return the list of element names, for which we do not carry out the character transliteration in language. In XHTML, the list typically include the elements style and script. The value is a list of strings. The value of this function is locked and bound at mirror generation time.

See also
transliterationxml-transliterate-character-data-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.


xml-pass-default-dtd-attributes-in?


Form
(xml-pass-default-dtd-attributes-in? language)

Description
Controls whether the default attribute values, as specified in the DTD, are passed explicitly as attribute values in every instance of the element. The value is boolean, and normally false. A true value in most cases give problems relative to the XML attribute validation. The value of this function is locked and bound at mirror generation time.

See also
validation controlxml-check-attributes?    


xml-accept-only-string-valued-attributes-in?


Form
(xml-accept-only-string-valued-attributes-in? language)

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

See also
setterset-xml-accept-only-string-valued-attributes-in    


set-xml-accept-only-string-valued-attributes-in


Form
(set-xml-accept-only-string-valued-attributes-in language new-value)

Description
Controls the handling of LAML attribute values in language. If new-value is true, LAML only accept string valued XML attribute. If new-value is false, LAML string converts whatever follows an attribute symbol. The value must be a boolean value. True is recommended.

Parameters
languageThe name of the XML-in-LAML language - see the first few linew of relevant mirror library manuals - a symbol.
new-valueA boolean value.

See also
getterxml-accept-only-string-valued-attributes-in?    

Note
Consider macro implementation.


xml-document-type-declaration-in


Form
(xml-document-type-declaration-in language)

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


xml-represent-white-space-in?


Form
(xml-represent-white-space-in? language)

Description
This value controls the representation of white space in the internal AST representation of a document. If true, white space markers are inserted. If false, a clean AST whithou any white space marking is produced. In some languages, white space handling is essential. This is the case in XHTML. In non-presentational XML language, white space handling is not relevant. The value of this function is locked and bound at mirror generation time.


 

3.   OTHER CONSTANTS.


explicit-space


Form
explicit-space

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


explicit-space-suppress


Form
explicit-space-suppress

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


_


Form
_

Description
The symbolic name of explicit white space suppress.


 

4.   AST FUNCTIONS.
In this section we document the functions that work on abstract syntax trees (ASTs). Abstract syntax trees make up the internal representation of XML documents in LAML. All the XML mirror functions return abstract syntax trees.


make-ast


Form
(make-ast element-name contents attributes kind language)

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

Parameters
element-nameA symbol or a string.
contentsA list of contents in term of CDATA (strings), white space markers, or other ASTs.
attributesThe attributes represented as a property list
kindThe symbol double or single
languageA symbol or string that represent the XML-in-LAL language name.


ast-element-name


Form
(ast-element-name ast)

Description
Return the root element name of ast. The type of the returned value is a string.

Preconditions
ast is an abstract syntax tree that satisfies the ast? predicate


ast-subtrees


Form
(ast-subtrees ast)

Description
Return the list of substrees of ast. This is also known as the contents of the ast. It is a list of CDATA (strings), ASTs, and white space markers.

Preconditions
ast is an abstract syntax tree that satisfies the ast? predicate


ast-attributes


Form
(ast-attributes ast)

Description
Return the list of attributes of ast, on property list format.

Preconditions
ast is an abstract syntax tree that satisfies the ast? predicate

Returns
Return value description

See also
Relevant functionget-prop

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.

Preconditions
ast is an abstract syntax tree that satisfies the ast? predicate


ast-language


Form
(ast-language ast)

Description
Return the language of the ast. The type of the returned value is a symbol.

Preconditions
ast is an abstract syntax tree that satisfies the ast? predicate


ast?


Form
(ast? x)

Description
Is the parameter x an AST


cdata?


Form
(cdata? x)

Description
Is the parameter x CDATA


contents-data?


Form
(contents-data? x)

Description
Is the parameter x either an ast or a contents string.


forced-white-space?


Form
(forced-white-space? x)

Description
Is the parameter x a white space mark.


white-space-suppress?


Form
(white-space-suppress? x)

Description
Is the parameter x a white suppress space mark.


white-space-related?


Form
(white-space-related? x)

Description
Is the parameter x white space related?


terminal-ast-node?


Form
(terminal-ast-node? x)

Description
Is x an ast nodes without subtrees?


ast-of-type?


Form
(ast-of-type? type name)

Description
A higher-order function that returns an AST predicate, which checks if the type of the AST is name. The type is either element-name, kind, or language (a symbol). 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.


aggregated-ast-cdata-contents


Form
(aggregated-ast-cdata-contents ast)

Description
Return a string of the aggregated CDATA contents of ast. White space markers are taken into account. AST subtrees are of ast are just ignored.


 

5.   XML LANGUAGE BOOKKEEPING.


xml-in-laml-name-clashes


Form
xml-in-laml-name-clashes

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


register-xml-in-laml-language


Form
(register-xml-in-laml-language language language-map)

Description
Register that language (the first parameter) is an XML language in use in the current LAML session. The first parameter, language, is a symbol. The second parameter, language-map, is the language map of the language. As a precondition is a assumed that we do not register the same language more than once.


language-map-of


Form
(language-map-of language)

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


language-in-use?


Form
(language-in-use? language)

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


languages-in-use


Form
(languages-in-use)

Description
Return the list of language in used, as registered by register-xml-in-laml-language.


element-names-of-language


Form
(element-names-of-language language)

Description
Return the element names of language, as defined by its language map.


causes-xml-in-laml-name-clash?


Form
(causes-xml-in-laml-name-clash? name)

Description
Is name involed in a name clash among the registered xml-in-laml languages?


 

6.   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 the language map is an association list from element names (symbols) to function objects. In the longer run, it should be more efficient search structure.


get-mirror-function


Form
(get-mirror-function language-map element-name)

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


put-mirror-function


Form
(put-mirror-function language-map element-name mirror-function)

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


 

7.   MIRROR GENERATION FUNCTIONS.
The functions in this sections are the important and 'heavy' mirror generation functions.


xml-sort-tag-parameters


Form
(xml-sort-tag-parameters parameters tag-name [language])

Description
Separates the parameter, 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.

See also
similar functionxml-sort-superficially-tag-parameters    


xml-sort-superficially-tag-parameters


Form
(xml-sort-superficially-tag-parameters parameters tag-name [language])

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

See also
similar functionxml-sort-tag-parameters    


generate-xml-mirror-function


Form
(generate-xml-mirror-function validation-procedure tag-name default-dtd-attributes single-double-kind language overlap-check? action-procedure)

Description
Return an XML mirror surface function, in which textual content parameters and attribute value pairs can be given in a very liberal fashion.

Parameters
validation-procedurethe procedure that validates all aspects of the application of the element mirror function.
tag-namea string which represents the name of the tag (used for error message purposes).
default-dtd-attributesan alist of attribute key value pairs, as specified in the DTD.
single-double-kindeither the symbol single, double or possible-single.
languagethe language in use (a symbol).
overlap-check?controls whether to check for name clashes in between the registered XML-in-LAML languages.
action-procedureserves both as a boolean and a procedure. If non-false, the parameter servers as action procedure, which will receive the AST for action purposes.


 

8.   CONTENTS VALIDATION.
The definitions in this section is used by the validation procedures, which are specific for each supported XML language


one-or-more


Form
(one-or-more . element-constituent-list)

Description
Return a predicate which checks whether the contents matches one or more instances from element-constituent-list. Element constituent-list is a list of strings, namely element tag names or "#PCDATA". A true results means OK - no error Avoid a O(n^2) algorithm here in the final implementation


zero-or-more


Form
(zero-or-more . element-constituent-list)

Description
Return a predicate which checks whether the contents matches zero or more instances from element-constituent-list


sequence-with-optionals


Form
(sequence-with-optionals . rhs-elements)

Description
Return a predicate which checks whether the contents match the sequential rhs-elements. rhs-elements is a list of strings or symbols, where symbols represent optionals. Example (sequence-with-optionals "xxx" "yyy" 'zzz) corresponds to xxx, yyy, zzz? We assume that rhs-elements, in the starting point, always contains at least one element.


pcdata-checker


Form
(pcdata-checker contents)

Description
A predicate which checks whether the contents is PCDATA.


xml-add-problem!


Form
(xml-add-problem! error-message)

Description
The procedure for reporting validation problems. Adds error message to xml-problem-contents-list and returns #f, as an indication of validation failure.


xml-enrich-error-message


Form
(xml-enrich-error-message error-message constituent)

Description
Enrich an error message with info about a constitutent (AST)


xml-enrich-error-messages


Form
(xml-enrich-error-messages error-message-list constituent)

Description
Enrich a list of error messages with info about a constitutent (AST)


 

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


xml-check-attributes!


Form
(xml-check-attributes! attributes dtd-attribute-definition number-of-req-attributes tag-name)

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


display-xml-warning


Form
(display-xml-warning . messages)

Description
A variant of display-warning which prefixes the warning text with a 'XML Warning' prefix.


xml-check-error


Form
(xml-check-error . messages)

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

See also
default valuedisplay-xml-warning    
alternative valuelaml-error


 

10.   RENDERING FUNCTIONS AND PROCEDURES.
The functions and procedures in this section transform the internal document representation (abstract syntax trees) to a textual form (text strings).


render-to-output-port


Form
(render-to-output xml-clause output-port [prolog epilog])

Description
Render the XML clause (an AST) to output-port. output-port is assumed to be open. output-port will not be closed by this procedure.

Parameters
xml-clausean AST
output-portan open output port
prologThe symbol prolog, in which case (standard-prolog) is inserted, or a prolog string to be inserted
epilogThe symbol epilog in which case (standard-epilog) is inserted, or a epilog string to be inserted

See also
standard-prologlaml.scm
standard-epiloglaml.scm


xml-render


Form
(render xml-clause [prolog epilog])

Description
Render the xml-clause (an AST) and return the rendered string

Parameters
xml-clausean AST
prologThe symbol prolog, in which case (standard-prolog) is inserted, or a prolog string to be inserted
epilogThe symbol epilog in which case (standard-epilog) is inserted, or a epilog string to be inserted


 

11.   ELEMENT RELATED FUNCTIONS.
This section contains (mostly) higher-order functions that are related to the mirrors of the XML elements.


xml-modify-element


Form
(xml-modify-element element . attributes-and-contents)

Description
Bind some attributes content elements of element (the first parameter) and return a new, 'modified element function'. With this, some attributes and some content elements are pre-bound to certain values in the modified element. The parameter attributes-and-contents is of the same form as the parameters to a LAML surface mirror functions. In fact, attributes-and-contents is appended to the actual parameters, which are passed to the modified element function.

Returns
an attribute-modified mirror function

Example
(define a-main (modify-element a 'target "main"))

See also
similar functionxml-modify-element-prepend    


xml-modify-element-prepend


Form
(xml-modify-element-prepend element . attributes-and-contents)

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

See also
similar functionxml-modify-element    


 

12.   XML IN LAML PARAMETRIZATION AND ABSTRACTION FUNCTIONS.
The functions in this category are higher-order functions which generate functions that obey XML-in-LAML parameter passing rules. In other words, the function that are generated use the same parameter conventions as the mirror functions of the HTML and XML elements.


xml-in-laml-parametrization


Form
(xml-in-laml-parametrization f parameter-mediator [parameter-validator! f-name])

Description
Generate a function with XML-in-LAML parameter passing rules which sends its input to an ordinary function 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 optional 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).

See also
applied functionxml-sort-tag-parameters    
similar functionxml-in-laml-abstraction    
useful par. validatorrequired-implied-attributes    

Note
See the LAML tutorial - authoring with higher-order functions - for additional discussion and examples.


xml-in-laml-abstraction


Form
(xml-in-laml-abstraction f [parameter-validator! f-name])

Description
Generate a function with XML-in-LAML parameter passing rules which sends its input to an XML or HTML mirror function, or to another XML-in-LAML abstraction. The first parameter, f, is supposed to call one or more XML or HTML mirror function, or another XML-in-LAML abstraction. The function f takes two parameters: A content list and an attribute property list. 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
fA transformer function of two parameters - contents and the attribute property list
parameter-validator!A checking procedure of two parameters - contents and the attribute property list. Must report errors explicitly by xml-check-error.
f-nameThe name of abstraction - used for error message purposes

See also
applied functionxml-sort-superficially-tag-parameters    
similar functionxml-in-laml-parametrization    
useful par. validatorrequired-implied-attributes    

Note
See the LAML tutorial - authoring with higher-order functions - 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-namesA list of attribute names (symbols) which are required.
implied-attribute-namesA list of additional attribute names (symbols) which are allowed, or the list (*) - a singleton list with the symbol * - in the meaning of any attribute.

See also
relevant context of usexml-in-laml-abstraction    xml-in-laml-parametrization    
error functionxml-check-error    


 

13.   AST TRAVERSAL AND ATTRIBUTE GETTER FUNCTIONS.
The AST traversal functions extract information from AST by means of traversal and searching. The AST attribute getter functions extract attribute values from the attribute list of an AST.


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 those subtrees that satisfy the node-interesting? predicate. Non-AST constituents of the AST (CDATA and white space markers) are not visited during the traversal. The traversal is done in pre-order. In fact, return the transformed ASTs, applying ast-transformer on each returned tree. The higher-order function ast-of-type? generates useful node-interesting? functions.

See also
useful as parameterast-of-type?    


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 the first subtree which satisfies node-interesting. 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. The higher-order function ast-of-type? generates useful node-interesting? functions.

See also
useful as parameterast-of-type?    


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-namethe attribute name - a symbol.
default-valuethe default value returned if there is no attribute named attribute-name in the attribute-list.


 

14.   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.

Preconditions
The LAML tool html-support (for parsing and pretty printing) must be loaded for this function to work.

Note
To load html-support: (laml-tool-load "xml-html-support/html-support.scm")


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