* Summary: internal data structures, constants and functions
* Description: Internal data structures, constants and functions used
* They are not part of the API or ABI, i.e. they can change
* without prior notice, use carefully.
* Copy: See Copyright for the status of this software.
* Author: Daniel Veillard
#ifndef __XML_XSLT_INTERNALS_H__
#define __XML_XSLT_INTERNALS_H__
#include <libxml/xpath.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlstring.h>
#include <libxslt/xslt.h>
#include "numbersInternals.h"
/* #define XSLT_DEBUG_PROFILE_CACHE */
* check if the argument is a text node
#define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
(((n)->type == XML_TEXT_NODE) || \
((n)->type == XML_CDATA_SECTION_NODE)))
* XSLT_MARK_RES_TREE_FRAG:
* internal macro to set up tree fragments
#define XSLT_MARK_RES_TREE_FRAG(n) \
(n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
* internal macro to test tree fragments
#define XSLT_IS_RES_TREE_FRAG(n) \
((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
((n)->name != NULL) && ((n)->name[0] == ' '))
* XSLT_REFACTORED_KEYCOMP:
* Internal define to enable on-demand xsl:key computation.
* That's the only mode now but the define is kept for compatibility
#define XSLT_REFACTORED_KEYCOMP
* Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
* for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
* Internal define to enable the refactored parts of Libxslt.
/* #define XSLT_REFACTORED */
/* ==================================================================== */
* Internal define to enable the refactored variable part of libxslt
#define XSLT_REFACTORED_VARS
extern const xmlChar *xsltXSLTAttrMarker;
/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
* XSLT_REFACTORED_XSLT_NSCOMP
* Internal define to enable the pointer-comparison of
* namespaces of XSLT elements.
/* #define XSLT_REFACTORED_XSLT_NSCOMP */
* XSLT_REFACTORED_XPATHCOMP:
* Internal define to enable the optimization of the
* compilation of XPath expressions.
#define XSLT_REFACTORED_XPATHCOMP
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
extern const xmlChar *xsltConstNamespaceNameXSLT;
* quick test to detect XSLT elements
#define IS_XSLT_ELEM_FAST(n) \
(((n) != NULL) && ((n)->ns != NULL) && \
((n)->ns->href == xsltConstNamespaceNameXSLT))
* quick test to detect XSLT attributes
#define IS_XSLT_ATTR_FAST(a) \
(((a) != NULL) && ((a)->ns != NULL) && \
((a)->ns->href == xsltConstNamespaceNameXSLT))
* XSLT_HAS_INTERNAL_NSMAP:
* check for namespace mapping
#define XSLT_HAS_INTERNAL_NSMAP(s) \
(((s) != NULL) && ((s)->principal) && \
((s)->principal->principalData) && \
((s)->principal->principalData->nsMap))
* XSLT_GET_INTERNAL_NSMAP:
* get pointer to namespace map
#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
#else /* XSLT_REFACTORED_XSLT_NSCOMP */
* quick check whether this is an xslt element
#define IS_XSLT_ELEM_FAST(n) \
(((n) != NULL) && ((n)->ns != NULL) && \
(xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
* quick check for xslt namespace attribute
#define IS_XSLT_ATTR_FAST(a) \
(((a) != NULL) && ((a)->ns != NULL) && \
(xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
* XSLT_REFACTORED_MANDATORY_VERSION:
* TODO: Currently disabled to surpress regression test failures, since
* the old behaviour was that a missing version attribute
* produced a only a warning and not an error, which was incerrect.
* So the regression tests need to be fixed if this is enabled.
/* #define XSLT_REFACTORED_MANDATORY_VERSION */
* Pointer-list for various purposes.
typedef struct _xsltPointerList xsltPointerList;
typedef xsltPointerList *xsltPointerListPtr;
struct _xsltPointerList {
* XSLT_REFACTORED_PARSING:
* Internal define to enable the refactored parts of Libxslt
/* #define XSLT_REFACTORED_PARSING */
* Max number of specified xsl:sort on an element.
* Specific value for pattern without priority expressed.
#define XSLT_PAT_NO_PRIORITY -12345789
* Extra information added to the transformation context.
typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
struct _xsltRuntimeExtra {
void *info; /* pointer to the extra data */
xmlFreeFunc deallocate; /* pointer to the deallocation routine */
union { /* dual-purpose field */
void *ptr; /* data not needing deallocation */
int ival; /* integer value storage */
* XSLT_RUNTIME_EXTRA_LST:
* @ctxt: the transformation context
* Macro used to access extra information stored in the context
#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
* XSLT_RUNTIME_EXTRA_FREE:
* @ctxt: the transformation context
* Macro used to free extra information stored in the context
#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
* @ctxt: the transformation context
* Macro used to define extra information stored in the context
#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
* The in-memory structure corresponding to an XSLT Template.
typedef struct _xsltTemplate xsltTemplate;
typedef xsltTemplate *xsltTemplatePtr;
struct _xsltTemplate *next;/* chained list sorted by priority */
struct _xsltStylesheet *style;/* the containing stylesheet */
xmlChar *match; /* the matching string */
float priority; /* as given from the stylesheet, not computed */
const xmlChar *name; /* the local part of the name QName */
const xmlChar *nameURI; /* the URI part of the name QName */
const xmlChar *mode;/* the local part of the mode QName */
const xmlChar *modeURI;/* the URI part of the mode QName */
xmlNodePtr content; /* the template replacement value */
xmlNodePtr elem; /* the source element */
* TODO: @inheritedNsNr and @inheritedNs won't be used in the
int inheritedNsNr; /* number of inherited namespaces */
xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
/* Profiling informations */
int nbCalls; /* the number of time the template was called */
unsigned long time; /* the time spent in this template */
void *params; /* xsl:param instructions */
int templNr; /* Nb of templates in the stack */
int templMax; /* Size of the templtes stack */
xsltTemplatePtr *templCalledTab; /* templates called */
int *templCountTab; /* .. and how often */
* Data structure of decimal-format.
typedef struct _xsltDecimalFormat xsltDecimalFormat;
typedef xsltDecimalFormat *xsltDecimalFormatPtr;
struct _xsltDecimalFormat {
struct _xsltDecimalFormat *next; /* chained list */
/* Used for interpretation of pattern */
xmlChar *patternSeparator;
/* May appear in result */
xmlChar *noNumber; /* Not-a-number */
/* Used for interpretation of pattern and may appear in result */
* Data structure associated to a parsed document.
typedef struct _xsltDocument xsltDocument;
typedef xsltDocument *xsltDocumentPtr;
struct _xsltDocument *next; /* documents are kept in a chained list */
int main; /* is this the main document */
xmlDocPtr doc; /* the parsed document */
void *keys; /* key tables storage */
struct _xsltDocument *includes; /* subsidiary includes */
int preproc; /* pre-processing already done */
* Representation of an xsl:key.
typedef struct _xsltKeyDef xsltKeyDef;
typedef xsltKeyDef *xsltKeyDefPtr;
struct _xsltKeyDef *next;
xmlXPathCompExprPtr comp;
xmlXPathCompExprPtr usecomp;
xmlNsPtr *nsList; /* the namespaces in scope */
int nsNr; /* the number of namespaces in scope */
* Holds the computed keys for key definitions of the same QName.
* Is owned by an xsltDocument.
typedef struct _xsltKeyTable xsltKeyTable;
typedef xsltKeyTable *xsltKeyTablePtr;
struct _xsltKeyTable *next;
* The in-memory structure corresponding to an XSLT Stylesheet.
* NOTE: most of the content is simply linked from the doc tree
* structure, no specific allocation is made.
typedef struct _xsltStylesheet xsltStylesheet;
typedef xsltStylesheet *xsltStylesheetPtr;
typedef struct _xsltTransformContext xsltTransformContext;
typedef xsltTransformContext *xsltTransformContextPtr;
* The in-memory structure corresponding to element precomputed data,
* designed to be extended by extension implementors.
typedef struct _xsltElemPreComp xsltElemPreComp;
typedef xsltElemPreComp *xsltElemPreCompPtr;
* @ctxt: the XSLT transformation context
* @inst: the stylesheet node
* @comp: the compiled information from the stylesheet
* Signature of the function associated to elements part of the
* stylesheet language like xsl:if or xsl:apply-templates.
typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
xsltElemPreCompPtr comp);
* @ctxt: a transformation context
* @sorts: the node-set to sort
* @nbsorts: the number of sorts
* Signature of the function to use during sorting
typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
XSLT_FUNC_APPLYTEMPLATES,
XSLT_FUNC_LITERAL_RESULT_ELEMENT,
XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
* xsltElemPreCompDeallocator:
* @comp: the #xsltElemPreComp to free up
* Deallocates an #xsltElemPreComp structure.
typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
* The basic structure for compiled items of the AST of the XSLT processor.
* This structure is also intended to be extended by extension implementors.
* TODO: This is somehow not nice, since it has a "free" field, which
* derived stylesheet-structs do not have.
struct _xsltElemPreComp {
xsltElemPreCompPtr next; /* next item in the global chained
list hold by xsltStylesheet. */
xsltStyleType type; /* type of the element */
xsltTransformFunction func; /* handling function */
xmlNodePtr inst; /* the node in the stylesheet's tree
corresponding to this item */
xsltElemPreCompDeallocator free; /* the deallocator */
* The abstract basic structure for items of the XSLT processor.
* 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
* 2) compiled forms of literal result elements
* 3) compiled forms of extension elements
typedef struct _xsltStylePreComp xsltStylePreComp;