|
Unicorn XML Toolkit Version 1.50.00 |
|||||||||
� PREV CLASS �� NEXT CLASS | FRAMES��NO FRAMES | |||||||||
SUMMARY: � CONSTR �|� FUNCTION �|�DATA | DETAIL: � CONSTR �|� FUNCTION �|�DATA |
class CXsltProcessor: public Sax::CXmlReader { public: CXsltProcessor(CToolkitBase *pToolkitBase); ~CXsltProcessor(); public: void SetFeature( const WCHAR *pszName, bool bValue); bool GetFeature(const WCHAR *pszName); void SetProperty( const WCHAR *pszName, CInterface *pValue); CInterface *GetProperty(const WCHAR *pszName); void SetEntityResolver(Sax::CEntityResolver *pResolver); Sax::CEntityResolver *GetEntityResolver(); void SetDtdHandler(Sax::CDtdHandler *pHandler); Sax::CDtdHandler *GetDtdHandler(); void SetContentHandler(Sax::CContentHandler *pHandler); Sax::CContentHandler *GetContentHandler(); void SetErrorHandler(Sax::CErrorHandler *pHandler); Sax::CErrorHandler *GetErrorHandler(); void Parse(Sax::CInputSource *pInput); void Parse(const WCHAR *pszSystemId); public: void SetNamespaces(bool bNamespaces); bool GetNamespaces(); void SetInputSource(Sax::CInputSource *pInputSource); Sax::CInputSource *GetInputSource(); void Start(); public: void SetSourceUri(const WCHAR *pszUri); CString GetSourceUri(); void SetSourceNode(Dom::INode *pNode); Dom::XNode GetSourceNode(); void SetSourceDirect(bool bDirect); bool GetSourceDirect(); void SetSourceReader(Sax::CXmlReader *pReader); Sax::CXmlReader *GetSourceReader(); public: void SetStylesheetUri(const WCHAR *pszUri); CString GetStylesheetUri(); void SetStylesheetNode(Dom::INode *pNode); Dom::XNode GetStylesheetNode(); void SetStylesheetReader(Sax::CXmlReader *pReader); Sax::CXmlReader *GetStylesheetReader(); void SetStylesheet(CXsltStylesheet *pStylesheet); CXsltStylesheet *GetStylesheet(); public: void SetResultUri(const WCHAR *pszUri); CString GetResultUri(); void SetResultNode(Dom::INode *pNode); Dom::XNode GetResultNode(); void SetResultHandler(Sax::CContentHandler *pHandler); Sax::CContentHandler *GetResultHandler(); public: void ResetParam(); void SetParam(const WCHAR *pszName, bool bValue); void SetParam(const WCHAR *pszName, double dblValue); void SetParam(const WCHAR *pszName, const WCHAR *pszValue); public: void Reset(); }; typedef XInterface<CXsltProcessor> XXsltProcessor;
The XSLT processor.
XSLT processor is designed to transform XML documents using
the
XSL Transformations (XSLT)
Version 1.0
technology. At present, the toolkit's
XSLT processor fully implements the W3C XSLT 1.0 recommendation,
with the single exception of
format-number
function.
Before starting the XSLT processor, the application programmer must specify the following properties:
Uri
for details of the URI support)CXsltStylesheet
).
When the source document is specified as a DOM/XDM root node, the XSLT processor will by default create an internal duplicate image of the source XML content before starting transformation. This is needed to achieve the compliance with XSLT processing model (for example, to handle the whitespaces in the source document properly). Such duplication may be undesirable in some cases. To avoid it, the toolkit provides a separate "direct" mode, which allows dealing with the source documents represented using XDM data model. When a direct mode is specified, the XSLT engine acts directly on the supplied XDM document tree, without consuming extra time and memory for building the internal duplicate. Note that direct mode is not available for source documents represented using DOM data model.
XSLT processors can participate in SAX content event
producer/consumer pipelines. This feature is implemented by
subclassing the
Sax::CXmlReader
class.
Each XSLT processor object implements therefore the standard
SAX XML reader interface and can be used in contexts where
XML readers are required. A SAX content handler, which
will consume the result produced by the XSLT processor can
be registered using the SAX
SetContentHandler
method;
the effect is equivalent to setting the result content handler
using the proprietary
SetResultHandler
method of the XSLT processor. Note that effectively an XSLT processor
may serve as a filter placed between a SAX XML reader and a SAX content
handler, although formally XSLT processor is not a SAX XML filter.
An application programmer may pass the list of stylesheet parameters
to the transformation engine. These parameters will be assigned
to the XSLT parameters specified via top-level
xsl:param
stylesheet elements. Each parameter passed to the transformation
engine is identified by its name, which must be an XML
QName
.
Parameter names defined by the application programmer are converted
to XSLT expanded names using the namespace declarations on the root
element of the stylesheet. Expanded names are used for mapping
between parameter values passed to the transformation engine and
top-level
xsl:param
stylesheet elements.
CToolkitBase, Sax::CXmlReader, Dom::INode
Constructor/Destructor Summary | |
CXsltProcessor
(CToolkitBase *pToolkitBase);
����������Constructs the XSLT processor. |
|
~CXsltProcessor
();
����������Destroys the XSLT processor. |
Function Summary | |
void
|
SetFeature
(const WCHAR *pszName, bool bValue);
����������Sets the state of a feature. |
bool
|
GetFeature
(const WCHAR *pszName);
����������Looks up the value of a feature. |
void
|
SetProperty
(const WCHAR *pszName, CInterface *pValue);
����������Sets the value of a property. |
CInterface�*
|
GetProperty
(const WCHAR *pszName);
����������Looks up the value of a property. |
void
|
SetEntityResolver
(Sax::CEntityResolver *pResolver);
����������Allows an application to register an entity resolver. |
Sax::CEntityResolver�*
|
GetEntityResolver
();
����������Gets the current entity resolver. |
void
|
SetDtdHandler
(Sax::CDtdHandler *pHandler);
����������Allows an application to register a DTD event handler. |
Sax::CDtdHandler�*
|
GetDtdHandler
();
����������Gets the current DTD handler. |
void
|
SetContentHandler
(Sax::CContentHandler *pHandler);
����������Allows an application to register a content event handler. |
Sax::CContentHandler�*
|
GetContentHandler
();
����������Gets the current content handler. |
void
|
SetErrorHandler
(Sax::CErrorHandler *pHandler);
����������Allows an application to register an error event handler. |
Sax::CErrorHandler�*
|
GetErrorHandler
();
����������Gets the current error handler. |
void
|
Parse
(Sax::CInputSource *pInput);
����������Parses an XML document. |
void
|
Parse
(const WCHAR *pszSystemId);
����������Parses an XML document from a system identifier (URI). |
void
|
SetNamespaces
(bool bNamespaces);
����������Specifies whether content events generated by the reader provide namespace information. |
bool
|
GetNamespaces
();
����������Tests whether content events generated by the reader provide namespace information. |
void
|
SetInputSource
(Sax::CInputSource *pInputSource);
����������Sets the input source. |
Sax::CInputSource�*
|
GetInputSource
();
����������Gets the current input source. |
void
|
Start
();
����������Starts the XSLT processor. |
void
|
SetSourceUri
(const WCHAR *pszUri);
����������Sets an URI for a source XML document. |
CString
|
GetSourceUri
();
����������Returns the URI for a source XML document |
void
|
SetSourceNode
(Dom::INode *pNode);
����������Sets a root node for a source XML document. |
Dom::XNode
|
GetSourceNode
();
����������Returns the root node for a source XML document. |
void
|
SetSourceDirect
(bool bDirect);
����������Enables/disables direct source mode. |
bool
|
GetSourceDirect
();
����������Returns the direct source mode settings. |
void
|
SetSourceReader
(Sax::CXmlReader *pReader);
����������Sets a SAX reader for a source XML document. |
Sax::CXmlReader�*
|
GetSourceReader
();
����������Returns the SAX reader for a source XML document. |
void
|
SetStylesheetUri
(const WCHAR *pszUri);
����������Sets an URI for an XSLT stylesheet. |
CString
|
GetStylesheetUri
();
����������Returns the URI for an XSLT stylesheet |
void
|
SetStylesheetNode
(Dom::INode *pNode);
����������Sets a root node for an XSLT stylesheet. |
Dom::XNode
|
GetStylesheetNode
();
����������Returns the root node for an XSLT stylesheet. |
void
|
SetStylesheetReader
(Sax::CXmlReader *pReader);
����������Sets an XML reader for an XSLT stylesheet. |
Sax::CXmlReader�*
|
GetStylesheetReader
();
����������Returns the XML reader for an XSLT stylesheet. |
void
|
SetStylesheet
(CXsltStylesheet *pStylesheet);
����������Sets a precompiled XSLT stylesheet object. |
CXsltStylesheet�*
|
GetStylesheet
();
����������Returns the precompiled XSLT stylesheet object. |
void
|
SetResultUri
(const WCHAR *pszUri);
����������Sets an URI for a transformation result destination. |
CString
|
GetResultUri
();
����������Returns the URI for a transformation result destination. |
void
|
SetResultNode
(Dom::INode *pNode);
����������Sets a root node for a transformation result. |
Dom::XNode
|
GetResultNode
();
����������Returns the root node for a transformation result. |
void
|
SetResultHandler
(Sax::CContentHandler *pHandler);
����������Sets a content handler for a transformation result. |
Sax::CContentHandler�*
|
GetResultHandler
();
����������Returns the content handler for a transformation result. |
void
|
ResetParam
();
����������Makes the list of stylesheet parameters empty. |
void
|
SetParam
(const WCHAR *pszName, bool bValue);
����������Adds a boolean value to the list of stylesheet parameters. |
void
|
SetParam
(const WCHAR *pszName, double dblValue);
����������Adds a number value to the list of stylesheet parameters. |
void
|
SetParam
(const WCHAR *pszName, const WCHAR *pszValue);
����������Adds a string value to the list of stylesheet parameters. |
void
|
Reset
();
����������Invalidates all XSLT processor properties describing a source XML document, an XSLT stylesheet, a transformation result destination, and stylesheet parameters. |
Constructor/Destructor Detail |
CXsltProcessor(CToolkitBase *pToolkitBase);
Constructs the XSLT processor.
pToolkitBase
- the master toolkit base~CXsltProcessor();
Destroys the XSLT processor.
Function Detail |
void SetFeature( const WCHAR *pszName, bool bValue);
Sets the state of a feature.
See
Sax::CXmlReader::SetFeature
for a detailed
discussion concerning SAX reader features.
pszName
- the feature name, which is a fully-qualified URIbValue
- the requested state of the feature
(
true
or
false
)bool GetFeature(const WCHAR *pszName);
Looks up the value of a feature.
See
Sax::CXmlReader::GetFeature
for a detailed
discussion concerning SAX reader features.
pszName
- the feature name, which is a fully-qualified URItrue
or
false
)void SetProperty( const WCHAR *pszName, CInterface *pValue);
Sets the value of a property.
See
Sax::CXmlReader::SetProperty
for a detailed
discussion concerning SAX reader properties.
pszName
- the property name, which is a fully-qualified URIpValue
- the requested value for the property,
which is an interface pointerCInterface *GetProperty(const WCHAR *pszName);
Looks up the value of a property.
See
Sax::CXmlReader::GetProperty
for a detailed
discussion concerning SAX reader properties.
pszName
- the property name, which is a fully-qualified URIvoid SetEntityResolver(Sax::CEntityResolver *pResolver);
Allows an application to register an entity resolver.
Note that XSLT processors do not use entity resolvers, and this method is a stub implemented for the formal SAX compatibility only.
pResolver
- the entity resolverSax::CEntityResolver *GetEntityResolver();
Gets the current entity resolver.
NULL
if none has been registeredvoid SetDtdHandler(Sax::CDtdHandler *pHandler);
Allows an application to register a DTD event handler.
Note that XSLT processors do not generate DTD events, and this method is a stub implemented for the formal SAX compatibility only.
pHandler
- the DTD handlerSax::CDtdHandler *GetDtdHandler();
Gets the current DTD handler.
NULL
if none has been registeredvoid SetContentHandler(Sax::CContentHandler *pHandler);
Allows an application to register a content event handler.
This method is equivalent to the proprietary method
SetResultHandler
of the XSLT processor.
pHandler
- the content handlerSax::CContentHandler *GetContentHandler();
Gets the current content handler.
NULL
if none has been registeredvoid SetErrorHandler(Sax::CErrorHandler *pHandler);
Allows an application to register an error event handler.
Note that XSLT processors do not generate error events, and this method is a stub implemented for the formal SAX compatibility only.
pHandler
- the error handlerSax::CErrorHandler *GetErrorHandler();
Gets the current error handler.
NULL
if none has been registeredvoid Parse(Sax::CInputSource *pInput);
Parses an XML document.
Note that, although implementing SAX XML reader interface,
XSLT processors are not true XML parsers, and this method is a stub
implemented for the formal SAX compatibility only. When called, this method
throws
Sax::CSaxNotSupportedException
.
pInput
- the input source for
the top-level of the XML documentvoid Parse(const WCHAR *pszSystemId);
Parses an XML document from a system identifier (URI).
Note that, although implementing SAX XML reader interface,
XSLT processors are not true XML parsers, and this method is a stub
implemented for the formal SAX compatibility only. When called, this method
throws
Sax::CSaxNotSupportedException
.
pszSystemId
- the system identifier (URI)void SetNamespaces(bool bNamespaces);
Specifies whether content events generated by the reader provide namespace information.
bNamespaces
-
true
if content events
generated by this reader must provide namespace information;
false
otherwisebool GetNamespaces();
Tests whether content events generated by the reader provide namespace information.
true
if content events
generated by this reader provide namespace information;
false
otherwisevoid SetInputSource(Sax::CInputSource *pInputSource);
Sets the input source.
Note that, although implementing SAX XML reader interface,
XSLT processors are not true XML parsers, and this method is a stub
implemented for the formal SAX compatibility only. When called, this method
throws
Sax::CSaxNotSupportedException
.
pInputSource
- the input sourceSax::CInputSource *GetInputSource();
Gets the current input source.
Note that, although implementing SAX XML reader interface,
XSLT processors are not true XML parsers, and this method is a stub
implemented for the formal SAX compatibility only. When called, this method
throws
Sax::CSaxNotSupportedException
.
NULL
if none has been registeredvoid Start();
Starts the XSLT processor.
When started, the XSLT processor will transform the specified source document using the specified stylesheet; the output will be transferred to the specified result destination.
void SetSourceUri(const WCHAR *pszUri);
Sets an URI for a source XML document.
This URI is used as a definitive specification of a source XML document unless a source XML reader or a source DOM/XDM node is specified, in which case the URI serves for diagnostic purposes only.
See
Uri
for details of the URI support.
pszUri
- the source XML document URICString GetSourceUri();
Returns the URI for a source XML document
void SetSourceNode(Dom::INode *pNode);
Sets a root node for a source XML document.
This method invalidates previous setting for a source XML reader or a source DOM/XDM node, if any.
Both DOM and XDM document models are supported,
unless direct processing mode is set with
SetSourceDirect
,
in which case only XDM model is allowed.
The root node must be either a document or an element.
pNode
- the root node for a source XML documentDom::XNode GetSourceNode();
Returns the root node for a source XML document.
NULL
if non was specifiedvoid SetSourceDirect(bool bDirect);
Enables/disables direct source mode.
In the direct mode, the XSLT processor avoids building of the internal representation of the source document, using the specified source XDM node directly. Direct source mode is ignored if the source document is specified using URI or XML reader. It is an error if direct source mode is specified for a source DOM node; this error is detected and reported when the processor is started.
bDirect
-
true
to enable
direct source mode;
false
to disable itbool GetSourceDirect();
Returns the direct source mode settings.
true
if direct source mode
is enables;
false
otherwisevoid SetSourceReader(Sax::CXmlReader *pReader);
Sets a SAX reader for a source XML document.
This method invalidates previous setting for a source XML reader or a source DOM/XDM node, if any.
pReader
- the SAX reader for a source XML documentSax::CXmlReader *GetSourceReader();
Returns the SAX reader for a source XML document.
NULL
is none was specifiedvoid SetStylesheetUri(const WCHAR *pszUri);
Sets an URI for an XSLT stylesheet.
This URI is used as a definitive specification of an XSLT stylesheet unless a stylesheet XML reader or a stylesheet DOM/XDM node is specified, in which case the URI serves for diagnostic purposes only.
See
Uri
for details of the URI support.
pszUri
- the stylesheet URICString GetStylesheetUri();
Returns the URI for an XSLT stylesheet
void SetStylesheetNode(Dom::INode *pNode);
Sets a root node for an XSLT stylesheet.
This method invalidates previous setting for a stylesheet XML reader, a stylesheet DOM/XDM node, or a precompiled stylesheet object, if any.
Both DOM and XDM document models are supported. The root node must be either a document or an element corresponding to a stylesheet root.
pNode
- the root node for an XSLT stylesheetDom::XNode GetStylesheetNode();
Returns the root node for an XSLT stylesheet.
NULL
if none was specifiedvoid SetStylesheetReader(Sax::CXmlReader *pReader);
Sets an XML reader for an XSLT stylesheet.
This method invalidates previous setting for a stylesheet XML reader, a stylesheet DOM/XDM node, or a precompiled stylesheet object, if any.
pReader
- the XML reader for an XSLT stylesheetSax::CXmlReader *GetStylesheetReader();
Returns the XML reader for an XSLT stylesheet.
NULL
if none was specifiedvoid SetStylesheet(CXsltStylesheet *pStylesheet);
Sets a precompiled XSLT stylesheet object.
This method invalidates previous setting for a stylesheet XML reader, a stylesheet DOM/XDM node, or a precompiled stylesheet object, if any.
pStylesheet
- the precompiled stylesheet objectCXsltStylesheet *GetStylesheet();
Returns the precompiled XSLT stylesheet object.
NULL
if none was specifiedvoid SetResultUri(const WCHAR *pszUri);
Sets an URI for a transformation result destination.
This URI is used as a definitive specification of a transformation result destination unless a result XML reader or a result DOM/XDM node is specified, in which case the URI serves for diagnostic purposes only.
See
Uri
for details of the URI support.
pszUri
- the URI for a transformation result
destinationCString GetResultUri();
Returns the URI for a transformation result destination.
NULL
if none was specifiedvoid SetResultNode(Dom::INode *pNode);
Sets a root node for a transformation result.
The transformation result will be converted to a newly constructed sub-tree built under the specified root node. In particular, if an empty document node is specified as the root, the entire document tree will be built as the result of transformation. The root node must be allowed to hold a type of content produced as the result of transformation.
This method invalidates previous setting for a result content handler or a result DOM/XDM node, if any.
Both DOM and XDM document models are supported.
pNode
- the root node for a transformation resultDom::XNode GetResultNode();
Returns the root node for a transformation result.
NULL
if none was specifiedvoid SetResultHandler(Sax::CContentHandler *pHandler);
Sets a content handler for a transformation result.
This method invalidates previous setting for a result content handler or a result DOM/XDM node, if any.
This method is equivalent to the standard SAX method
SetContentHandler
.
pHandler
- the content handler for
a transformation resultSax::CContentHandler *GetResultHandler();
Returns the content handler for a transformation result.
NULL
if none was specifiedvoid ResetParam();
Makes the list of stylesheet parameters empty.
void SetParam(const WCHAR *pszName, bool bValue);
Adds a boolean value to the list of stylesheet parameters.
pszName
- the qualified name of the parameterbValue
- the boolean parameter valuevoid SetParam(const WCHAR *pszName, double dblValue);
Adds a number value to the list of stylesheet parameters.
pszName
- the qualified name of the parameterdblValue
- the number parameter valuevoid SetParam(const WCHAR *pszName, const WCHAR *pszValue);
Adds a string value to the list of stylesheet parameters.
pszName
- the qualified name of the parameterpszValue
- the string parameter valuevoid Reset();
Invalidates all XSLT processor properties describing a source XML document, an XSLT stylesheet, a transformation result destination, and stylesheet parameters.
|
Unicorn XML Toolkit Version 1.50.00 |
|||||||||
� PREV CLASS �� NEXT CLASS | FRAMES��NO FRAMES | |||||||||
SUMMARY: � CONSTR �|� FUNCTION �|�DATA | DETAIL: � CONSTR �|� FUNCTION �|�DATA |