Configuring the XSLT processor |
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 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 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 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 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 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).
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.
The following other features are of interest to the Eiffel programmer:
If the timing facility is on, then each execution phase and build of a document tree prints timing information on the standard error stream.
Copyright © 2004-2016, Colin Adams and others mailto:colin@colina.demon.co.uk http://www.gobosoft.com Last Updated: 27 December 2016 |