xsltutils

xsltutils - set of utilities for the XSLT engine

interfaces for the utilities module of the XSLT engine. things like message handling, profiling, and other generally useful routines.

Author(s): Daniel Veillard

Synopsis

#define IS_XSLT_ELEM;
#define IS_XSLT_NAME;
#define IS_XSLT_REAL_NODE;
#define XSLT_STRANGE;
#define XSLT_TIMESTAMP_TICS_PER_SEC;
#define XSLT_TODO;
#define XSLT_TRACE;
typedef enum xsltDebugStatusCodes;
typedef enum xsltDebugTraceCodes;
int	xslAddCall			(xsltTemplatePtr templ, 
xmlNodePtr source); void xslDropCall (void); typedef int xsltAddCallCallback (xsltTemplatePtr templ,
xmlNodePtr source); void xsltCalibrateAdjust (long delta); xmlXPathObjectPtr * xsltComputeSortResult (xsltTransformContextPtr ctxt,
xmlNodePtr sort); xsltDebugTraceCodes xsltDebugGetDefaultTrace (void); void xsltDebugSetDefaultTrace (xsltDebugTraceCodes val); void xsltDefaultSortFunction (xsltTransformContextPtr ctxt,
xmlNodePtr * sorts,
int nbsorts); void xsltDoSortFunction (xsltTransformContextPtr ctxt,
xmlNodePtr * sorts,
int nbsorts); void xsltDocumentSortFunction (xmlNodeSetPtr list); typedef void xsltDropCallCallback (void); const xmlChar * xsltGetCNsProp (xsltStylesheetPtr style,
xmlNodePtr node,
const xmlChar * name,
const xmlChar * nameSpace); int xsltGetDebuggerStatus (void); xmlChar * xsltGetNsProp (xmlNodePtr node,
const xmlChar * name,
const xmlChar * nameSpace); xmlDocPtr xsltGetProfileInformation (xsltTransformContextPtr ctxt); const xmlChar * xsltGetQNameURI (xmlNodePtr node,
xmlChar ** name); const xmlChar * xsltGetQNameURI2 (xsltStylesheetPtr style,
xmlNodePtr node,
const xmlChar ** name); int xsltGetUTF8Char (const unsigned char * utf,
int * len); typedef void xsltHandleDebuggerCallback (xmlNodePtr cur,
xmlNodePtr node,
xsltTemplatePtr templ,
xsltTransformContextPtr ctxt); void xsltMessage (xsltTransformContextPtr ctxt,
xmlNodePtr node,
xmlNodePtr inst); void xsltPrintErrorContext (xsltTransformContextPtr ctxt,
xsltStylesheetPtr style,
xmlNodePtr node); void xsltSaveProfiling (xsltTransformContextPtr ctxt,
FILE * output); int xsltSaveResultTo (xmlOutputBufferPtr buf,
xmlDocPtr result,
xsltStylesheetPtr style); int xsltSaveResultToFd (int fd,
xmlDocPtr result,
xsltStylesheetPtr style); int xsltSaveResultToFile (FILE * file,
xmlDocPtr result,
xsltStylesheetPtr style); int xsltSaveResultToFilename (const char * URL,
xmlDocPtr result,
xsltStylesheetPtr style,
int compression); int xsltSaveResultToString (xmlChar ** doc_txt_ptr,
int * doc_txt_len,
xmlDocPtr result,
xsltStylesheetPtr style); void xsltSetCtxtLocaleHandlers (xsltTransformContextPtr ctxt,
xsltNewLocaleFunc newLocale,
xsltFreeLocaleFunc freeLocale,
xsltGenSortKeyFunc genSortKey); int xsltSetCtxtParseOptions (xsltTransformContextPtr ctxt,
int options); void xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt,
xsltSortFunc handler); int xsltSetDebuggerCallbacks (int no,
void * block); void xsltSetDebuggerStatus (int value); void xsltSetGenericDebugFunc (void * ctx,
xmlGenericErrorFunc handler); void xsltSetGenericErrorFunc (void * ctx,
xmlGenericErrorFunc handler); void xsltSetSortFunc (xsltSortFunc handler); void xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt,
void * ctx,
xmlGenericErrorFunc handler); const xmlChar * xsltSplitQName (xmlDictPtr dict,
const xmlChar * name,
const xmlChar ** prefix); long xsltTimestamp (void); void xsltTransformError (xsltTransformContextPtr ctxt,
xsltStylesheetPtr style,
xmlNodePtr node,
const char * msg,
... ...); xmlXPathCompExprPtr xsltXPathCompile (xsltStylesheetPtr style,
const xmlChar * str); xmlXPathCompExprPtr xsltXPathCompileFlags (xsltStylesheetPtr style,
const xmlChar * str,
int flags);

Description

Details

Macro IS_XSLT_ELEM

#define IS_XSLT_ELEM;

Checks that the element pertains to XSLT namespace.


Macro IS_XSLT_NAME

#define IS_XSLT_NAME;

Checks the value of an element in XSLT namespace.


Macro IS_XSLT_REAL_NODE

#define IS_XSLT_REAL_NODE;

Check that a node is a 'real' one: document, element, text or attribute.


Macro XSLT_STRANGE

#define XSLT_STRANGE;

Macro to flag that a problem was detected internally.


Macro XSLT_TIMESTAMP_TICS_PER_SEC

#define XSLT_TIMESTAMP_TICS_PER_SEC;

Sampling precision for profiling


Macro XSLT_TODO

#define XSLT_TODO;

Macro to flag unimplemented blocks.


Macro XSLT_TRACE

#define XSLT_TRACE;

Control the type of xsl debugtrace messages emitted.







Variable xslDebugStatus

int xslDebugStatus;


Variable xsltGenericDebug

xmlGenericErrorFunc xsltGenericDebug;


Variable xsltGenericDebugContext

void * xsltGenericDebugContext;


Variable xsltGenericError

xmlGenericErrorFunc xsltGenericError;


Variable xsltGenericErrorContext

void * xsltGenericErrorContext;


xslAddCall ()

int	xslAddCall			(xsltTemplatePtr templ, 
xmlNodePtr source)

Add template "call" to call stack

templ:current template being applied
source:the source node being processed
Returns:: 1 on sucess 0 otherwise an error may be printed if WITH_XSLT_DEBUG_BREAKPOINTS is defined



xsltComputeSortResult ()

xmlXPathObjectPtr *	xsltComputeSortResult	(xsltTransformContextPtr ctxt, 
xmlNodePtr sort)

reorder the current node list accordingly to the set of sorting requirement provided by the array of nodes.

ctxt:a XSLT process context
sort:node list
Returns:a ordered XPath nodeset or NULL in case of error.

xsltDebugGetDefaultTrace ()

xsltDebugTraceCodes	xsltDebugGetDefaultTrace	(void)

Get the current default debug tracing level mask

Returns:the current default debug tracing level mask

xsltDebugSetDefaultTrace ()

void	xsltDebugSetDefaultTrace	(xsltDebugTraceCodes val)

Set the default debug tracing level mask

val:tracing level mask

xsltDefaultSortFunction ()

void	xsltDefaultSortFunction		(xsltTransformContextPtr ctxt, 
xmlNodePtr * sorts,
int nbsorts)

reorder the current node list accordingly to the set of sorting requirement provided by the arry of nodes.

ctxt:a XSLT process context
sorts:array of sort nodes
nbsorts:the number of sorts in the array

xsltDoSortFunction ()

void	xsltDoSortFunction		(xsltTransformContextPtr ctxt, 
xmlNodePtr * sorts,
int nbsorts)

reorder the current node list accordingly to the set of sorting requirement provided by the arry of nodes. This is a wrapper function, the actual function used is specified using xsltSetCtxtSortFunc() to set the context specific sort function, or xsltSetSortFunc() to set the global sort function. If a sort function is set on the context, this will get called. Otherwise the global sort function is called.

ctxt:a XSLT process context
sorts:array of sort nodes
nbsorts:the number of sorts in the array


xsltGetCNsProp ()

const xmlChar *	xsltGetCNsProp		(xsltStylesheetPtr style, 
xmlNodePtr node,
const xmlChar * name,
const xmlChar * nameSpace)

Similar to xmlGetNsProp() but with a slightly different semantic Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified, or has no namespace and the element is in that namespace. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off.

style:the stylesheet
node:the node
name:the attribute name
nameSpace:the URI of the namespace
Returns:the attribute value or NULL if not found. The string is allocated in the stylesheet dictionary.



xsltGetProfileInformation ()

xmlDocPtr	xsltGetProfileInformation	(xsltTransformContextPtr ctxt)

This function should be called after the transformation completed to extract template processing profiling information if available. The information is returned as an XML document tree like <?xml version="1.0"?> <profile> <template rank="1" match="*" name="" mode="" calls="6" time="48" average="8"/> <template rank="2" match="item2|item3" name="" mode="" calls="10" time="30" average="3"/> <template rank="3" match="item1" name="" mode="" calls="5" time="17" average="3"/> </profile> The caller will need to free up the returned tree with xmlFreeDoc()

ctxt:a transformation context
Returns:the xmlDocPtr corresponding to the result or NULL if not available.


xsltGetQNameURI2 ()

const xmlChar *	xsltGetQNameURI2	(xsltStylesheetPtr style, 
xmlNodePtr node,
const xmlChar ** name)

This function is similar to xsltGetQNameURI, but is used when @name is a dictionary entry.

style:stylesheet pointer
node:the node holding the QName
name:pointer to the initial QName value
Returns:the namespace URI if there is a prefix, or NULL if @name is not prefixed.


xsltMessage ()

void	xsltMessage			(xsltTransformContextPtr ctxt, 
xmlNodePtr node,
xmlNodePtr inst)

Process and xsl:message construct

ctxt:an XSLT processing context
node:The current node
inst:The node containing the message instruction

xsltPrintErrorContext ()

void	xsltPrintErrorContext		(xsltTransformContextPtr ctxt, 
xsltStylesheetPtr style,
xmlNodePtr node)

Display the context of an error.

ctxt:the transformation context
style:the stylesheet
node:the current node being processed

xsltSaveProfiling ()

void	xsltSaveProfiling		(xsltTransformContextPtr ctxt, 
FILE * output)

Save the profiling information on @output

ctxt:an XSLT context
output:a FILE * for saving the information

xsltSaveResultTo ()

int	xsltSaveResultTo		(xmlOutputBufferPtr buf, 
xmlDocPtr result,
xsltStylesheetPtr style)

Save the result @result obtained by applying the @style stylesheet to an I/O output channel @buf

buf:an output buffer
result:the result xmlDocPtr
style:the stylesheet
Returns:the number of byte written or -1 in case of failure.

xsltSaveResultToFd ()

int	xsltSaveResultToFd		(int fd, 
xmlDocPtr result,
xsltStylesheetPtr style)

Save the result @result obtained by applying the @style stylesheet to an open file descriptor This does not close the descriptor.

fd:a file descriptor
result:the result xmlDocPtr
style:the stylesheet
Returns:the number of bytes written or -1 in case of failure.

xsltSaveResultToFile ()

int	xsltSaveResultToFile		(FILE * file, 
xmlDocPtr result,
xsltStylesheetPtr style)

Save the result @result obtained by applying the @style stylesheet to an open FILE * I/O. This does not close the FILE @file

file:a FILE * I/O
result:the result xmlDocPtr
style:the stylesheet
Returns:the number of bytes written or -1 in case of failure.

xsltSaveResultToFilename ()

int	xsltSaveResultToFilename	(const char * URL, 
xmlDocPtr result,
xsltStylesheetPtr style,
int compression)

Save the result @result obtained by applying the @style stylesheet to a file or @URL

URL:a filename or URL
result:the result xmlDocPtr
style:the stylesheet
compression:the compression factor (0 - 9 included)
Returns:the number of byte written or -1 in case of failure.

xsltSaveResultToString ()

int	xsltSaveResultToString		(xmlChar ** doc_txt_ptr, 
int * doc_txt_len,
xmlDocPtr result,
xsltStylesheetPtr style)

Save the result @result obtained by applying the @style stylesheet to a new allocated string.

doc_txt_ptr:Memory pointer for allocated XML text
doc_txt_len:Length of the generated XML text
result:the result xmlDocPtr
style:the stylesheet
Returns:0 in case of success and -1 in case of error

xsltSetCtxtLocaleHandlers ()

void	xsltSetCtxtLocaleHandlers	(xsltTransformContextPtr ctxt, 
xsltNewLocaleFunc newLocale,
xsltFreeLocaleFunc freeLocale,
xsltGenSortKeyFunc genSortKey)

Set the locale handlers.

ctxt:an XSLT transform context
newLocale:locale constructor
freeLocale:locale destructor
genSortKey:sort key generator

xsltSetCtxtParseOptions ()

int	xsltSetCtxtParseOptions		(xsltTransformContextPtr ctxt, 
int options)

Change the default parser option passed by the XSLT engine to the parser when using document() loading.

ctxt:a XSLT process context
options:a combination of libxml2 xmlParserOption
Returns:the previous options or -1 in case of error

xsltSetCtxtSortFunc ()

void	xsltSetCtxtSortFunc		(xsltTransformContextPtr ctxt, 
xsltSortFunc handler)

DEPRECATED: Use xsltSetCtxtLocaleHandlers. Function to set the handler for XSLT sorting for the specified context. If the handler is NULL, then the global sort function will be called

ctxt:a XSLT process context
handler:the new handler function





xsltSetSortFunc ()

void	xsltSetSortFunc			(xsltSortFunc handler)

DEPRECATED: Use xsltSetCtxtLocaleHandlers. Function to reset the global handler for XSLT sorting. If the handler is NULL, the default sort function will be used.

handler:the new handler function

xsltSetTransformErrorFunc ()

void	xsltSetTransformErrorFunc	(xsltTransformContextPtr ctxt, 
void * ctx,
xmlGenericErrorFunc handler)

Function to reset the handler and the error context for out of context error messages specific to a given XSLT transromation. This simply means that @handler will be called for subsequent error messages while running the transformation.

ctxt:the XSLT transformation context
ctx:the new error handling context
handler:the new handler function



xsltTransformError ()

void	xsltTransformError		(xsltTransformContextPtr ctxt, 
xsltStylesheetPtr style,
xmlNodePtr node,
const char * msg,
... ...)

Display and format an error messages, gives file, line, position and extra parameters, will use the specific transformation context if available

ctxt:an XSLT transformation context
style:the XSLT stylesheet used
node:the current node in the stylesheet
msg:the message to display/transmit
...:extra parameters for the message display

xsltXPathCompile ()

xmlXPathCompExprPtr	xsltXPathCompile	(xsltStylesheetPtr style, 
const xmlChar * str)

Compile an XPath expression

style:the stylesheet
str:the XPath expression
Returns:the xmlXPathCompExprPtr resulting from the compilation or NULL. the caller has to free the object.

xsltXPathCompileFlags ()

xmlXPathCompExprPtr	xsltXPathCompileFlags	(xsltStylesheetPtr style, 
const xmlChar * str,
int flags)

Compile an XPath expression

style:the stylesheet
str:the XPath expression
flags:extra compilation flags to pass down to libxml2 XPath
Returns:the xmlXPathCompExprPtr resulting from the compilation or NULL. the caller has to free the object.