Transformation Source |
XM_XSLT_SOURCE is an interface for the various sources of data, both for source documents and stylesheets, along with routines to build a tree representation of the data.
The interface has deferred features set_system_id (a_system_id: STRING) and system_id: STRING for naming the source. But the principal deferred feature is send (a_parser: XM_PARSER; a_receiver: XM_XPATH_RECEIVER; is_stylesheet: BOOLEAN).
Send is called by the system to build a representation of the data which can be used by the stylesheet compiler and/or the transformer. The meaning of the arguments is as follows:
In summary, when send is called, an implementation must check the string mode on the supplied parser, and then generate an event stream to the receiver.
The system provides the following implementation:
This class provides an additional feature, send_from_stream, which is used by the library for xsl:import, xsl:include and document() processing. Your own implementations should not implement this routine, as it will not be called by the library.
Possible future library-supplied implementations include XM_XSLT_RECEIVER_SOURCE and XM_XSLT_XM_CALLBACKS_SOURCE, to direct existing event streams to the receiver. The former may be need for simple pipeling of multiple transformations. The latter could be useful for bridging between application which are already programmed to use the XM_CALLBACKS interface, and the XSLT library. I can also envisage a variation on the latter, XM_DOCUMENT_SOURCE, where an XM_DOCUMENT is turned into an XPath data model. This will be expensive on memory (two representations of the same tree in memory). An alternative approach is to virtualize an XPath data model over an XM_DOCUMENT. This would be more expensive on CPU cycles.
Normally, you will not need to write an implementation of XM_XSLT_SOURCE. If you have a mechanism for supplying XML data in a textual form, and a suitable URI scheme to associate with it, then you should only have to implement XM_URI_RESOLVER. In this case, XM_XSLT_URI_SOURCE will handle your data source transparently. Only when your data source cannot be supplied as a KI_CHARACTER_INPUT_STREAM supplying XML text, will you need to write an XM_XSLT_SOURCE.
If you cannot write an (or use an existing) implementation of XM_URI_RESOLVER for your data source, then you cannot use that data source as an xsl:import, xsl:include or document() or doc() source.
Copyright © 2004, Colin Adams and others mailto:colin@colina.demon.co.uk http://www.gobosoft.com Last Updated: Friday, October 29th, 2004 |