SaxonC
11.6
Saxon Processor library for C/C++, PHP and Python
|
#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) | |
SaxonProcessor * | getSaxonProcessor () |
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... | |
XdmValue * | getParameter (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... | |
XdmValue * | transformFileToValue (const char *sourcefile, const char *stylesheetfile) |
XsltExecutable * | compileFromFile (const char *stylesheet) |
compile a stylesheet file. More... | |
XsltExecutable * | compileFromString (const char *stylesheet) |
compile a stylesheet received as a string. More... | |
XsltExecutable * | compileFromAssociatedFile (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... | |
XsltExecutable * | compileFromXdmNode (XdmNode *node) |
compile a stylesheet received as an XdmNode. More... | |
bool | exceptionOccurred () |
SaxonApiException * | getException () |
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 |
An Xslt30Processor
represents factory to compile, load and execute a stylesheet. It is possible to cache the context and the stylesheet in the Xslt30Processor
.
Xslt30Processor::Xslt30Processor | ( | ) |
Default constructor.
Creates a Saxon-HE product
Xslt30Processor::Xslt30Processor | ( | SaxonProcessor * | proc, |
std::string | cwd = "" |
||
) |
Constructor with the SaxonProcessor supplied.
proc | - Supplied pointer to the SaxonProcessor object |
cwd | - The current working directory |
Xslt30Processor::Xslt30Processor | ( | const Xslt30Processor & | other | ) |
Xslt30Processor copy constructor.
other | - Xslt30Processor |
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.
deleteValues | - if true then XdmValues are deleted |
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.
sourceFile | - The file name of the XML document. |
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.
stylesheet | - The file name of the stylesheet document. |
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
xslFilename | - file name of the stylesheet |
filename | - the file to which the compiled package should be saved |
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.
stylesheet | as a lexical string representation |
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
stylesheet | as a lexical string representation |
filename | - the file to which the compiled package should be saved |
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.
node | the XdmNode object for the stylesheet |
void Xslt30Processor::compileFromXdmNodeAndSave | ( | XdmNode * | node, |
const char * | filename | ||
) |
|
inline |
Utility method for working with SaxonC on Python
|
inline |
Utility method for working with SaxonC on Python
|
inline |
bool Xslt30Processor::exceptionOccurred | ( | ) |
Checks for pending exceptions without creating a local reference to the exception object
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.
const char * Xslt30Processor::getErrorMessage | ( | ) |
Get the error message if there are any error.
A transformation may have a number of errors reported against it.
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.
XdmValue * Xslt30Processor::getParameter | ( | const char * | name | ) |
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'
|
inline |
Get the SaxonProcessor object.
bool Xslt30Processor::removeParameter | ( | const char * | name | ) |
Remove a parameter (name, value) pair from a stylesheet
name | the name of the stylesheet parameter |
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
baseURI | - the base output URI |
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.
cwd | - Current working directory |
void Xslt30Processor::setJustInTimeCompilation | ( | bool | jit | ) |
Say whether just-in-time compilation of template rules should be used.
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. |
Recommendation: disable this option unless you are confident that the stylesheet you are compiling is error-free.
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.
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 |
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.
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 |
const char * Xslt30Processor::transformFileToString | ( | const char * | sourcefile, |
const char * | stylesheetfile | ||
) |
Perform a one shot transformation.
The result is returned as a string
sourcefile | - The file name of the source document |
stylesheetfile | - The file name of the stylesheet document. |
XdmValue * Xslt30Processor::transformFileToValue | ( | const char * | sourcefile, |
const char * | stylesheetfile | ||
) |