Saxon/C  1.1.2
Saxon Processor library for C/C++/PHP
 All Classes Functions Variables
Public Member Functions | List of all members
XsltProcessor Class Reference

#include <XsltProcessor.h>

Public Member Functions

 XsltProcessor ()
 Default constructor. More...
 
 XsltProcessor (SaxonProcessor *proc, std::string cwd="")
 Constructor with the SaxonProcessor supplied. More...
 
void setcwd (const char *cwd)
 set the current working directory More...
 
void setSourceFromXdmValue (XdmItem *value)
 Set the source document from a XdmValue for the transformation. More...
 
void setSourceFromFile (const char *filename)
 
void setOutputFile (const char *outfile)
 
void setParameter (const char *name, XdmValue *value)
 
XdmValuegetParameter (const char *name)
 
bool removeParameter (const char *name)
 
void setProperty (const char *name, const char *value)
 
const char * getProperty (const char *name)
 
std::map< std::string,
XdmValue * > & 
getParameters ()
 Get all parameters as a std::map. More...
 
std::map< std::string,
std::string > & 
getProperties ()
 Get all properties as a std::map. More...
 
void clearParameters (bool deleteValues=false)
 Clear parameter values set. More...
 
void clearProperties ()
 Clear property values set.
 
XdmValuegetXslMessages ()
 
void transformFileToFile (const char *sourcefile, const char *stylesheetfile, const char *outputfile)
 Perform a one shot transformation. More...
 
const char * transformFileToString (const char *sourcefile, const char *stylesheetfile)
 Perform a one shot transformation. More...
 
XdmValuetransformFileToValue (const char *sourcefile, const char *stylesheetfile)
 
void compileFromFile (const char *stylesheet)
 compile a stylesheet file. More...
 
void compileFromString (const char *stylesheet)
 compile a stylesheet received as a string. More...
 
void compileFromStringAndSave (const char *stylesheet, const char *filename)
 compile a stylesheet received as a string and save to SEF file. More...
 
void compileFromFileAndSave (const char *xslFilename, const char *filename)
 compile a stylesheet received as a fileand save to SEF file. More...
 
void compileFromXdmNode (XdmNode *node)
 compile a stylesheet received as an XdmNode. More...
 
void releaseStylesheet ()
 Internal method to release cached stylesheet. More...
 
const char * transformToString ()
 Execute transformation to string. Properties supplied in advance. More...
 
XdmValuetransformToValue ()
 Execute transformation to Xdm Value. Properties supplied in advance. More...
 
void transformToFile ()
 Execute transformation to file. Properties supplied in advance. More...
 
bool exceptionOccurred ()
 
const char * checkException ()
 Check for exception thrown. More...
 
void exceptionClear ()
 Clear any exception thrown.
 
int exceptionCount ()
 Get number of errors reported during execution or evaluate of stylesheet. More...
 
const char * getErrorMessage (int i)
 Get the ith error message if there are any error. More...
 
const char * getErrorCode (int i)
 Get the ith error code if there are any error. More...
 
SaxonProcessorgetSaxonProcessor ()
 Get the SaxonProcessor object. More...
 

Detailed Description

An XsltProcessor represents factory to compile, load and execute a stylesheet. It is possible to cache the context and the stylesheet in the XsltProcessor.

Constructor & Destructor Documentation

XsltProcessor::XsltProcessor ( )

Default constructor.

Creates a Saxon-HE product

XsltProcessor::XsltProcessor ( SaxonProcessor proc,
std::string  cwd = "" 
)

Constructor with the SaxonProcessor supplied.

Parameters
proc- Supplied pointer to the SaxonProcessor object cwd - The current working directory

Member Function Documentation

const char * XsltProcessor::checkException ( )

Check for exception thrown.

Returns
cha*. Returns the exception message if thrown otherwise return NULL
void XsltProcessor::clearParameters ( bool  deleteValues = false)

Clear parameter values set.

Default behaviour (false) is to leave XdmValues in memory true then XdmValues are deleted

Parameters
deleteValues.Individual pointers to XdmValue objects have to be deleted in the calling program
void XsltProcessor::compileFromFile ( const char *  stylesheet)

compile a stylesheet file.

The compiled stylesheet is cached and available for execution later.

Parameters
stylesheet- The file name of the stylesheet document.
void XsltProcessor::compileFromFileAndSave ( const char *  xslFilename,
const char *  filename 
)

compile a stylesheet received as a fileand save to SEF file.

The compiled stylesheet is saved as SEF to file store

Parameters
xslFilename- file name of the stylesheet
filename- the file to which the compiled package should be saved
void XsltProcessor::compileFromString ( const char *  stylesheet)

compile a stylesheet received as a string.

The compiled stylesheet is cached and available for execution later.

Parameters
stylesheetas a lexical string representation
void XsltProcessor::compileFromStringAndSave ( const char *  stylesheet,
const char *  filename 
)

compile a stylesheet received as a string and save to SEF file.

The compiled stylesheet is saved as SEF to file store

Parameters
stylesheetas a lexical string representation
filename- the file to which the compiled package should be saved
void XsltProcessor::compileFromXdmNode ( XdmNode node)

compile a stylesheet received as an XdmNode.

The compiled stylesheet is cached and available for execution later.

Parameters
stylesheetas a lexical string representation
int XsltProcessor::exceptionCount ( )

Get number of errors reported during execution or evaluate of stylesheet.

A transformation may have a number of errors reported against it.

Returns
int - Count of the exceptions recorded against the transformation
bool XsltProcessor::exceptionOccurred ( )

Checks for pending exceptions without creating a local reference to the exception object

Returns
bool - true when there is a pending exception; otherwise return false
const char * XsltProcessor::getErrorCode ( int  i)

Get the ith error code if there are any error.

A transformation may have a number of errors reported against it.

Returns
char* - The error code of the i'th exception. The error code are related to the specific specification
const char * XsltProcessor::getErrorMessage ( int  i)

Get the ith error message if there are any error.

A transformation may have a number of errors reported against it.

Returns
char* - The message of the i'th exception
XdmValue * XsltProcessor::getParameter ( const char *  name)

Get a parameter value by name

Parameters
name- Specified paramater name to get
Returns
XdmValue
std::map< std::string, XdmValue * > & XsltProcessor::getParameters ( )

Get all parameters as a std::map.

Please note that the key name has been prefixed with 'param:', for example 'param:name'

Returns
std:map with key as string name mapped to XdmValue.
std::map< std::string, std::string > & XsltProcessor::getProperties ( )

Get all properties as a std::map.

Returns
std:map with key as string name mapped to string values.
const char * XsltProcessor::getProperty ( const char *  name)

Get a property value by name

Parameters
name- Specified paramater name to get
Returns
string - Get string of the property as char pointer array
SaxonProcessor* XsltProcessor::getSaxonProcessor ( )
inline

Get the SaxonProcessor object.

Returns
SaxonProcessor - Pointer to the object
XdmValue * XsltProcessor::getXslMessages ( )

Get the messages written using the xsl:message instruction

Returns
XdmValue - Messages returns as a XdmValue.
void XsltProcessor::releaseStylesheet ( )

Internal method to release cached stylesheet.

Parameters
void
bool XsltProcessor::removeParameter ( const char *  name)

Remove a parameter (name, value) pair from a stylesheet

Parameters
namethe name of the stylesheet parameter
Returns
bool - outcome of the romoval
void XsltProcessor::setcwd ( const char *  cwd)

set the current working directory

Parameters
cwd- Current working directory
void XsltProcessor::setOutputFile ( const char *  outfile)

Set the output file of where the transformation result is sent

void XsltProcessor::setParameter ( const char *  name,
XdmValue value 
)

Set the value of a stylesheet parameter

Parameters
namethe name of the stylesheet parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name"
valuethe value of the stylesheet parameter, or null to clear a previously set value
void XsltProcessor::setProperty ( const char *  name,
const char *  value 
)

Set a property specific to the processor in use. XsltProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml") 'o':outfile name, 'it': initial template, 'im': initial mode, 's': source as file name 'm': switch on message listener for xsl:message instructions (TODO: this feature should be event based), 'item'| 'node' : source supplied as an XdmNode object

Parameters
nameof the property
valueof the property
void XsltProcessor::setSourceFromFile ( const char *  filename)

Set the source from file for the transformation.

void XsltProcessor::setSourceFromXdmValue ( XdmItem value)

Set the source document from a XdmValue for the transformation.

Parameters
value- The source to the stylesheet as a pointer to the XdmItem object.
void XsltProcessor::transformFileToFile ( const char *  sourcefile,
const char *  stylesheetfile,
const char *  outputfile 
)

Perform a one shot transformation.

The result is stored in the supplied outputfile.

Parameters
sourcefile- The file name of the source document
stylesheetfile- The file name of the stylesheet document. If NULL the most recently compiled stylesheet is used
outputfile- The file name where results will be stored
const char * XsltProcessor::transformFileToString ( const char *  sourcefile,
const char *  stylesheetfile 
)

Perform a one shot transformation.

The result is returned as a string

Parameters
sourcefile- The file name of the source document
stylesheetfile- The file name of the stylesheet document. If NULL the most recently compiled stylesheet is used
Returns
char array - result of the transformation
XdmValue * XsltProcessor::transformFileToValue ( const char *  sourcefile,
const char *  stylesheetfile 
)

Perform a one shot transformation. The result is returned as an XdmValue

Parameters
sourcefile- The file name of the source document
stylesheetfile- The file name of the stylesheet document. If NULL the most recently compiled stylesheet is used
Returns
XdmValue - result of the transformation
void XsltProcessor::transformToFile ( )

Execute transformation to file. Properties supplied in advance.

Perform the transformation based upon cached stylesheet and source document. Assume the outputfile has been set in advance

Returns
as an XdmValue.
const char * XsltProcessor::transformToString ( )

Execute transformation to string. Properties supplied in advance.

Perform the transformation based upon what has been cached.

Returns
char*. Pointer to Array of chars. Result returned as a string.
XdmValue * XsltProcessor::transformToValue ( )

Execute transformation to Xdm Value. Properties supplied in advance.

Perform the transformation based upon cached stylesheet and any source document.

Returns
as an XdmValue.

The documentation for this class was generated from the following files: