Packages: All | Callback | DOM | Range | SAX | Schema | Traversal | XML | XPath | XPointer | XSLT | XSLTVM Functions | Datatypes

Package XSLTVM

XSLTVM Package implements the XSL Transformation (XSLT) language as specified in W3C Recommendation 16 November 1999. XSLT Virtual Machine is the software implementation of a "CPU" designed to run compiled XSLT code. A concept of virtual machine assumes a compiler compiling XSLT stylesheets to a sequence of byte codes or machine instructions for the "XSLT CPU". The byte-code program is a platform-independent sequence of 2-byte units. It can be stored, cashed and run on different XSLTVM. The XSLTVM uses the bytecode programs to transform instance XML documents. This approach clearly separates compile(design)-time from run-time computations and specifies a uniform way of exchanging data between instructions. A typical scenario of using the package APIs has the following steps:

(1) Create/Use an XML meta context object. xctx = XmlCreate(&err,...);

(2) Create/Use an XSLT Compiler object. comp = XmlXvmCreateComp(xctx);

(3) Compile an XSLT stylesheets and store/cash the result bytecode. code = XmlXvmCompileFile(comp, xslFile, baseuri, flags, &err);

(4) Create/Use an XSLTVM object. The explicit stack size seting are needed when XSLTVM terminates with "... Stack Overflow" message or when smaller memory footprints are required (see XmlXvmCreate). vm = XmlXvmCreate(xctx, "StringStack", 32, "NodeStack", 24, NULL);

(5) Set a stylesheet bytecode to the XSLTVM object. len = XmlXvmGetBytecodeLength(code, &err); err = XmlXvmSetBytecodeBuffer(vm, code, len);

(6) Transform an instance XML document. err = XmlXvmTransformFile(vm, xmlFile, baseuri);

(7) Clean. XmlXvmDestroy(vm); XmlXvmDestroyComp(comp); XmlDestroy(xctx);


Function Index

FunctionInterfaceDescription
XMLXVM_DEBUG_F XSLTVM XML XSLT VM debug function
XmlXvmCompileBuffer XSLTC Compile an XSLT stylesheet from buffer into bytecode
XmlXvmCompileDom XSLTC Compile an XSLT stylesheet from DOM into bytecode
XmlXvmCompileFile XSLTC Compile XSLT stylesheet from file into bytecode
XmlXvmCompileURI XSLTC Compile XSLT stylesheet from URI into bytecode
XmlXvmCompileXPath XSLTC Compiles an XPath expression
XmlXvmCreate XSLTVM Create an XSLT virtual machine
XmlXvmCreateComp XSLTC Create an XSLT compiler
XmlXvmDestroy XSLTVM Destroys an XSLT virtual machine
XmlXvmDestroyComp XSLTC Destroys an XSLT compiler object
XmlXvmEvaluateXPath XSLTVM Evaluate already-compiled XPath expression
XmlXvmGetBytecodeLength XSLTC Returns the bytecode length
XmlXvmGetObjectBoolean XSLTVM Get boolean value of XPath object
XmlXvmGetObjectNSetNode XSLTVM Get node from nodeset-type XPath object
XmlXvmGetObjectNSetNum XSLTVM Get number of of nodes in nodeset-type XPath object
XmlXvmGetObjectNumber XSLTVM Get number from XPath object
XmlXvmGetObjectString XSLTVM Get string from XPath object
XmlXvmGetObjectType XSLTVM Get XPath object type
XmlXvmGetOutputDom XSLTVM Returns the output DOM
XmlXvmResetParams XSLTVM Resets the stylesheet top-level text params.
XmlXvmSetBaseURI XSLTVM Sets the base URI for the XSLTVM
XmlXvmSetBytecodeBuffer XSLTVM Set the compiled byte-code
XmlXvmSetBytecodeFile XSLTVM Set the compiled bytecode from file
XmlXvmSetBytecodeURI XSLTVM Set the compiled byte-code
XmlXvmSetDebugFunc XSLTVM Set a callback function for debuging
XmlXvmSetOutputDom XSLTVM Sets the XSLTVM to output document node.
XmlXvmSetOutputEncoding XSLTVM Sets the encoding for the XSLTVM output
XmlXvmSetOutputSax XSLTVM Set XSLTVM to output SAX
XmlXvmSetOutputStream XSLTVM Set the XSLTVM output to a user-defined stream
XmlXvmSetTextParam XSLTVM Set the stylesheet top-level text param.
XmlXvmTransformBuffer XSLTVM Run compiled XSLT stylesheet on XML document in memory
XmlXvmTransformDom XSLTVM Run compiled XSLT stylesheet on XML document as DOM
XmlXvmTransformFile XSLTVM Run compiled XSLT stylesheet on XML document in file
XmlXvmTransformURI XSLTVM Run compiled XSLT stylesheet on XML document from URI


Interface XSLTC

Function Index

FunctionDescription
XmlXvmCompileBuffer Compile an XSLT stylesheet from buffer into bytecode
XmlXvmCompileDom Compile an XSLT stylesheet from DOM into bytecode
XmlXvmCompileFile Compile XSLT stylesheet from file into bytecode
XmlXvmCompileURI Compile XSLT stylesheet from URI into bytecode
XmlXvmCompileXPath Compiles an XPath expression
XmlXvmCreateComp Create an XSLT compiler
XmlXvmDestroyComp Destroys an XSLT compiler object
XmlXvmGetBytecodeLength Returns the bytecode length


Interface XSLTVM

Function Index

FunctionDescription
XMLXVM_DEBUG_F XML XSLT VM debug function
XmlXvmCreate Create an XSLT virtual machine
XmlXvmDestroy Destroys an XSLT virtual machine
XmlXvmEvaluateXPath Evaluate already-compiled XPath expression
XmlXvmGetObjectBoolean Get boolean value of XPath object
XmlXvmGetObjectNSetNode Get node from nodeset-type XPath object
XmlXvmGetObjectNSetNum Get number of of nodes in nodeset-type XPath object
XmlXvmGetObjectNumber Get number from XPath object
XmlXvmGetObjectString Get string from XPath object
XmlXvmGetObjectType Get XPath object type
XmlXvmGetOutputDom Returns the output DOM
XmlXvmResetParams Resets the stylesheet top-level text params.
XmlXvmSetBaseURI Sets the base URI for the XSLTVM
XmlXvmSetBytecodeBuffer Set the compiled byte-code
XmlXvmSetBytecodeFile Set the compiled bytecode from file
XmlXvmSetBytecodeURI Set the compiled byte-code
XmlXvmSetDebugFunc Set a callback function for debuging
XmlXvmSetOutputDom Sets the XSLTVM to output document node.
XmlXvmSetOutputEncoding Sets the encoding for the XSLTVM output
XmlXvmSetOutputSax Set XSLTVM to output SAX
XmlXvmSetOutputStream Set the XSLTVM output to a user-defined stream
XmlXvmSetTextParam Set the stylesheet top-level text param.
XmlXvmTransformBuffer Run compiled XSLT stylesheet on XML document in memory
XmlXvmTransformDom Run compiled XSLT stylesheet on XML document as DOM
XmlXvmTransformFile Run compiled XSLT stylesheet on XML document in file
XmlXvmTransformURI Run compiled XSLT stylesheet on XML document from URI

XMLXVM_DEBUG_F

Name XMLXVM_DEBUG_F
Interface XSLTVM
Purpose XML XSLT VM debug function
Prototype #define XMLXVM_DEBUG_F(func, line, file, obj, n) \
void func(ub2 line, oratext *file, xvmobj *obj, ub4 n)
Arguments
line  (IN)  source stylesheet line#
file  (IN)  stylesheet filename
obj  (IN)  current VM object
n  (IN)  index of current node
Returns (void)
Description Debug callback function for XSLT VM

See Also XmlXvmSetDebugFunc

XmlXvmCompileBuffer

Name XmlXvmCompileBuffer
Interface XSLTC
Purpose Compile an XSLT stylesheet from buffer into bytecode
Prototype ub2 *XmlXvmCompileBuffer(xmlxvmcomp *comp, oratext *buffer, ub4 length, 
                     oratext *baseURI, xmlxvmflag flags, xmlerr *error);
Arguments
comp  (IN)  compiler object
buffer  (IN)  pointer to buffer containing stylesheet document
length  (IN)  the length of the stylesheet document in bytes
baseuri  (IN)  base URI of the document
flags  (IN)  flags for the current compilation
error  (OUT)  returned error code
Returns (ub2 *) bytecode or NULL on error
Description Compile an XSLT stylesheet from buffer into bytecode

Compiler flags could be one or more of the following:

XMLXVM_DEBUG - forces compiler to include debug information into the bytecode

XMLXVM_STRIPSPACE - same as <xsl:strip-space elements="*"/>.

The generated bytecode resides in a compiler buffer which is freed when next stylesheet is compiled or when compiler object is deleted. Hence, if the bytecode is to be reused it should be copied into another location.

See Also XmlXvmCompileFile, XmlXvmCompileURI, XmlXvmCompileDom

XmlXvmCompileDom

Name XmlXvmCompileDom
Interface XSLTC
Purpose Compile an XSLT stylesheet from DOM into bytecode
Prototype ub2 *XmlXvmCompileDom(xmlxvmcomp *comp, xmldocnode *root, xmlxvmflag flags, 
                  xmlerr *error);
Arguments
comp  (IN)  compiler object
root  (IN)  root element of the stylesheet DOM
flags  (IN)  flags for the current compilation
error  (OUT)  returned error code
Returns (ub2 *) bytecode or NULL on error
Description Compile an XSLT stylesheet from DOM into bytecode

Compiler flags could be one or more of the following:

XMLXVM_DEBUG - forces compiler to include debug information into the bytecode

XMLXVM_STRIPSPACE - same as <xsl:strip-space elements="*"/>.

The generated bytecode resides in a compiler buffer which is freed when next stylesheet is compiled or when compiler object is deleted. Hence, if the bytecode is to be reused it should be copied into another location.

Example comp   = XmlXvmCreateComp(xctx);
code   = XmlXvmCompileDom(comp, root, XMLXVM_DEBUG, &err);
See Also XmlXvmCompileFile, XmlXvmCompileBuffer, XmlXvmCompileURI

XmlXvmCompileFile

Name XmlXvmCompileFile
Interface XSLTC
Purpose Compile XSLT stylesheet from file into bytecode
Prototype ub2 *XmlXvmCompileFile(xmlxvmcomp *comp, oratext *path,
                   oratext *baseURI, xmlxvmflag flags, xmlerr *error);
Arguments
comp  (IN)  compiler object
path  (IN)  path of XSL stylesheet file
baseuri  (IN)  base URI of the document
flags  (IN)  flags for the current compilation
error  (OUT)  returned error code
Returns (ub2 *) bytecode or NULL on error
Description Compile XSLT stylesheet from file into bytecode.

Compiler flags could be one or more of the following:

XMLXVM_DEBUG - forces compiler to include debug information into the bytecode

XMLXVM_STRIPSPACE - same as <xsl:strip-space elements="*"/>.

The generated bytecode resides in a compiler buffer which is freed when next stylesheet is compiled or when compiler object is deleted. Hence, if the bytecode is to be reused it should be copied into another location.

Example comp = XmlXvmCreateComp(xctx);
code = XmlXvmCompileFile(comp, xslFile1, baseuri, 0, &err);
...  (copy the code)
code = XmlXvmCompileFile(comp, xslFile2, baseuri, 0, &err);
...  (copy the code)
See Also XmlXvmCompileURI, XmlXvmCompileBuffer, XmlXvmCompileDom

XmlXvmCompileURI

Name XmlXvmCompileURI
Interface XSLTC
Purpose Compile XSLT stylesheet from URI into bytecode
Prototype ub2 *XmlXvmCompileURI(xmlxvmcomp *comp, oratext *uri, xmlxvmflag flags, 
                  xmlerr *error);
Arguments
comp  (IN)  compiler object
uri  (IN)  URI of the file contining the XSL stylesheet
flags  (IN)  flags for the current compilation
error  (OUT)  returned error code
Returns (ub2 *) bytecode or NULL on error
Description Compile XSLT stylesheet from URI into bytecode

Compiler flags could be one or more of the following:

XMLXVM_DEBUG - forces compiler to include debug information into the bytecode

XMLXVM_STRIPSPACE - same as <xsl:strip-space elements="*"/>.

The generated bytecode resides in a compiler buffer which is freed when next stylesheet is compiled or when compiler object is deleted. Hence, if the bytecode is to be reused it should be copied into another location.

Example comp = XmlXvmCreateComp(xctx);
code = XmlXvmCompileURI(comp, xslFile1, uri, XMLXVM_DEBUG, &err);
...  (copy the code)
code = XmlXvmCompileURI(comp, xslFile2, uri, XMLXVM_STRIPSPACE, &err);
...  (copy the code)
See Also XmlXvmCompileFile, XmlXvmCompileBuffer, XmlXvmCompileDom

XmlXvmCompileXPath

Name XmlXvmCompileXPath
Interface XSLTC
Purpose Compiles an XPath expression
Prototype ub2 *XmlXvmCompileXPath(xmlxvmcomp *comp, oratext *xpath,
                    oratext **pfxmap, xmlerr *error);
Arguments
comp  (IN)  Compiler object
xpath  (IN)  XPath expression
pfxmap  (IN)  array of prefix-URI mappings
error  (OUT)  returned error code
Returns (ub2 *) XPath expression bytecode or NULL on error
Description Compiles an XPath expression. The optional pfxmap is used to map namespace prefixes to URIs in the XPath expression. It is an array of prefix, URI values, endinging in NULL, for example:

oratext *my_pfx_map[] = "pfx1", "/this/that/pfx1/uri", "pfx2", "/this/that/another/pfx2/uri", NULL ;

Example comp = XmlXvmCreateComp(xctx);
code = XmlXvmCompileXPath(comp, "pfx1:doc/employee[4]",
  my_pfx_map, &err);

XmlXvmCreate

Name XmlXvmCreate
Interface XSLTVM
Purpose Create an XSLT virtual machine
Prototype xmlxvm *XmlXvmCreate(xmlctx *xctx, ...);
Arguments
xctx  (IN)  XML context
...  (IN)  list of zero or more properties to be set, NULL-terminated
Returns (xmlxvm *) XSLT virtual machine object, or NULL on error
Description Create an XSLT virtual machine. Zero or more of the following XSLTVM properties could be set by using this API:

"VMStack", size, - sets the size[Kbyte] of the main VM stack. Default size is 4K.

"NodeStack", size, - sets the size[Kbyte] of the node-stack Default size is 16K.

"StringStack", size - sets the size[Kbyte] of the string-stack Default size is 64K.

If the stack size is not specified the default size is used. The explicit stack size seting is needed when XSLTVM terminates with "Stack Overflow" message or when smaller memory footprints are required.

Example vm = XmlXvmCreate(xctx);
XmlXvmDestroy(vm);
...
vm = XmlXvmCreate(xctx, "VMStack", 10, "NodeStack", 24, 
                        "StringStack", 24, NULL);
See Also XmlXvmDestroy

XmlXvmCreateComp

Name XmlXvmCreateComp
Interface XSLTC
Purpose Create an XSLT compiler
Prototype xmlxvmcomp *XmlXvmCreateComp(xmlctx *xctx);
Arguments
xctx  (IN)  XML context
Returns (xmlxvmcomp *) XSLT compiler object, or NULL on error
Description Create an XSLT compiler object. The XSLT compiler is used to compile XSLT stylesheets into bytecode.

Example comp = XmlXvmCreateComp(xctx);
code = XmlXvmCompileFile(comp, xslFile1, baseuri, 0, &err);
code = XmlXvmCompileFile(comp, xslFile2, baseuri, 0, &err);
...
-- the following is an example of bytecode instructions sequence:
...
14.           <xsl:apply-templates select="@* | node()"/>
    39    PUSHCUR          
    40    ATTRIBUTE        node()       node()       
    43    PUSHCUR                                        
    44    CHILD            node()       node()       
    47    UNION            
    48    PUSHCTX          [loop][context]
    49    FOREACH          code: @-8    
    51    PUSHCUR          
    52    MATCH             0            
    54    CALLTEMPLATE      
    55    BRA              code: @6     
    57    TESTCURNDTYPE    1            
    59    BNO              code: @-3   
...
See Also XmlXvmDestroyComp

XmlXvmDestroy

Name XmlXvmDestroy
Interface XSLTVM
Purpose Destroys an XSLT virtual machine
Prototype void XmlXvmDestroy(xmlxvm *vm);
Arguments
vm  (IN)  VM object
comp  (IN)  XSLT virtual machine object
Returns (void)
Description Destroys an XSLT virtual machine

See Also XmlXvmCreate

XmlXvmDestroyComp

Name XmlXvmDestroyComp
Interface XSLTC
Purpose Destroys an XSLT compiler object
Prototype void XmlXvmDestroyComp(xmlxvmcomp *comp);
Arguments
comp  (IN)  XSLT compiler object
Returns (void)
Description Destroys an XSLT compiler object

See Also XmlXvmCreateComp

XmlXvmEvaluateXPath

Name XmlXvmEvaluateXPath
Interface XSLTVM
Purpose Evaluate already-compiled XPath expression
Prototype xvmobj *XmlXvmEvaluateXPath(xmlxvm *vm, ub2 *bytecode, ub4 ctxpos,
                        ub4 ctxsize, xmlnode *ctxnode);
Arguments
vm  (IN)  XSLTVM object
bytecode  (IN)  XPath expression bytecode
ctxpos  (IN)  current context position
ctxsize  (IN)  current context size
ctxnode  (IN)  current context node
Returns (xvmobj *) XPath object
Description Evaluate already-compiled XPath expression

Example code   = XmlXvmCompileXPath(comp, xpath, NULL, &err);
obj    = XmlXvmEvaluateXPath(vm, code, 1, 1, node);
switch (XmlXvmGetObjectType(obj))
...

XmlXvmGetBytecodeLength

Name XmlXvmGetBytecodeLength
Interface XSLTC
Purpose Returns the bytecode length
Prototype ub4 XmlXvmGetBytecodeLength(ub2 *bytecode, xmlerr *error);
Arguments
bytecode  (IN)  bytecode buffer
error  (OUT)  returned error code
Returns (ub4) The bytecode length in bytes.
Description The bytecode length is needed when the bytecode is to be copied or when it is set into XSLTVM.

Example len = XmlXvmGetBytecodeLength(code, &err);
err = XmlXvmSetBytecodeBuffer (vm, code, len);

XmlXvmGetObjectBoolean

Name XmlXvmGetObjectBoolean
Interface XSLTVM
Purpose Get boolean value of XPath object
Prototype boolean XmlXvmGetObjectBoolean(xvmobj *obj);
Arguments
xobj  (IN)  XPath object.
Returns (boolean) value of an XPath object
Description Get boolean value of XPath object

Example obj = XmlXvmEvaluateXPath(vm, code, 1, 1, node);
switch (XmlXvmGetObjectType(obj)) 

    case XMLXVM_TYPE_BOOL:
bool = XmlXvmGetObjectBoolean(obj);
...
See Also XmlXvmGetObjectType, XmlXvmGetObjectNSetNum, XmlXvmGetObjectNSetNode, XmlXvmGetObjectNumber, XmlXvmGetObjectBoolean

XmlXvmGetObjectNSetNode

Name XmlXvmGetObjectNSetNode
Interface XSLTVM
Purpose Get node from nodeset-type XPath object
Prototype xmlnode *XmlXvmGetObjectNSetNode(xvmobj *obj, ub4 i);
Arguments
xobj  (IN)  XPath object
i  (IN)  node index in nodeset
Returns (xmlnode *) The object type or values.
Description Get node from nodeset-type XPath object

Example obj = XmlXvmEvaluateXPath(vm, code, 1, 1, node);
switch (XmlXvmGetObjectType(obj)) 

    case XMLXVM_TYPE_NDSET:
        objnum = XmlXvmGetObjectNSetNum(obj);
        for (i = 0; i < objnum; i++) 
            node = XmlXvmGetObjectNSetNode(obj, i);
            ...
See Also XmlXvmGetObjectType, XmlXvmGetObjectNSetNum, XmlXvmGetObjectString, XmlXvmGetObjectNumber, XmlXvmGetObjectBoolean

XmlXvmGetObjectNSetNum

Name XmlXvmGetObjectNSetNum
Interface XSLTVM
Purpose Get number of of nodes in nodeset-type XPath object
Prototype ub4 XmlXvmGetObjectNSetNum(xvmobj *obj);
Arguments
xobj  (IN)  XPath object (nodeset)
Returns (ub4) number of nodes in nodeset
Description Get number of of nodes in nodeset-type XPath object

Example obj = XmlXvmEvaluateXPath(vm, code, 1, 1, node);
switch (XmlXvmGetObjectType(obj)) 

    case XMLXVM_TYPE_NDSET:
        objnum = XmlXvmGetObjectNSetNum(obj);
        for (i = 0; i < objnum; i++) 
            node = XmlXvmGetObjectNSetNode(obj, i);
            ...
See Also XmlXvmGetObjectType, XmlXvmGetObjectNSetNode, XmlXvmGetObjectString, XmlXvmGetObjectNumber, XmlXvmGetObjectBoolean

XmlXvmGetObjectNumber

Name XmlXvmGetObjectNumber
Interface XSLTVM
Purpose Get number from XPath object
Prototype double XmlXvmGetObjectNumber(xvmobj *obj);
Arguments
xobj  (IN)  XPath object.
Returns (double) number
Description Get number from XPath object

Example obj = XmlXvmEvaluateXPath(vm, code, 1, 1, node);
switch (XmlXvmGetObjectType(obj)) 

    case XMLXVM_TYPE_NUM:
num = XmlXvmGetObjectNumber(obj);
        ...
See Also XmlXvmGetObjectType, XmlXvmGetObjectNSetNum, XmlXvmGetObjectNSetNode, XmlXvmGetObjectString, XmlXvmGetObjectBoolean

XmlXvmGetObjectString

Name XmlXvmGetObjectString
Interface XSLTVM
Purpose Get string from XPath object
Prototype oratext *XmlXvmGetObjectString(xvmobj *obj);
Arguments
xobj  (IN)  XPath object.
Returns (oratext *) string
Description Get string from XPath object

Example obj = XmlXvmEvaluateXPath(vm, code, 1, 1, node);
switch (XmlXvmGetObjectType(obj)) 

    case XMLXVM_TYPE_STR:
str = XmlXvmGetObjectString(obj);
        ...
See Also XmlXvmGetObjectType, XmlXvmGetObjectNSetNum, XmlXvmGetObjectNSetNode, XmlXvmGetObjectNumber, XmlXvmGetObjectBoolean

XmlXvmGetObjectType

Name XmlXvmGetObjectType
Interface XSLTVM
Purpose Get XPath object type
Prototype xmlxvmobjtype XmlXvmGetObjectType(xvmobj *obj);
Arguments
xobj  (IN)  XPath object
Returns (xmlxvmobjtype) type-code for object
Description Get XPath object type

Example switch (XmlXvmGetObjectType(obj)) 
    case XMLXVM_TYPE_NDSET: ...
    case XMLXVM_TYPE_BOOL: ...  
    case XMLXVM_TYPE_NUM: ... 
    case XMLXVM_TYPE_FRAG: ...
    case XMLXVM_TYPE_STR: ...
See Also XmlXvmGetObjectNSetNum, XmlXvmGetObjectNSetNode, XmlXvmGetObjectString, XmlXvmGetObjectNumber, XmlXvmGetObjectBoolean

XmlXvmGetOutputDom

Name XmlXvmGetOutputDom
Interface XSLTVM
Purpose Returns the output DOM
Prototype xmlfragnode *XmlXvmGetOutputDom(xmlxvm *vm);
Arguments
vm  (IN)  VM object
Returns (xmlfragnode *) output DOM, or NULL in a case of SAX or Stream output.
Description Returns the root node of the result DOM tree (if any). XmlXvmSetOutputDom() has to be used before transformation to set the VM to output a DOM tree (the default VM output is a stream).

Example doc  = XmlCreateDocument(xctx,  NULL, NULL, NULL, &err);
err  = XmlXvmSetOutputDom(vm, doc);
err  = XmlXvmTransformFile(vm, ...); 
root = XmlXvmGetOutputDom(vm);
See Also XmlXvmSetOutputDom

XmlXvmResetParams

Name XmlXvmResetParams
Interface XSLTVM
Purpose Resets the stylesheet top-level text params.
Prototype void XmlXvmResetParams(xmlxvm *vm);
Arguments
vm  (IN)  VM object
Returns No returns.
Description Resets the stylesheet top-level param with their default values.

XmlXvmSetBaseURI

Name XmlXvmSetBaseURI
Interface XSLTVM
Purpose Sets the base URI for the XSLTVM
Prototype xmlerr XmlXvmSetBaseURI(xmlxvm *vm, oratext *baseuri);
Arguments
vm  (IN)  VM object
baseuri  (IN)  VM baseuri for reading and writing documents
Returns (xmlerr) error code.
Description Sets the base URI for the XSLTVM. The baseuri is used by VM to the compose the path XML documents to be loaded for transformation using document() or XmlXvmTransformFile().

Example err  = XmlXvmSetBaseURI(vm, "/doc/myxmlfiles/");
err  = XmlXvmTransformFile(vm, "xmlfile1", NULL);
err  = XmlXvmTransformFile(vm, "xmlfile2", NULL);
...

XmlXvmSetBytecodeBuffer

Name XmlXvmSetBytecodeBuffer
Interface XSLTVM
Purpose Set the compiled byte-code
Prototype xmlerr XmlXvmSetBytecodeBuffer(xmlxvm *vm, ub2 *buffer, size_t buflen);
Arguments
vm  (IN)  XSLT VM context
buffer  (IN)  user's buffer
buflen  (IN)  size of buffer in bytes
Returns (xmlerr) numeric error code, XMLERR_OK [0] on success
Description Set the compiled bytecode from buffer. Any previously set bytecode is replaced. An XML transformation can't be performed if the stylesheet bytecode is not set. The VM doesn't copy the bytecode into internal buffer, hence the it shouldn't be freed before VM finishes using it.

Example code = XmlXvmCompileFile(comp, xslFile, baseuri, flags, &err);
len = XmlXvmGetBytecodeLength(code, &err);
err = XmlXvmSetBytecodeBuffer(vm, code, len);
See Also XmlXvmSetBytecodeFile, XmlXvmSetBytecodeURI

XmlXvmSetBytecodeFile

Name XmlXvmSetBytecodeFile
Interface XSLTVM
Purpose Set the compiled bytecode from file
Prototype xmlerr XmlXvmSetBytecodeFile(xmlxvm *vm, oratext *path);
Arguments
vm  (IN)  XSLT VM context
path  (IN)  path of bytecode file
Returns (xmlerr) numeric error code, XMLERR_OK [0] on success
Description Set the compiled bytecode from file. Any previously set bytecode is replaced. An XML transformation can't be performed if the stylesheet bytecode is not set.

Example err = XmlXvmSetBytecodeFile(vm, codefile);
err = XmlXvmTransformFile (vm, xmlFile, baseuri);
See Also XmlXvmSetBytecodeURI, XmlXvmSetBytecodeBuffer

XmlXvmSetBytecodeURI

Name XmlXvmSetBytecodeURI
Interface XSLTVM
Purpose Set the compiled byte-code
Prototype xmlerr XmlXvmSetBytecodeURI(xmlxvm *vm, oratext *uri);
Arguments
vm  (IN)  XSLT VM context
uri  (IN)  URI
Returns (xmlerr) numeric error code, XMLERR_OK [0] on success
Description Set the compiled bytecode from URI. Any previously set bytecode is replaced. An XML transformation can't be performed if the stylesheet bytecode is not set.

See Also XmlXvmSetBytecodeFile, XmlXvmSetBytecodeBuffer

XmlXvmSetDebugFunc

Name XmlXvmSetDebugFunc
Interface XSLTVM
Purpose Set a callback function for debuging
Prototype #define XMLXVM_DEBUG_FUNC(func) \
void func (ub2 line, oratext *filename, xvmobj *obj, ub4 n)
xmlerr XmlXvmSetDebugFunc(xmlxvm *vm, XMLXVM_DEBUG_FUNC(debugcallback));
Arguments
vm  (IN)  XSLT VM context
func  (IN)  the callback function
Returns (xmlerr) numeric error code, XMLERR_OK [0] on success
Description The user callback function is invoked by VM every time the execution reaches a new line in the XSLT stylesheet. The VM passes to the user the stylesheet file name, the line number, the current context nodes-set and the current node index in the node-set. IMPORTANT - the stylesheet has to be compiled with flag XMLXVM_DEBUG.

Example XMLXVM_DEBUG_F(MyCallbackFunction, line, file, obj, n);
...
code = XmlXvmCompileFile(comp, xslFile, NULL, XMLXVM_DEBUG, &err);
...
vm   = XmlXvmCreate(xctx, NULL);
len  = XmlXvmGetBytecodeLength(code, &err);
err  = XmlXvmSetBytecodeBuffer(vm, code, len);
err  = XmlXvmSetDebugFunc(vm, MyCallbackFunction);
err  = XmlXvmTransformFile(vm, xmlFile, baseuri);

XmlXvmSetOutputDom

Name XmlXvmSetOutputDom
Interface XSLTVM
Purpose Sets the XSLTVM to output document node.
Prototype xmlerr XmlXvmSetOutputDom(xmlxvm *vm, xmldocnode *doc);
Arguments
vm  (IN)  VM object
doc  (IN)  empty document
Returns (xmlerr) error code
Description Sets the XSLTVM to output DOM. If (xmldocnode == NULL) then the result DOM tree belongs to the VM object and is deleted when a new transformation is performed or when the VM object is deleted. If the result DOM tree is to be used for longer period of time then an xmldocnode has to be created and set to the VM object.

Example doc  = XmlCreateDocument(xctx,  NULL, NULL, NULL, &err);
err  = XmlXvmSetOutputDom(vm, doc);
err  = XmlXvmTransformFile(vm, ...); 
root = XmlXvmGetOutputDom(vm);

XmlXvmSetOutputEncoding

Name XmlXvmSetOutputEncoding
Interface XSLTVM
Purpose Sets the encoding for the XSLTVM output
Prototype xmlerr XmlXvmSetOutputEncoding(xmlxvm *vm, oratext *encoding);
Arguments
vm  (IN)  VM object
encoding  (IN)  output encoding
Returns (xmlerr) error code.
Description Sets the encoding for the XSLTVM stream output. If the input (data) encoding is different from the one set by this APIs then encoding conversion is performed. This APIs overrides the encoding set in the XSLT stylesheet (if any).

XmlXvmSetOutputSax

Name XmlXvmSetOutputSax
Interface XSLTVM
Purpose Set XSLTVM to output SAX
Prototype xmlerr XmlXvmSetOutputSax(xmlxvm *vm, xmlsaxcb *saxcb, void *saxctx);
Arguments
vm  (IN)  VM object
saxcb  (IN)  SAX callback object
saxctx  (IN)  SAX context
Returns (xmlerr) error code
Description Set XSLTVM to output SAX. If the SAX callback interface object is provided the VM outputs the result document in a form of SAX events using the user specified callback functions.

XmlXvmSetOutputStream

Name XmlXvmSetOutputStream
Interface XSLTVM
Purpose Set the XSLTVM output to a user-defined stream
Prototype xmlerr XmlXvmSetOutputStream(xmlxvm *vm, xmlostream *ostream);
Arguments
vm  (IN)  VM object
ostream  (IN)  stream object
Returns (xmlerr) error code.
Description Set the XSLTVM output to a user-defined stream. The default XSLTVM output is a stream. This APIs overrides the default stream with user spesified APIs for writing.

XmlXvmSetTextParam

Name XmlXvmSetTextParam
Interface XSLTVM
Purpose Set the stylesheet top-level text param.
Prototype xmlerr XmlXvmSetTextParam(xmlxvm *vm, oratext *name, oratext *value);
Arguments
vm  (IN)  VM object
name  (IN)  name of top-level param
value  (IN)  value of top-level param
Returns (xmlerr) error code, XMLERR_SUCC [0] on success.
Description Set the stylesheet top-level text param. The param value set in the XSLT stylesheet is overritten. Since the top-level param are reset with stylesheed values after each transformation this APIs has to be called again.

XmlXvmTransformBuffer

Name XmlXvmTransformBuffer
Interface XSLTVM
Purpose Run compiled XSLT stylesheet on XML document in memory
Prototype xmlerr XmlXvmTransformBuffer(xmlxvm *vm, oratext *buffer,
                           ub4 length, oratext *baseURI);
Arguments
vm  (IN)  VM object
buffer  (IN)  NULL-terminated buffer containing the XML document
length  (IN)  the length of the XML document
baseURI(IN)  (base)  base URI of the XML document
Returns (xmlerr) error code.
Description Run compiled XSLT stylesheet on XML document in memory. The compiled XSLT stylesheet (bytecode) should be set using XmlXvmSetBytecode...() prior to this call. xsl:output is supported only if the output is a stream instead of DOM or SAX.

See Also XmlXvmTransformFile, XmlXvmTransformURI, XmlXvmTransformDom

XmlXvmTransformDom

Name XmlXvmTransformDom
Interface XSLTVM
Purpose Run compiled XSLT stylesheet on XML document as DOM
Prototype xmlerr XmlXvmTransformDom(xmlxvm *vm, xmldocnode *root);
Arguments
vm  (IN)  VM object
root  (IN)  root element of the XML document's DOM
Returns (xmlerr) error code.
Description Run compiled XSLT stylesheet on XML document as DOM. The compiled XSLT stylesheet (bytecode) should be set using XmlXvmSetBytecode...() prior to this call. xsl:output is supported only if the output is a stream instead of DOM or SAX.

Example code   = XmlXvmCompileFile(comp, xslFile, baseuri, 0, &err);
vm     = XmlXvmCreate(xctx, NULL);
len    = XmlXvmGetBytecodeLength(code, &err);
err    = XmlXvmSetBytecodeBuffer (vm, code, len); 
domdoc = XmlLoadDom(xctx, &err, "uri", xmlFile, NULL);
err    = XmlXvmTransformDom(vm, domdoc);
err    = XmlXvmTransformDom (vm, domdoc);
See Also XmlXvmTransformFile, XmlXvmTransformURI, XmlXvmTransformBuffer

XmlXvmTransformFile

Name XmlXvmTransformFile
Interface XSLTVM
Purpose Run compiled XSLT stylesheet on XML document in file
Prototype xmlerr XmlXvmTransformFile(xmlxvm *vm, oratext *path, oratext *baseURI);
Arguments
vm  (IN)  VM object
path  (IN)  path of XML document to transform
Returns (xmlerr) error code
Description Run compiled XSLT stylesheet on XML document in file. The compiled XSLT stylesheet (bytecode) should be set using XmlXvmSetBytecode ...() prior to this call. xsl:output is supported only if the output is a stream instead of DOM or SAX.

Example code = XmlXvmCompileFile(comp, xslFile, baseuri, 0, &err);
...
vm   = XmlXvmCreate(xctx, NULL);
len  = XmlXvmGetBytecodeLength(code, &err);
err  = XmlXvmSetBytecodeBuffer(vm, code, len);
err  = XmlXvmTransformFile(vm, xmlFile[i], baseuri);
See Also XmlXvmTransformURI, XmlXvmTransformBuffer, XmlXvmTransformDom

XmlXvmTransformURI

Name XmlXvmTransformURI
Interface XSLTVM
Purpose Run compiled XSLT stylesheet on XML document from URI
Prototype xmlerr XmlXvmTransformURI(xmlxvm *vm, oratext *uri);
Arguments
vm  (IN)  VM object
uri  (IN)  URI of XML document to transform
baseuri  (IN)  base URI of XML document
Returns (xmlerr) error code.
Description Run compiled XSLT stylesheet on XML document from URI. The compiled XSLT stylesheet (bytecode) should be set using XmlXvmSetBytecode ...() prior to this call. xsl:output is supported only if the output is a stream instead of DOM or SAX.

See Also XmlXvmTransformFile, XmlXvmTransformBuffer, XmlXvmTransformDom