SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
|
#include <Xslt30Processor.h>
Public Member Functions | |
Xslt30Processor () | |
Default constructor. | |
Xslt30Processor (SaxonProcessor *proc, std::string cwd="") | |
Constructor with the SaxonProcessor supplied. | |
Xslt30Processor (const Xslt30Processor &other) | |
SaxonProcessor * | getSaxonProcessor () |
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. | |
XdmValue * | getParameter (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. | |
XdmValue * | transformFileToValue (const char *sourcefile, const char *stylesheetfile) |
void | importPackage (const char *packageFile) |
Import a library package. | |
XsltExecutable * | compileFromFile (const char *stylesheet) |
compile a stylesheet file. | |
XsltExecutable * | compileFromString (const char *stylesheet, const char *encoding=nullptr) |
compile a stylesheet received as a string. | |
XsltExecutable * | compileFromAssociatedFile (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. | |
XsltExecutable * | compileFromXdmNode (XdmNode *node) |
compile a stylesheet received as an XdmNode. | |
bool | exceptionOccurred () |
SaxonApiException * | getException () |
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 |
An Xslt30Processor
represents a factory to compile, load and execute stylesheets. It is possible to cache the context and the stylesheet in the Xslt30Processor
.
Xslt30Processor::Xslt30Processor | ( | ) |
Xslt30Processor::Xslt30Processor | ( | SaxonProcessor * | proc, |
std::string | cwd = "" ) |
Constructor with the SaxonProcessor supplied.
proc | - Supplied pointer to the SaxonProcessor object |
cwd | - The current working directory |
SaxonApiException |
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. |
SaxonApiException | if the compilation of the stylesheet fails |
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. |
SaxonApiException | if the compilation of the stylesheet fails |
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 |
SaxonApiException | if the compilation of the stylesheet fails |
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.
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. |
SaxonApiException | if the compilation of the stylesheet fails |
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
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 |
SaxonApiException | if the compilation of the stylesheet fails |
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 |
SaxonApiException | if the compilation of the stylesheet fails |
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.
node | - the XdmNode object for the stylesheet |
filename | - the file to which the compiled package should be saved |
SaxonApiException | if the compilation of the stylesheet fails |
|
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 first error code if there are any errors.
A transformation may have a number of errors reported against it.
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.
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.
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
.
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() . |
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::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.
fast | - set to true to request fast compilation; set to false to revert to the optimization options defined in the Configuration. |
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.
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. |
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::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
relocatable | - if true then static-base-uri() represents the deployed location of the package, rather than its compile time location |
void Xslt30Processor::setTargetEdition | ( | const char * | edition | ) |
Set the target edition.
Set the target edition under which the stylesheet will be executed.
edition | - the Saxon edition for the run-time environment. One of "EE", "PE", "HE", or "JS", "JS2", or "JS3". |
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).
version | - the language level to be supported. The values "3.0" and "4.0" are recognized |
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 |
SaxonApiException | if the transformation fails |
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. |
SaxonApiException | if the transformation fails |
XdmValue * Xslt30Processor::transformFileToValue | ( | const char * | sourcefile, |
const char * | stylesheetfile ) |
Perform a one shot transformation. The result is returned as an XdmValue
sourcefile | - The file name of the source document |
stylesheetfile | - The file name of the stylesheet document. |
SaxonApiException | if the transformation fails |