# The XSLT C library for Gnome ## Module xsltutils from libxslt

API Menu
Main Menu Developer Menu API Menu ChangeLog
Related links
Mail archive XML libxml DOM gdome2 FTP Windows binaries Solaris binaries MacOsX binaries Pascal bindings Bug Tracker Xsldbg Debugger Apache module
API Indexes
Alphabetic Constructors Functions/Types Modules Symbols
interfaces for the utilities module of the XSLT engine. things like message handling, profiling, and other generally useful routines. ## Table of Contents
    #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
    Enum xsltDebugStatusCodes
    Enum xsltDebugTraceCodes
    int	xslAddCall			(xsltTemplatePtr templ,
    					 xmlNodePtr source)
    void	xslDropCall			(void)
    Function type: xsltAddCallCallback
    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)
    Function type: xsltDropCallCallback
    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)
    Function type: xsltHandleDebuggerCallback
    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)
    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)
## Description ### 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. ### Enum xsltDebugStatusCodes
    Enum xsltDebugStatusCodes {
        XSLT_DEBUG_NONE = 0 : no debugging allowed
        XSLT_DEBUG_INIT = 1
        XSLT_DEBUG_STEP = 2
        XSLT_DEBUG_STEPOUT = 3
        XSLT_DEBUG_NEXT = 4
        XSLT_DEBUG_STOP = 5
        XSLT_DEBUG_CONT = 6
        XSLT_DEBUG_RUN = 7
        XSLT_DEBUG_RUN_RESTART = 8
        XSLT_DEBUG_QUIT = 9
    }
### Enum xsltDebugTraceCodes
    Enum xsltDebugTraceCodes {
        XSLT_TRACE_ALL = -1
        XSLT_TRACE_NONE = 0
        XSLT_TRACE_COPY_TEXT = 1
        XSLT_TRACE_PROCESS_NODE = 2
        XSLT_TRACE_APPLY_TEMPLATE = 4
        XSLT_TRACE_COPY = 8
        XSLT_TRACE_COMMENT = 16
        XSLT_TRACE_PI = 32
        XSLT_TRACE_COPY_OF = 64
        XSLT_TRACE_VALUE_OF = 128
        XSLT_TRACE_CALL_TEMPLATE = 256
        XSLT_TRACE_APPLY_TEMPLATES = 512
        XSLT_TRACE_CHOOSE = 1024
        XSLT_TRACE_IF = 2048
        XSLT_TRACE_FOR_EACH = 4096
        XSLT_TRACE_STRIP_SPACES = 8192
        XSLT_TRACE_TEMPLATES = 16384
        XSLT_TRACE_KEYS = 32768
        XSLT_TRACE_VARIABLES = 65536
    }
### Function: 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
### Function: xslDropCall
    void	xslDropCall			(void)
Drop the topmost item off the call stack ### Function type: xsltAddCallCallback
    Function type: xsltAddCallCallback
    int	xsltAddCallCallback		(xsltTemplatePtr templ,
    					 xmlNodePtr source)
`templ`: |
`source`: |
`Returns`: |
### Function: xsltCalibrateAdjust
    void	xsltCalibrateAdjust		(long delta)
Used for to correct the calibration for xsltTimestamp()
`delta`: | a negative dealy value found
### Function: 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.
### Function: xsltDebugGetDefaultTrace
    xsltDebugTraceCodes	xsltDebugGetDefaultTrace	(void)
Get the current default debug tracing level mask
`Returns`: | the current default debug tracing level mask
### Function: xsltDebugSetDefaultTrace
    void	xsltDebugSetDefaultTrace	(xsltDebugTraceCodes val)
Set the default debug tracing level mask
`val`: | tracing level mask
### Function: 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
### Function: 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
### Function: xsltDocumentSortFunction
    void	xsltDocumentSortFunction	(xmlNodeSetPtr list)
reorder the current node list @list accordingly to the document order
`list`: | the node set
### Function type: xsltDropCallCallback
    Function type: xsltDropCallCallback
    void	xsltDropCallCallback		(void)
### Function: 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 dictionnary.
### Function: xsltGetDebuggerStatus
    int	xsltGetDebuggerStatus		(void)
Get xslDebugStatus.
`Returns`: | the value of xslDebugStatus.
### Function: xsltGetNsProp
    xmlChar *	xsltGetNsProp		(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.
`node`: | the node
`name`: | the attribute name
`nameSpace`: | the URI of the namespace
`Returns`: | the attribute value or NULL if not found. It's up to the caller to free the memory.
### Function: xsltGetProfileInformation
    xmlDocPtr	xsltGetProfileInformation	(xsltTransformContextPtr ctxt)
This function should be called after the transformation completed to extract template processing profiling informations if availble. The informations are 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.
### Function: xsltGetQNameURI
    const xmlChar *	xsltGetQNameURI		(xmlNodePtr node,
    					 xmlChar ** name)
This function analyzes @name, if the name contains a prefix, the function seaches the associated namespace in scope for it. It will also replace @name value with the NCName, the old value being freed. Errors in the prefix lookup are signalled by setting @name to NULL. NOTE: the namespace returned is a pointer to the place where it is defined and hence has the same lifespan as the document holding it.
`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.
### Function: 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.
### Function: xsltGetUTF8Char
    int	xsltGetUTF8Char			(const unsigned char * utf,
    					 int * len)
Read one UTF8 Char from @utf Function copied from libxml2 xmlGetUTF8Char() ... to discard ultimately and use the original API
`utf`: | a sequence of UTF-8 encoded bytes
`len`: | a pointer to @bytes len
`Returns`: | the char value or -1 in case of error and update @len with the number of bytes used
### Function type: xsltHandleDebuggerCallback
    Function type: xsltHandleDebuggerCallback
    void	xsltHandleDebuggerCallback	(xmlNodePtr cur,
    					 xmlNodePtr node,
    					 xsltTemplatePtr templ,
    					 xsltTransformContextPtr ctxt)
`cur`: |
`node`: |
`templ`: |
`ctxt`: |
### Function: 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
### Function: 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
### Function: xsltSaveProfiling
    void	xsltSaveProfiling		(xsltTransformContextPtr ctxt,
    					 FILE * output)
Save the profiling informations on @output
`ctxt`: | an XSLT context
`output`: | a FILE * for saving the informations
### Function: 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.
### Function: 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.
### Function: 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.
### Function: 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.
### Function: 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 file or @URL
`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`: | the number of byte written or -1 in case of failure.
### Function: 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
### Function: xsltSetCtxtSortFunc
    void	xsltSetCtxtSortFunc		(xsltTransformContextPtr ctxt,
    					 xsltSortFunc handler)
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
### Function: xsltSetDebuggerCallbacks
    int	xsltSetDebuggerCallbacks	(int no,
    					 void * block)
This function allow to plug a debugger into the XSLT library @block points to a block of memory containing the address of @no callback routines.
`no`: | number of callbacks
`block`: | the block of callbacks
`Returns`: | 0 in case of success and -1 in case of error
### Function: xsltSetDebuggerStatus
    void	xsltSetDebuggerStatus		(int value)
This function sets the value of xslDebugStatus.
`value`: | the value to be set
### Function: xsltSetGenericDebugFunc
    void	xsltSetGenericDebugFunc		(void * ctx,
    					 xmlGenericErrorFunc handler)
Function to reset the handler and the error context for out of context error messages. This simply means that @handler will be called for subsequent error messages while not parsing or validating. And @ctx will be passed as first argument to @handler One can simply force messages to be emitted to another FILE * than stderr by setting @ctx to this file handle and @handler to NULL.
`ctx`: | the new error handling context
`handler`: | the new handler function
### Function: xsltSetGenericErrorFunc
    void	xsltSetGenericErrorFunc		(void * ctx,
    					 xmlGenericErrorFunc handler)
Function to reset the handler and the error context for out of context error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler One can simply force messages to be emitted to another FILE * than stderr by setting @ctx to this file handle and @handler to NULL.
`ctx`: | the new error handling context
`handler`: | the new handler function
### Function: xsltSetSortFunc
    void	xsltSetSortFunc			(xsltSortFunc handler)
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
### 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
### Function: xsltSplitQName
    const xmlChar *	xsltSplitQName		(xmlDictPtr dict,
    					 const xmlChar * name,
    					 const xmlChar ** prefix)
Split QNames into prefix and local names, both allocated from a dictionnary.
`dict`: | a dictionnary
`name`: | the full QName
`prefix`: | the return value
`Returns`: | the localname or NULL in case of error.
### Function: xsltTimestamp
    long	xsltTimestamp			(void)
Used for gathering profiling data
`Returns`: | the number of tenth of milliseconds since the beginning of the profiling
### 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
### Function: 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.
Daniel Veillard