Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
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...
 
SaxonProcessorgetSaxonProcessor ()
 Get the SaxonProcessor object. More...
 
void setcwd (const char *cwd)
 set the current working directory More...
 
void setSourceFromXdmNode (XdmNode *value)
 Set the source document from an XdmNode for the transformation. More...
 
void setSourceFromFile (const char *filename)
 
void setOutputFile (const char *outfile)
 
void setJustInTimeCompilation (bool jit)
 
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 an exported file (SEF). More...
 
void compileFromFileAndSave (const char *xslFilename, const char *filename)
 compile a stylesheet received as a file and save to an exported file (SEF). More...
 
void compileFromXdmNodeAndSave (XdmNode *node, const char *filename)
 compile a stylesheet received as an XdmNode. 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...
 

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() [1/2]

XsltProcessor::XsltProcessor ( )

Default constructor.

Creates a Saxon-HE product

◆ XsltProcessor() [2/2]

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

◆ checkException()

const char * XsltProcessor::checkException ( )

Check for exception thrown.

Returns
cha*. Returns the exception message if thrown otherwise return NULL

◆ clearParameters()

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

◆ compileFromFile()

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.

◆ compileFromFileAndSave()

void XsltProcessor::compileFromFileAndSave ( const char *  xslFilename,
const char *  filename 
)

compile a stylesheet received as a file and save to an exported file (SEF).

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

◆ compileFromString()

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

◆ compileFromStringAndSave()

void XsltProcessor::compileFromStringAndSave ( const char *  stylesheet,
const char *  filename 
)

compile a stylesheet received as a string and save to an exported file (SEF).

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

◆ compileFromXdmNode()

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

◆ compileFromXdmNodeAndSave()

void XsltProcessor::compileFromXdmNodeAndSave ( XdmNode node,
const char *  filename 
)

compile a stylesheet received as an XdmNode.

The compiled stylesheet is cached and available for execution later.

Parameters
stylesheetas a lexical string representation
filename- the file to which the compiled package should be saved

◆ exceptionCount()

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

◆ exceptionOccurred()

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

◆ getErrorCode()

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

◆ getErrorMessage()

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

◆ getParameter()

XdmValue * XsltProcessor::getParameter ( const char *  name)

Get a parameter value by name

Parameters
name- Specified paramater name to get
Returns
XdmValue

◆ getParameters()

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.

◆ getProperties()

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.

◆ getProperty()

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

◆ getSaxonProcessor()

SaxonProcessor* XsltProcessor::getSaxonProcessor ( )
inline

Get the SaxonProcessor object.

Returns
SaxonProcessor - Pointer to the object

◆ getXslMessages()

XdmValue * XsltProcessor::getXslMessages ( )

Get the messages written using the xsl:message instruction

Returns
XdmValue - Messages returned as an XdmValue.

◆ releaseStylesheet()

void XsltProcessor::releaseStylesheet ( )

Internal method to release cached stylesheet.

Parameters
void

◆ removeParameter()

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

◆ setcwd()

void XsltProcessor::setcwd ( const char *  cwd)

set the current working directory

Parameters
cwd- Current working directory

◆ setJustInTimeCompilation()

void XsltProcessor::setJustInTimeCompilation ( bool  jit)

Say whether just-in-time compilation of template rules should be used.

Parameters
jittrue if just-in-time compilation is to be enabled. With this option enabled, static analysis of a template rule is deferred until the first time that the template is matched. This can improve performance when many template rules are rarely used during the course of a particular transformation; however, it means that static errors in the stylesheet will not necessarily cause the compile(Source) method to throw an exception (errors in code that is actually executed will still be notified to the registered ErrorListener or ErrorList, but this may happen after the compile(Source) method returns). This option is enabled by default in Saxon-EE, and is not available in Saxon-HE or Saxon-PE.

Recommendation: disable this option unless you are confident that the stylesheet you are compiling is error-free.

◆ setOutputFile()

void XsltProcessor::setOutputFile ( const char *  outfile)

Set the output file of where the transformation result is sent

◆ setParameter()

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

◆ setProperty()

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

◆ setSourceFromFile()

void XsltProcessor::setSourceFromFile ( const char *  filename)

Set the source from file for the transformation.

◆ setSourceFromXdmNode()

void XsltProcessor::setSourceFromXdmNode ( XdmNode value)

Set the source document from an XdmNode for the transformation.

Parameters
value- The source to the stylesheet as a pointer to the XdmNode object.

◆ transformFileToFile()

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

◆ transformFileToString()

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

◆ transformFileToValue()

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

◆ transformToFile()

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.

◆ transformToString()

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.

◆ transformToValue()

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: