Package: xuriella

Function apply-stylesheet

Lambda List

apply-stylesheet (stylesheet source-designator &key output parameters uri-resolver navigator)

Arguments

stylesheet -- a stylesheet designator (see below for details)
source-designator -- a source document designator (see below for details)
output -- optional output sink designator (see below for details)
parameters -- a list of parameter instances
uri-resolver -- optional function of one argument
navigator -- optional XPath navigator

Return Value

The value returned by sax:end-document when called on the designated output sink.

Details

Apply a stylesheet to a document.

This function takes a stylesheet (either a parsed stylesheet or a designator for a XML file to be parsed) and a source document, specified using the XML designator source-designator, and applies the stylesheet to the document.

An XML designator is any value accepted by cxml:parse, in particular:
Pathnames
The file referred to by the pathname will parsed using cxml.
Stream
The stream will be parsed using cxml.
Xstream
Similar to the stream case, but using cxml's internal representation of rune streams.
String
The string itself will be parsed as an XML document, and is assumed to have been decoded into characters already.
Array of (unsigned-byte 8)
The array itself will be parsed as an XML document (which has not been decoded yet).
Note: Since strings are interpreted as documents, namestrings are not acceptable. Use pathnames instead of namestrings.

An output sink designator has the following form:
Null
Designates a string sink. I.e., the result document of the stylesheet will be returned as a string. This is the default.
Pathnames
The file referred to by the pathname will created and written to.
Stream
The stream will be written to.
SAX or HAX handler
Events will be sent directly to this sink.
Note: Specificaton of a sink overrides the specification of XML or HTML output method in the stylesheet.

Parameters are identified by names, and have values that are strings. Top-level parameters of these names are bound accordingly. If a paramater is not specified, its default value is computed as implemented in the stylesheet. If parameters are specified that the stylesheet does not recognize, they will be ignored.

A uri-resolver is a function taking a PURI object as an argument and returning a PURI object as a value. The URI resolver will be invoked for all references to external files, e.g. at compilation time using xsl:import and xsl:include, and at run-time using the document() function.

The URI resolver can be used to rewrite URLs so that file http:// links are replaced by file:// links, for example. Another application are URI resolvers that signal an error instead of returning, for example so that file:// links are forbidden.

The specified navigator will be passed to XPath protocol functions.
 

See also