Configuring the XSLT processor PreviousNext

The configuration of the processor is controlled by XM_XSLT_CONFIGURATION. This has two creation procedures, make and make_with_defaults. The latter creation procedure takes no arguments, and sets up convenient defaults (as used by the command-line processor gexslt). We will look in detail at the arguments to make.

The Entity Resolver

The first argument is an XM_URI_EXTERNAL_RESOLVER, for use by the XML parser to resolve PUBLIC and SYSTEM external identifiers. The creation procedure make_with_defaults uses a catalog resolver, XM_CATALOG_RESOLVER, to look up the external identifiers in an OASIS ETRC XML catalog.

You can disable the actual catalog lookup by inheriting from XM_SHARED_CATALOG_MANAGER and calling shared_catalog_manager.suppress_catalogs. In which case you will get resolution of the SYSTEM identifier, providing it's URI scheme is one of the registered schemes. By default, only file and data are registered. You can register handlers for additional URI schemes by creating a descendant of XM_URI_RESOLVER and passing it as the sole argument to shared_catalog_manager.bootstrap_resolver.uri_scheme_resolver.register_scheme. You can do this even if you don't disable the catalog lookup.

Despite the flexibility of the catalog resolver, you may still want to provide your own resolver (if you want to resolve external entities from a relational database manager, for instance). Just create your own, and pass it as the first argument to make.

The URI Resolver

The second argument is an XM_URI_REFERENCE_RESOLVER. This is used to resolve URIs given by the xsl:include and xsl:import instructions, and the document() function. make_with_defaults passes the same catalog resolver as it does for the first argument, but there is no obligation that the two arguments must receive the same object.

The Output Resolver

The third argument is an XM_XSLT_OUTPUT_URI_RESOLVER. This is used to resolve the destination URI specified by the href attribute of xsl:result-document. It is not used to resolve the principal output destination, as that is under the direct control of the user of the XSLT library, not the stylesheet author.

make_with_defaults passes an XM_XSLT_DEFAULT_OUTPUT_URI_RESOLVER.

The Error Listener

The fourth argument is an XM_XSLT_ERROR_LISTENER. This receives notifications of warnings, recoverable errors and fatal errors.

make_with_defaults passes an XM_XSLT_DEFAULT_ERROR_LISTENER.

The Encoder Factory

The fifth argument is an XM_XSLT_ENCODER_FACTORY. This creates output encoders for the various character encodings supported by the library.

If you need to create output files in an encoding which is not supported by the library, then you will need to create a descendant of XM_XSLT_OUTPUT_ENCODER, and a descendant of XM_XSLT_ENCODER_FACTORY to create your encoder (but better would be to offer your encoder to Gobo, for inclusion in the library, if that is possible for you).

The Message Emitter Factory

To control the destination of output fron xsl:message instructions, the configuration supports a feature set_message_emitter_factory. This takes as a single argument an object of type XM_XSLT_MESSAGE_EMITTER_FACTORY. The default factory creates an object of type XM_XSLT_MESSAGE_EMITTER, but if you look at the source code, then you will see that the interface fror the created objects is only an XM_XPATH_RECEIVER.

The sole feature of the factory is new_message_emitter. As arguments, this receives a reference to the transformer, an XM_OUTPUT for performing output (configured to write to standard error by default, but you can freely change this within new_message_emitter), and an XM_XSLT_OUTPUT_PROPERTIES. This last object is initialized to the defaults for the xml output method. it is present for use by an XM_XSLT_XML_EMITTER, but there is currently no way that the XSLT programmer can set it's contents. If programmers see a need, then we could add a User-defined Data Element which would enable stylesheet authors to code the same parameters as you can currently code on xsl:output or xsl:result-document, to affect the way in which xsl:message output is serialized.

Other features of the configuration

The following other features are of interest to the Eiffel programmer:

set_trace_listener (a_trace_listener: XM_XSLT_TRACE_LISTENER)
This sets the trace_listener. Setting it to a non-Void value turns on stylesheet execution tracing. See XM_XSLT_TRACE_LISTENER for more details.
set_line_numbering (on_or_off: BOOLEAN)
Turns line numbering on and off in diagnostic messages (providing the error listener makes use of the information).
set_timing (on_or_off: BOOLEAN)
Turns the timing facility on or off.

If the timing facility is on, then each execution phase and build of a document tree prints timing information on the standard error stream.

use_tiny_tree_model (true_or_false: BOOLEAN)
Selects use of the tiny tree model for building in-memory representations of XML source documents (not used for the stylesheet). This is supposed to save memory, at the possible expense of execution time.
set_digits (digits: INTEGER)
Sets the number of digits to be used when performing decimal arithmetic with XPath expressions. The default is 18 digits, and it may not be set lower than this.
Sets the entity resolver for XML parsing.
Set the URI reference resolver for xsl:import/include processing, and for the document() function.
Prevents the XML parser from reading external DTDs. This applies to all uses of the fn:doc(), fn:document() and fn:collection() functions, as well as the principal source document and all tranformation modules.
set_recovery_policy (a_recovery_policy: INTEGER)
Sets the recovery policy for error listeners.

Copyright 2004-2016, Colin Adams and others
Last Updated: 27 December 2016