SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
Public Member Functions | Friends | List of all members
Xslt30Processor Class Reference

#include <Xslt30Processor.h>

Public Member Functions

 Xslt30Processor ()
 Default constructor. More...
 
 Xslt30Processor (SaxonProcessor *proc, std::string cwd="")
 Constructor with the SaxonProcessor supplied. More...
 
 Xslt30Processor (const Xslt30Processor &other)
 
SaxonProcessorgetSaxonProcessor ()
 Get the SaxonProcessor object. More...
 
void setcwd (const char *cwd)
 set the current working directory (cwd). More...
 
void setBaseOutputURI (const char *baseURI)
 Set the base output URI. More...
 
void setJustInTimeCompilation (bool jit)
 Say whether just-in-time compilation of template rules should be used. More...
 
void setParameter (const char *name, XdmValue *value)
 Set the value of a stylesheet parameter. More...
 
XdmValuegetParameter (const char *name)
 
bool removeParameter (const char *name)
 
std::map< std::string, XdmValue * > & getParameters ()
 Get all parameters as a std::map. More...
 
void clearParameters (bool deleteValues=false)
 Clear parameter values set. More...
 
XdmValue ** createXdmValueArray (int len)
 
char ** createCharArray (int len)
 
void deleteXdmValueArray (XdmValue **arr, int len)
 Utility method for Python API - internal use only. More...
 
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)
 
XsltExecutablecompileFromFile (const char *stylesheet)
 compile a stylesheet file. More...
 
XsltExecutablecompileFromString (const char *stylesheet)
 compile a stylesheet received as a string. More...
 
XsltExecutablecompileFromAssociatedFile (const char *sourceFile)
 Get the stylesheet associated. 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...
 
XsltExecutablecompileFromXdmNode (XdmNode *node)
 compile a stylesheet received as an XdmNode. More...
 
bool exceptionOccurred ()
 
SaxonApiExceptiongetException ()
 Get the SaxonApiException object created when we have an error. More...
 
void exceptionClear ()
 Clear any exception thrown.
 
const char * getErrorMessage ()
 Get the error message if there are any error. More...
 
const char * getErrorCode ()
 Get the ith error code if there are any error. More...
 

Friends

class XsltExecutable
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Xslt30Processor() [1/3]

Xslt30Processor::Xslt30Processor ( )

Default constructor.

Creates a Saxon-HE product

◆ Xslt30Processor() [2/3]

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

Constructor with the SaxonProcessor supplied.

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

◆ Xslt30Processor() [3/3]

Xslt30Processor::Xslt30Processor ( const Xslt30Processor other)

Xslt30Processor copy constructor.

Parameters
other- Xslt30Processor

Member Function Documentation

◆ clearParameters()

void Xslt30Processor::clearParameters ( bool  deleteValues = false)

Clear parameter values set.

Default behaviour (false) is to leave XdmValues in memory. Individual pointers to XdmValue objects have to be deleted in the calling program.

Parameters
deleteValues- if true then XdmValues are deleted

◆ compileFromAssociatedFile()

XsltExecutable * Xslt30Processor::compileFromAssociatedFile ( const char *  sourceFile)

Get the stylesheet associated.

Note: the term "compile" here indicates that the stylesheet is converted into an executable form. The compilation uses a snapshot of the properties of the Xslt30Processor at the time this method is invoked.

Parameters
sourceFile- The file name of the XML document.
Returns
an XsltExecutable, which represents the compiled stylesheet. The XsltExecutable is immutable and thread-safe; it may be used to run multiple transformations, in series or concurrently.

◆ compileFromFile()

XsltExecutable * Xslt30Processor::compileFromFile ( const char *  stylesheet)

compile a stylesheet file.

Note: the term "compile" here indicates that the stylesheet is converted into an executable form. The compilation uses a snapshot of the properties of the Xslt30Processor at the time this method is invoked.

Parameters
stylesheet- The file name of the stylesheet document.
Returns
an XsltExecutable, which represents the compiled stylesheet. The XsltExecutable is immutable and thread-safe; it may be used to run multiple transformations, in series or concurrently.

◆ compileFromFileAndSave()

void Xslt30Processor::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()

XsltExecutable * Xslt30Processor::compileFromString ( const char *  stylesheet)

compile a stylesheet received as a string.

Note: the term "compile" here indicates that the stylesheet is converted into an executable form. The compilation uses a snapshot of the properties of the Xslt30Processor at the time this method is invoked.

Parameters
stylesheetas a lexical string representation
Returns
an XsltExecutable, which represents the compiled stylesheet. The XsltExecutable is immutable and thread-safe; it may be used to run multiple transformations, in series or concurrently.

◆ compileFromStringAndSave()

void Xslt30Processor::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()

XsltExecutable * Xslt30Processor::compileFromXdmNode ( XdmNode node)

compile a stylesheet received as an XdmNode.

Note: the term "compile" here indicates that the stylesheet is converted into an executable form. The compilation uses a snapshot of the properties of the Xslt30Processor at the time this method is invoked.

Parameters
nodethe XdmNode object for the stylesheet
Returns
an XsltExecutable, which represents the compiled stylesheet. The XsltExecutable is immutable and thread-safe; it may be used to run multiple transformations, in series or concurrently.

◆ compileFromXdmNodeAndSave()

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

compile a stylesheet received as an XdmNode.

The compiled stylesheet is cached and available for execution later.

Parameters
nodethe XdmNode object for the stylesheet
filename- the file to which the compiled package should be saved

◆ createCharArray()

char** Xslt30Processor::createCharArray ( int  len)
inline

Utility method for working with SaxonC on Python

◆ createXdmValueArray()

XdmValue** Xslt30Processor::createXdmValueArray ( int  len)
inline

Utility method for working with SaxonC on Python

◆ deleteXdmValueArray()

void Xslt30Processor::deleteXdmValueArray ( XdmValue **  arr,
int  len 
)
inline

Utility method for Python API - internal use only.

This method deletes a XdmValue pointer array

Parameters
arr- XdmValue pointer array
len- length of the array

◆ exceptionOccurred()

bool Xslt30Processor::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 * Xslt30Processor::getErrorCode ( )

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 exception. The error code are related to the specific specification

◆ getErrorMessage()

const char * Xslt30Processor::getErrorMessage ( )

Get the error message if there are any error.

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

Returns
char* - The message of the exception

◆ getException()

SaxonApiException * Xslt30Processor::getException ( )

Get the SaxonApiException object created when we have an error.

After the execution of the processor if there is an error, then a SaxonApiException is created. NULL returned if there is no error.

Returns
SaxomApiException object of the exception thrown.

◆ getParameter()

XdmValue * Xslt30Processor::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 * > & Xslt30Processor::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.

◆ getSaxonProcessor()

SaxonProcessor* Xslt30Processor::getSaxonProcessor ( )
inline

Get the SaxonProcessor object.

Returns
SaxonProcessor - Pointer to the object

◆ removeParameter()

bool Xslt30Processor::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

◆ setBaseOutputURI()

void Xslt30Processor::setBaseOutputURI ( const char *  baseURI)

Set the base output URI.

The base output URI is used for resolving relative URIs in the href attribute of the xsl:result-document instruction; it is accessible to XSLT stylesheet code using the XPath current-output-uri() function

Parameters
baseURI- the base output URI

◆ setcwd()

void Xslt30Processor::setcwd ( const char *  cwd)

set the current working directory (cwd).

This method also applies to the static base URI for XSLT stylesheets when supplied as lexical string. The cwd is used to set the base URI is part of the static context, and is used to resolve any relative URIs appearing within XSLT.

Parameters
cwd- Current working directory

◆ setJustInTimeCompilation()

void Xslt30Processor::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.

◆ setParameter()

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

Set the value of a stylesheet parameter.

Static (compile-time) parameters must be provided using this method on the XsltCompiler object, prior to stylesheet compilation. Non-static parameters may also be provided using this method if their values will not vary from one transformation to another.

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 nullptr to clear a previously set value

◆ transformFileToFile()

void Xslt30Processor::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.
outputfile- The file name where results will be stored

◆ transformFileToString()

const char * Xslt30Processor::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.
Returns
char array - result of the transformation

◆ transformFileToValue()

XdmValue * Xslt30Processor::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.
Returns
XdmValue - result of the transformation

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