SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
Xslt30Processor Class Reference

#include <Xslt30Processor.h>

Public Member Functions

 Xslt30Processor ()
 Default constructor.
 
 Xslt30Processor (SaxonProcessor *proc, std::string cwd="")
 Constructor with the SaxonProcessor supplied.
 
 Xslt30Processor (const Xslt30Processor &other)
 
SaxonProcessorgetSaxonProcessor ()
 Get the SaxonProcessor object.
 
void setcwd (const char *cwd)
 set the current working directory (cwd).
 
void setBaseOutputURI (const char *baseURI)
 Set the base output URI.
 
void setJustInTimeCompilation (bool jit)
 Say whether just-in-time compilation of template rules should be used.
 
void setTargetEdition (const char *edition)
 Set the target edition.
 
void setXsltLanguageVersion (const char *version)
 Set the XSLT (and XPath) language level to be supported by the processor.
 
void setFastCompilation (bool fast)
 Request fast compilation.
 
void setRelocatable (bool relocatable)
 Indicate package deployable to a different location.
 
void setParameter (const char *name, XdmValue *value)
 Set the value of a stylesheet parameter.
 
XdmValuegetParameter (const char *name)
 
bool removeParameter (const char *name)
 
std::map< std::string, XdmValue * > & getParameters ()
 Get all parameters as a std::map.
 
void clearParameters (bool deleteValues=false)
 Clear parameter values set.
 
XdmValue ** createXdmValueArray (int len)
 
char ** createCharArray (int len)
 
void deleteXdmValueArray (XdmValue **arr, int len)
 Utility method for Python API - internal use only.
 
void transformFileToFile (const char *sourcefile, const char *stylesheetfile, const char *outputfile)
 Perform a one shot transformation.
 
const char * transformFileToString (const char *sourcefile, const char *stylesheetfile)
 Perform a one shot transformation.
 
XdmValuetransformFileToValue (const char *sourcefile, const char *stylesheetfile)
 
void importPackage (const char *packageFile)
 Import a library package.
 
XsltExecutablecompileFromFile (const char *stylesheet)
 compile a stylesheet file.
 
XsltExecutablecompileFromString (const char *stylesheet, const char *encoding=nullptr)
 compile a stylesheet received as a string.
 
XsltExecutablecompileFromAssociatedFile (const char *sourceFile)
 Get the stylesheet associated.
 
void compileFromStringAndSave (const char *stylesheet, const char *filename, const char *encoding=nullptr)
 
void compileFromFileAndSave (const char *xslFilename, const char *filename)
 
void compileFromXdmNodeAndSave (XdmNode *node, const char *filename)
 compile a stylesheet received as an XdmNode.
 
XsltExecutablecompileFromXdmNode (XdmNode *node)
 compile a stylesheet received as an XdmNode.
 
bool exceptionOccurred ()
 
SaxonApiExceptiongetException ()
 Get the SaxonApiException object created when we have an error.
 
void exceptionClear ()
 Clear any exception thrown.
 
const char * getErrorMessage ()
 Get the first error message if there are any errors.
 
const char * getErrorCode ()
 Get the first error code if there are any errors.
 

Friends

class XsltExecutable
 

Detailed Description

An Xslt30Processor represents a factory to compile, load and execute stylesheets. 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

Exceptions
SaxonApiException

◆ 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
Exceptions
SaxonApiException

◆ 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.
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ 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.
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ 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
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ compileFromString()

XsltExecutable * Xslt30Processor::compileFromString ( const char * stylesheet,
const char * encoding = nullptr )

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
stylesheet- the stylesheet as a lexical string representation
encoding- the encoding of the stylesheet string. If not specified then the platform default encoding is used.
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.
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ compileFromStringAndSave()

void Xslt30Processor::compileFromStringAndSave ( const char * stylesheet,
const char * filename,
const char * encoding = nullptr )

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
stylesheet- the stylesheet as a lexical string representation
filename- the file to which the compiled package should be saved
encoding- the string encoding of the filename. Defaults to JVM default
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ 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
node- the 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.
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ 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
node- the XdmNode object for the stylesheet
filename- the file to which the compiled package should be saved
Exceptions
SaxonApiExceptionif the compilation of the stylesheet fails

◆ 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 first error code if there are any errors.

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

Returns
char* - The error code of the exception. The error codes are related to the specific specification

◆ getErrorMessage()

const char * Xslt30Processor::getErrorMessage ( )

Get the first error message if there are any errors.

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
SaxonApiException object of the exception thrown.

◆ getParameter()

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

Get a parameter value by name

Parameters
name- Specified parameter 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

◆ importPackage()

void Xslt30Processor::importPackage ( const char * packageFile)

Import a library package.

Calling this method makes the supplied package available for reference in the xsl:use-package declarations of subsequent compilations performed using this Xslt30Processor.

Parameters
packageFile- the file name of the package to be imported, which should be supplied as an SEF. If relative, the file name of the SEF is resolved against the cwd, which is set using setcwd().

◆ removeParameter()

bool Xslt30Processor::removeParameter ( const char * name)

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

Parameters
name- the name of the stylesheet parameter
Returns
bool - outcome of the removal

◆ 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

◆ setFastCompilation()

void Xslt30Processor::setFastCompilation ( bool fast)

Request fast compilation.

Fast compilation will generally be achieved at the expense of run-time performance and quality of diagnostics. Fast compilation is a good trade-off if (a) the stylesheet is known to be correct, and (b) once compiled, it is only executed once against a document of modest size.

Fast compilation may result in static errors going unreported, especially if they occur in code that is never executed.

The current implementation is equivalent to switching off all optimizations other than just-in-time compilation of template rules. Setting this option, however, indicates an intent rather than a mechanism, and the implementation details may change in future to reflect the intent.

Parameters
fast- set to true to request fast compilation; set to false to revert to the optimization options defined in the Configuration.

◆ setJustInTimeCompilation()

void Xslt30Processor::setJustInTimeCompilation ( bool jit)

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

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

Parameters
jit- true 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.

◆ 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
name- the name of the stylesheet parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name"
value- the value of the stylesheet parameter, or nullptr to clear a previously set value

◆ setRelocatable()

void Xslt30Processor::setRelocatable ( bool relocatable)

Indicate package deployable to a different location.

Say whether any package produced by this compiler can be deployed to a different location, with a different base URI

Parameters
relocatable- if true then static-base-uri() represents the deployed location of the package, rather than its compile time location

◆ setTargetEdition()

void Xslt30Processor::setTargetEdition ( const char * edition)

Set the target edition.

Set the target edition under which the stylesheet will be executed.

Parameters
edition- the Saxon edition for the run-time environment. One of "EE", "PE", "HE", or "JS", "JS2", or "JS3".

◆ setXsltLanguageVersion()

void Xslt30Processor::setXsltLanguageVersion ( const char * version)

Set the XSLT (and XPath) language level to be supported by the processor.

Set the value to "4.0" to enable support for experimental features defined in the XSLT 4.0 proposal (which is likely to change before it stabilizes).

Parameters
version- the language level to be supported. The values "3.0" and "4.0" are recognized

◆ 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
Exceptions
SaxonApiExceptionif the transformation fails

◆ 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
Exceptions
SaxonApiExceptionif the transformation fails

◆ 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
Exceptions
SaxonApiExceptionif the transformation fails

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