Path: blob/master/venv/Lib/site-packages/lxml/includes/libxslt/xsltInternals.h
811 views
/*1* Summary: internal data structures, constants and functions2* Description: Internal data structures, constants and functions used3* by the XSLT engine.4* They are not part of the API or ABI, i.e. they can change5* without prior notice, use carefully.6*7* Copy: See Copyright for the status of this software.8*9* Author: Daniel Veillard10*/1112#ifndef __XML_XSLT_INTERNALS_H__13#define __XML_XSLT_INTERNALS_H__1415#include <libxml/tree.h>16#include <libxml/hash.h>17#include <libxml/xpath.h>18#include <libxml/xmlerror.h>19#include <libxml/dict.h>20#include <libxml/xmlstring.h>21#include <libxslt/xslt.h>22#include "xsltexports.h"23#include "xsltlocale.h"24#include "numbersInternals.h"2526#ifdef __cplusplus27extern "C" {28#endif2930/* #define XSLT_DEBUG_PROFILE_CACHE */3132/**33* XSLT_IS_TEXT_NODE:34*35* check if the argument is a text node36*/37#define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \38(((n)->type == XML_TEXT_NODE) || \39((n)->type == XML_CDATA_SECTION_NODE)))404142/**43* XSLT_MARK_RES_TREE_FRAG:44*45* internal macro to set up tree fragments46*/47#define XSLT_MARK_RES_TREE_FRAG(n) \48(n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");4950/**51* XSLT_IS_RES_TREE_FRAG:52*53* internal macro to test tree fragments54*/55#define XSLT_IS_RES_TREE_FRAG(n) \56((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \57((n)->name != NULL) && ((n)->name[0] == ' '))5859/**60* XSLT_REFACTORED_KEYCOMP:61*62* Internal define to enable on-demand xsl:key computation.63* That's the only mode now but the define is kept for compatibility64*/65#define XSLT_REFACTORED_KEYCOMP6667/**68* XSLT_FAST_IF:69*70* Internal define to enable usage of xmlXPathCompiledEvalToBoolean()71* for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">72*/73#define XSLT_FAST_IF7475/**76* XSLT_REFACTORED:77*78* Internal define to enable the refactored parts of Libxslt.79*/80/* #define XSLT_REFACTORED */81/* ==================================================================== */8283/**84* XSLT_REFACTORED_VARS:85*86* Internal define to enable the refactored variable part of libxslt87*/88#define XSLT_REFACTORED_VARS8990#ifdef XSLT_REFACTORED9192extern const xmlChar *xsltXSLTAttrMarker;939495/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */9697/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */9899/**100* XSLT_REFACTORED_XSLT_NSCOMP101*102* Internal define to enable the pointer-comparison of103* namespaces of XSLT elements.104*/105/* #define XSLT_REFACTORED_XSLT_NSCOMP */106107/**108* XSLT_REFACTORED_XPATHCOMP:109*110* Internal define to enable the optimization of the111* compilation of XPath expressions.112*/113#define XSLT_REFACTORED_XPATHCOMP114115#ifdef XSLT_REFACTORED_XSLT_NSCOMP116117extern const xmlChar *xsltConstNamespaceNameXSLT;118119/**120* IS_XSLT_ELEM_FAST:121*122* quick test to detect XSLT elements123*/124#define IS_XSLT_ELEM_FAST(n) \125(((n) != NULL) && ((n)->ns != NULL) && \126((n)->ns->href == xsltConstNamespaceNameXSLT))127128/**129* IS_XSLT_ATTR_FAST:130*131* quick test to detect XSLT attributes132*/133#define IS_XSLT_ATTR_FAST(a) \134(((a) != NULL) && ((a)->ns != NULL) && \135((a)->ns->href == xsltConstNamespaceNameXSLT))136137/**138* XSLT_HAS_INTERNAL_NSMAP:139*140* check for namespace mapping141*/142#define XSLT_HAS_INTERNAL_NSMAP(s) \143(((s) != NULL) && ((s)->principal) && \144((s)->principal->principalData) && \145((s)->principal->principalData->nsMap))146147/**148* XSLT_GET_INTERNAL_NSMAP:149*150* get pointer to namespace map151*/152#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)153154#else /* XSLT_REFACTORED_XSLT_NSCOMP */155156/**157* IS_XSLT_ELEM_FAST:158*159* quick check whether this is an xslt element160*/161#define IS_XSLT_ELEM_FAST(n) \162(((n) != NULL) && ((n)->ns != NULL) && \163(xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))164165/**166* IS_XSLT_ATTR_FAST:167*168* quick check for xslt namespace attribute169*/170#define IS_XSLT_ATTR_FAST(a) \171(((a) != NULL) && ((a)->ns != NULL) && \172(xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))173174175#endif /* XSLT_REFACTORED_XSLT_NSCOMP */176177178/**179* XSLT_REFACTORED_MANDATORY_VERSION:180*181* TODO: Currently disabled to surpress regression test failures, since182* the old behaviour was that a missing version attribute183* produced a only a warning and not an error, which was incerrect.184* So the regression tests need to be fixed if this is enabled.185*/186/* #define XSLT_REFACTORED_MANDATORY_VERSION */187188/**189* xsltPointerList:190*191* Pointer-list for various purposes.192*/193typedef struct _xsltPointerList xsltPointerList;194typedef xsltPointerList *xsltPointerListPtr;195struct _xsltPointerList {196void **items;197int number;198int size;199};200201#endif202203/**204* XSLT_REFACTORED_PARSING:205*206* Internal define to enable the refactored parts of Libxslt207* related to parsing.208*/209/* #define XSLT_REFACTORED_PARSING */210211/**212* XSLT_MAX_SORT:213*214* Max number of specified xsl:sort on an element.215*/216#define XSLT_MAX_SORT 15217218/**219* XSLT_PAT_NO_PRIORITY:220*221* Specific value for pattern without priority expressed.222*/223#define XSLT_PAT_NO_PRIORITY -12345789224225/**226* xsltRuntimeExtra:227*228* Extra information added to the transformation context.229*/230typedef struct _xsltRuntimeExtra xsltRuntimeExtra;231typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;232struct _xsltRuntimeExtra {233void *info; /* pointer to the extra data */234xmlFreeFunc deallocate; /* pointer to the deallocation routine */235union { /* dual-purpose field */236void *ptr; /* data not needing deallocation */237int ival; /* integer value storage */238} val;239};240241/**242* XSLT_RUNTIME_EXTRA_LST:243* @ctxt: the transformation context244* @nr: the index245*246* Macro used to access extra information stored in the context247*/248#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info249/**250* XSLT_RUNTIME_EXTRA_FREE:251* @ctxt: the transformation context252* @nr: the index253*254* Macro used to free extra information stored in the context255*/256#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate257/**258* XSLT_RUNTIME_EXTRA:259* @ctxt: the transformation context260* @nr: the index261*262* Macro used to define extra information stored in the context263*/264#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ265266/**267* xsltTemplate:268*269* The in-memory structure corresponding to an XSLT Template.270*/271typedef struct _xsltTemplate xsltTemplate;272typedef xsltTemplate *xsltTemplatePtr;273struct _xsltTemplate {274struct _xsltTemplate *next;/* chained list sorted by priority */275struct _xsltStylesheet *style;/* the containing stylesheet */276xmlChar *match; /* the matching string */277float priority; /* as given from the stylesheet, not computed */278const xmlChar *name; /* the local part of the name QName */279const xmlChar *nameURI; /* the URI part of the name QName */280const xmlChar *mode;/* the local part of the mode QName */281const xmlChar *modeURI;/* the URI part of the mode QName */282xmlNodePtr content; /* the template replacement value */283xmlNodePtr elem; /* the source element */284285/*286* TODO: @inheritedNsNr and @inheritedNs won't be used in the287* refactored code.288*/289int inheritedNsNr; /* number of inherited namespaces */290xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */291292/* Profiling informations */293int nbCalls; /* the number of time the template was called */294unsigned long time; /* the time spent in this template */295void *params; /* xsl:param instructions */296297int templNr; /* Nb of templates in the stack */298int templMax; /* Size of the templtes stack */299xsltTemplatePtr *templCalledTab; /* templates called */300int *templCountTab; /* .. and how often */301};302303/**304* xsltDecimalFormat:305*306* Data structure of decimal-format.307*/308typedef struct _xsltDecimalFormat xsltDecimalFormat;309typedef xsltDecimalFormat *xsltDecimalFormatPtr;310struct _xsltDecimalFormat {311struct _xsltDecimalFormat *next; /* chained list */312xmlChar *name;313/* Used for interpretation of pattern */314xmlChar *digit;315xmlChar *patternSeparator;316/* May appear in result */317xmlChar *minusSign;318xmlChar *infinity;319xmlChar *noNumber; /* Not-a-number */320/* Used for interpretation of pattern and may appear in result */321xmlChar *decimalPoint;322xmlChar *grouping;323xmlChar *percent;324xmlChar *permille;325xmlChar *zeroDigit;326const xmlChar *nsUri;327};328329/**330* xsltDocument:331*332* Data structure associated to a parsed document.333*/334typedef struct _xsltDocument xsltDocument;335typedef xsltDocument *xsltDocumentPtr;336struct _xsltDocument {337struct _xsltDocument *next; /* documents are kept in a chained list */338int main; /* is this the main document */339xmlDocPtr doc; /* the parsed document */340void *keys; /* key tables storage */341struct _xsltDocument *includes; /* subsidiary includes */342int preproc; /* pre-processing already done */343int nbKeysComputed;344};345346/**347* xsltKeyDef:348*349* Representation of an xsl:key.350*/351typedef struct _xsltKeyDef xsltKeyDef;352typedef xsltKeyDef *xsltKeyDefPtr;353struct _xsltKeyDef {354struct _xsltKeyDef *next;355xmlNodePtr inst;356xmlChar *name;357xmlChar *nameURI;358xmlChar *match;359xmlChar *use;360xmlXPathCompExprPtr comp;361xmlXPathCompExprPtr usecomp;362xmlNsPtr *nsList; /* the namespaces in scope */363int nsNr; /* the number of namespaces in scope */364};365366/**367* xsltKeyTable:368*369* Holds the computed keys for key definitions of the same QName.370* Is owned by an xsltDocument.371*/372typedef struct _xsltKeyTable xsltKeyTable;373typedef xsltKeyTable *xsltKeyTablePtr;374struct _xsltKeyTable {375struct _xsltKeyTable *next;376xmlChar *name;377xmlChar *nameURI;378xmlHashTablePtr keys;379};380381/*382* The in-memory structure corresponding to an XSLT Stylesheet.383* NOTE: most of the content is simply linked from the doc tree384* structure, no specific allocation is made.385*/386typedef struct _xsltStylesheet xsltStylesheet;387typedef xsltStylesheet *xsltStylesheetPtr;388389typedef struct _xsltTransformContext xsltTransformContext;390typedef xsltTransformContext *xsltTransformContextPtr;391392/**393* xsltElemPreComp:394*395* The in-memory structure corresponding to element precomputed data,396* designed to be extended by extension implementors.397*/398typedef struct _xsltElemPreComp xsltElemPreComp;399typedef xsltElemPreComp *xsltElemPreCompPtr;400401/**402* xsltTransformFunction:403* @ctxt: the XSLT transformation context404* @node: the input node405* @inst: the stylesheet node406* @comp: the compiled information from the stylesheet407*408* Signature of the function associated to elements part of the409* stylesheet language like xsl:if or xsl:apply-templates.410*/411typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,412xmlNodePtr node,413xmlNodePtr inst,414xsltElemPreCompPtr comp);415416/**417* xsltSortFunc:418* @ctxt: a transformation context419* @sorts: the node-set to sort420* @nbsorts: the number of sorts421*422* Signature of the function to use during sorting423*/424typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,425int nbsorts);426427typedef enum {428XSLT_FUNC_COPY=1,429XSLT_FUNC_SORT,430XSLT_FUNC_TEXT,431XSLT_FUNC_ELEMENT,432XSLT_FUNC_ATTRIBUTE,433XSLT_FUNC_COMMENT,434XSLT_FUNC_PI,435XSLT_FUNC_COPYOF,436XSLT_FUNC_VALUEOF,437XSLT_FUNC_NUMBER,438XSLT_FUNC_APPLYIMPORTS,439XSLT_FUNC_CALLTEMPLATE,440XSLT_FUNC_APPLYTEMPLATES,441XSLT_FUNC_CHOOSE,442XSLT_FUNC_IF,443XSLT_FUNC_FOREACH,444XSLT_FUNC_DOCUMENT,445XSLT_FUNC_WITHPARAM,446XSLT_FUNC_PARAM,447XSLT_FUNC_VARIABLE,448XSLT_FUNC_WHEN,449XSLT_FUNC_EXTENSION450#ifdef XSLT_REFACTORED451,452XSLT_FUNC_OTHERWISE,453XSLT_FUNC_FALLBACK,454XSLT_FUNC_MESSAGE,455XSLT_FUNC_INCLUDE,456XSLT_FUNC_ATTRSET,457XSLT_FUNC_LITERAL_RESULT_ELEMENT,458XSLT_FUNC_UNKOWN_FORWARDS_COMPAT459#endif460} xsltStyleType;461462/**463* xsltElemPreCompDeallocator:464* @comp: the #xsltElemPreComp to free up465*466* Deallocates an #xsltElemPreComp structure.467*/468typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);469470/**471* xsltElemPreComp:472*473* The basic structure for compiled items of the AST of the XSLT processor.474* This structure is also intended to be extended by extension implementors.475* TODO: This is somehow not nice, since it has a "free" field, which476* derived stylesheet-structs do not have.477*/478struct _xsltElemPreComp {479xsltElemPreCompPtr next; /* next item in the global chained480list hold by xsltStylesheet. */481xsltStyleType type; /* type of the element */482xsltTransformFunction func; /* handling function */483xmlNodePtr inst; /* the node in the stylesheet's tree484corresponding to this item */485486/* end of common part */487xsltElemPreCompDeallocator free; /* the deallocator */488};489490/**491* xsltStylePreComp:492*493* The abstract basic structure for items of the XSLT processor.494* This includes:495* 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)496* 2) compiled forms of literal result elements497* 3) compiled forms of extension elements498*/499typedef struct _xsltStylePreComp xsltStylePreComp;500typedef xsltStylePreComp *xsltStylePreCompPtr;501502#ifdef XSLT_REFACTORED503504/*505* Some pointer-list utility functions.506*/507XSLTPUBFUN xsltPointerListPtr XSLTCALL508xsltPointerListCreate (int initialSize);509XSLTPUBFUN void XSLTCALL510xsltPointerListFree (xsltPointerListPtr list);511XSLTPUBFUN void XSLTCALL512xsltPointerListClear (xsltPointerListPtr list);513XSLTPUBFUN int XSLTCALL514xsltPointerListAddSize (xsltPointerListPtr list,515void *item,516int initialSize);517518/************************************************************************519* *520* Refactored structures *521* *522************************************************************************/523524typedef struct _xsltNsListContainer xsltNsListContainer;525typedef xsltNsListContainer *xsltNsListContainerPtr;526struct _xsltNsListContainer {527xmlNsPtr *list;528int totalNumber;529int xpathNumber;530};531532/**533* XSLT_ITEM_COMPATIBILITY_FIELDS:534*535* Fields for API compatibility to the structure536* _xsltElemPreComp which is used for extension functions.537* Note that @next is used for storage; it does not reflect a next538* sibling in the tree.539* TODO: Evaluate if we really need such a compatibility.540*/541#define XSLT_ITEM_COMPATIBILITY_FIELDS \542xsltElemPreCompPtr next;\543xsltStyleType type;\544xsltTransformFunction func;\545xmlNodePtr inst;546547/**548* XSLT_ITEM_NAVIGATION_FIELDS:549*550* Currently empty.551* TODO: It is intended to hold navigational fields in the future.552*/553#define XSLT_ITEM_NAVIGATION_FIELDS554/*555xsltStylePreCompPtr parent;\556xsltStylePreCompPtr children;\557xsltStylePreCompPtr nextItem;558*/559560/**561* XSLT_ITEM_NSINSCOPE_FIELDS:562*563* The in-scope namespaces.564*/565#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;566567/**568* XSLT_ITEM_COMMON_FIELDS:569*570* Common fields used for all items.571*/572#define XSLT_ITEM_COMMON_FIELDS \573XSLT_ITEM_COMPATIBILITY_FIELDS \574XSLT_ITEM_NAVIGATION_FIELDS \575XSLT_ITEM_NSINSCOPE_FIELDS576577/**578* _xsltStylePreComp:579*580* The abstract basic structure for items of the XSLT processor.581* This includes:582* 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)583* 2) compiled forms of literal result elements584* 3) various properties for XSLT instructions (e.g. xsl:when,585* xsl:with-param)586*587* REVISIT TODO: Keep this structure equal to the fields588* defined by XSLT_ITEM_COMMON_FIELDS589*/590struct _xsltStylePreComp {591xsltElemPreCompPtr next; /* next item in the global chained592list hold by xsltStylesheet */593xsltStyleType type; /* type of the item */594xsltTransformFunction func; /* handling function */595xmlNodePtr inst; /* the node in the stylesheet's tree596corresponding to this item. */597/* Currently no navigational fields. */598xsltNsListContainerPtr inScopeNs;599};600601/**602* xsltStyleBasicEmptyItem:603*604* Abstract structure only used as a short-cut for605* XSLT items with no extra fields.606* NOTE that it is intended that this structure looks the same as607* _xsltStylePreComp.608*/609typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;610typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;611612struct _xsltStyleBasicEmptyItem {613XSLT_ITEM_COMMON_FIELDS614};615616/**617* xsltStyleBasicExpressionItem:618*619* Abstract structure only used as a short-cut for620* XSLT items with just an expression.621*/622typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;623typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;624625struct _xsltStyleBasicExpressionItem {626XSLT_ITEM_COMMON_FIELDS627628const xmlChar *select; /* TODO: Change this to "expression". */629xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */630};631632/************************************************************************633* *634* XSLT-instructions/declarations *635* *636************************************************************************/637638/**639* xsltStyleItemElement:640*641* <!-- Category: instruction -->642* <xsl:element643* name = { qname }644* namespace = { uri-reference }645* use-attribute-sets = qnames>646* <!-- Content: template -->647* </xsl:element>648*/649typedef struct _xsltStyleItemElement xsltStyleItemElement;650typedef xsltStyleItemElement *xsltStyleItemElementPtr;651652struct _xsltStyleItemElement {653XSLT_ITEM_COMMON_FIELDS654655const xmlChar *use;656int has_use;657const xmlChar *name;658int has_name;659const xmlChar *ns;660const xmlChar *nsPrefix;661int has_ns;662};663664/**665* xsltStyleItemAttribute:666*667* <!-- Category: instruction -->668* <xsl:attribute669* name = { qname }670* namespace = { uri-reference }>671* <!-- Content: template -->672* </xsl:attribute>673*/674typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;675typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;676677struct _xsltStyleItemAttribute {678XSLT_ITEM_COMMON_FIELDS679const xmlChar *name;680int has_name;681const xmlChar *ns;682const xmlChar *nsPrefix;683int has_ns;684};685686/**687* xsltStyleItemText:688*689* <!-- Category: instruction -->690* <xsl:text691* disable-output-escaping = "yes" | "no">692* <!-- Content: #PCDATA -->693* </xsl:text>694*/695typedef struct _xsltStyleItemText xsltStyleItemText;696typedef xsltStyleItemText *xsltStyleItemTextPtr;697698struct _xsltStyleItemText {699XSLT_ITEM_COMMON_FIELDS700int noescape; /* text */701};702703/**704* xsltStyleItemComment:705*706* <!-- Category: instruction -->707* <xsl:comment>708* <!-- Content: template -->709* </xsl:comment>710*/711typedef xsltStyleBasicEmptyItem xsltStyleItemComment;712typedef xsltStyleItemComment *xsltStyleItemCommentPtr;713714/**715* xsltStyleItemPI:716*717* <!-- Category: instruction -->718* <xsl:processing-instruction719* name = { ncname }>720* <!-- Content: template -->721* </xsl:processing-instruction>722*/723typedef struct _xsltStyleItemPI xsltStyleItemPI;724typedef xsltStyleItemPI *xsltStyleItemPIPtr;725726struct _xsltStyleItemPI {727XSLT_ITEM_COMMON_FIELDS728const xmlChar *name;729int has_name;730};731732/**733* xsltStyleItemApplyImports:734*735* <!-- Category: instruction -->736* <xsl:apply-imports />737*/738typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;739typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;740741/**742* xsltStyleItemApplyTemplates:743*744* <!-- Category: instruction -->745* <xsl:apply-templates746* select = node-set-expression747* mode = qname>748* <!-- Content: (xsl:sort | xsl:with-param)* -->749* </xsl:apply-templates>750*/751typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;752typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;753754struct _xsltStyleItemApplyTemplates {755XSLT_ITEM_COMMON_FIELDS756757const xmlChar *mode; /* apply-templates */758const xmlChar *modeURI; /* apply-templates */759const xmlChar *select; /* sort, copy-of, value-of, apply-templates */760xmlXPathCompExprPtr comp; /* a precompiled XPath expression */761/* TODO: with-params */762};763764/**765* xsltStyleItemCallTemplate:766*767* <!-- Category: instruction -->768* <xsl:call-template769* name = qname>770* <!-- Content: xsl:with-param* -->771* </xsl:call-template>772*/773typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;774typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;775776struct _xsltStyleItemCallTemplate {777XSLT_ITEM_COMMON_FIELDS778779xsltTemplatePtr templ; /* call-template */780const xmlChar *name; /* element, attribute, pi */781int has_name; /* element, attribute, pi */782const xmlChar *ns; /* element */783int has_ns; /* element */784/* TODO: with-params */785};786787/**788* xsltStyleItemCopy:789*790* <!-- Category: instruction -->791* <xsl:copy792* use-attribute-sets = qnames>793* <!-- Content: template -->794* </xsl:copy>795*/796typedef struct _xsltStyleItemCopy xsltStyleItemCopy;797typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;798799struct _xsltStyleItemCopy {800XSLT_ITEM_COMMON_FIELDS801const xmlChar *use; /* copy, element */802int has_use; /* copy, element */803};804805/**806* xsltStyleItemIf:807*808* <!-- Category: instruction -->809* <xsl:if810* test = boolean-expression>811* <!-- Content: template -->812* </xsl:if>813*/814typedef struct _xsltStyleItemIf xsltStyleItemIf;815typedef xsltStyleItemIf *xsltStyleItemIfPtr;816817struct _xsltStyleItemIf {818XSLT_ITEM_COMMON_FIELDS819820const xmlChar *test; /* if */821xmlXPathCompExprPtr comp; /* a precompiled XPath expression */822};823824825/**826* xsltStyleItemCopyOf:827*828* <!-- Category: instruction -->829* <xsl:copy-of830* select = expression />831*/832typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;833typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;834835/**836* xsltStyleItemValueOf:837*838* <!-- Category: instruction -->839* <xsl:value-of840* select = string-expression841* disable-output-escaping = "yes" | "no" />842*/843typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;844typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;845846struct _xsltStyleItemValueOf {847XSLT_ITEM_COMMON_FIELDS848849const xmlChar *select;850xmlXPathCompExprPtr comp; /* a precompiled XPath expression */851int noescape;852};853854/**855* xsltStyleItemNumber:856*857* <!-- Category: instruction -->858* <xsl:number859* level = "single" | "multiple" | "any"860* count = pattern861* from = pattern862* value = number-expression863* format = { string }864* lang = { nmtoken }865* letter-value = { "alphabetic" | "traditional" }866* grouping-separator = { char }867* grouping-size = { number } />868*/869typedef struct _xsltStyleItemNumber xsltStyleItemNumber;870typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;871872struct _xsltStyleItemNumber {873XSLT_ITEM_COMMON_FIELDS874xsltNumberData numdata; /* number */875};876877/**878* xsltStyleItemChoose:879*880* <!-- Category: instruction -->881* <xsl:choose>882* <!-- Content: (xsl:when+, xsl:otherwise?) -->883* </xsl:choose>884*/885typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;886typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;887888/**889* xsltStyleItemFallback:890*891* <!-- Category: instruction -->892* <xsl:fallback>893* <!-- Content: template -->894* </xsl:fallback>895*/896typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;897typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;898899/**900* xsltStyleItemForEach:901*902* <!-- Category: instruction -->903* <xsl:for-each904* select = node-set-expression>905* <!-- Content: (xsl:sort*, template) -->906* </xsl:for-each>907*/908typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;909typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;910911/**912* xsltStyleItemMessage:913*914* <!-- Category: instruction -->915* <xsl:message916* terminate = "yes" | "no">917* <!-- Content: template -->918* </xsl:message>919*/920typedef struct _xsltStyleItemMessage xsltStyleItemMessage;921typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;922923struct _xsltStyleItemMessage {924XSLT_ITEM_COMMON_FIELDS925int terminate;926};927928/**929* xsltStyleItemDocument:930*931* NOTE: This is not an instruction of XSLT 1.0.932*/933typedef struct _xsltStyleItemDocument xsltStyleItemDocument;934typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;935936struct _xsltStyleItemDocument {937XSLT_ITEM_COMMON_FIELDS938int ver11; /* assigned: in xsltDocumentComp;939read: nowhere;940TODO: Check if we need. */941const xmlChar *filename; /* document URL */942int has_filename;943};944945/************************************************************************946* *947* Non-instructions (actually properties of instructions/declarations) *948* *949************************************************************************/950951/**952* xsltStyleBasicItemVariable:953*954* Basic struct for xsl:variable, xsl:param and xsl:with-param.955* It's currently important to have equal fields, since956* xsltParseStylesheetCallerParam() is used with xsl:with-param from957* the xslt side and with xsl:param from the exslt side (in958* exsltFuncFunctionFunction()).959*960* FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param961* have additional different fields.962*/963typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;964typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;965966struct _xsltStyleBasicItemVariable {967XSLT_ITEM_COMMON_FIELDS968969const xmlChar *select;970xmlXPathCompExprPtr comp;971972const xmlChar *name;973int has_name;974const xmlChar *ns;975int has_ns;976};977978/**979* xsltStyleItemVariable:980*981* <!-- Category: top-level-element -->982* <xsl:param983* name = qname984* select = expression>985* <!-- Content: template -->986* </xsl:param>987*/988typedef xsltStyleBasicItemVariable xsltStyleItemVariable;989typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;990991/**992* xsltStyleItemParam:993*994* <!-- Category: top-level-element -->995* <xsl:param996* name = qname997* select = expression>998* <!-- Content: template -->999* </xsl:param>1000*/1001typedef struct _xsltStyleItemParam xsltStyleItemParam;1002typedef xsltStyleItemParam *xsltStyleItemParamPtr;10031004struct _xsltStyleItemParam {1005XSLT_ITEM_COMMON_FIELDS10061007const xmlChar *select;1008xmlXPathCompExprPtr comp;10091010const xmlChar *name;1011int has_name;1012const xmlChar *ns;1013int has_ns;1014};10151016/**1017* xsltStyleItemWithParam:1018*1019* <xsl:with-param1020* name = qname1021* select = expression>1022* <!-- Content: template -->1023* </xsl:with-param>1024*/1025typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;1026typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;10271028/**1029* xsltStyleItemSort:1030*1031* Reflects the XSLT xsl:sort item.1032* Allowed parents: xsl:apply-templates, xsl:for-each1033* <xsl:sort1034* select = string-expression1035* lang = { nmtoken }1036* data-type = { "text" | "number" | qname-but-not-ncname }1037* order = { "ascending" | "descending" }1038* case-order = { "upper-first" | "lower-first" } />1039*/1040typedef struct _xsltStyleItemSort xsltStyleItemSort;1041typedef xsltStyleItemSort *xsltStyleItemSortPtr;10421043struct _xsltStyleItemSort {1044XSLT_ITEM_COMMON_FIELDS10451046const xmlChar *stype; /* sort */1047int has_stype; /* sort */1048int number; /* sort */1049const xmlChar *order; /* sort */1050int has_order; /* sort */1051int descending; /* sort */1052const xmlChar *lang; /* sort */1053int has_lang; /* sort */1054xsltLocale locale; /* sort */1055const xmlChar *case_order; /* sort */1056int lower_first; /* sort */10571058const xmlChar *use;1059int has_use;10601061const xmlChar *select; /* sort, copy-of, value-of, apply-templates */10621063xmlXPathCompExprPtr comp; /* a precompiled XPath expression */1064};106510661067/**1068* xsltStyleItemWhen:1069*1070* <xsl:when1071* test = boolean-expression>1072* <!-- Content: template -->1073* </xsl:when>1074* Allowed parent: xsl:choose1075*/1076typedef struct _xsltStyleItemWhen xsltStyleItemWhen;1077typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;10781079struct _xsltStyleItemWhen {1080XSLT_ITEM_COMMON_FIELDS10811082const xmlChar *test;1083xmlXPathCompExprPtr comp;1084};10851086/**1087* xsltStyleItemOtherwise:1088*1089* Allowed parent: xsl:choose1090* <xsl:otherwise>1091* <!-- Content: template -->1092* </xsl:otherwise>1093*/1094typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;1095typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;10961097struct _xsltStyleItemOtherwise {1098XSLT_ITEM_COMMON_FIELDS1099};11001101typedef struct _xsltStyleItemInclude xsltStyleItemInclude;1102typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;11031104struct _xsltStyleItemInclude {1105XSLT_ITEM_COMMON_FIELDS1106xsltDocumentPtr include;1107};11081109/************************************************************************1110* *1111* XSLT elements in forwards-compatible mode *1112* *1113************************************************************************/11141115typedef struct _xsltStyleItemUknown xsltStyleItemUknown;1116typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;1117struct _xsltStyleItemUknown {1118XSLT_ITEM_COMMON_FIELDS1119};112011211122/************************************************************************1123* *1124* Extension elements *1125* *1126************************************************************************/11271128/*1129* xsltStyleItemExtElement:1130*1131* Reflects extension elements.1132*1133* NOTE: Due to the fact that the structure xsltElemPreComp is most1134* probably already heavily in use out there by users, so we cannot1135* easily change it, we'll create an intermediate structure which will1136* hold an xsltElemPreCompPtr.1137* BIG NOTE: The only problem I see here is that the user processes the1138* content of the stylesheet tree, possibly he'll lookup the node->psvi1139* fields in order to find subsequent extension functions.1140* In this case, the user's code will break, since the node->psvi1141* field will hold now the xsltStyleItemExtElementPtr and not1142* the xsltElemPreCompPtr.1143* However the place where the structure is anchored in the node-tree,1144* namely node->psvi, has beed already once been moved from node->_private1145* to node->psvi, so we have a precedent here, which, I think, should allow1146* us to change such semantics without headaches.1147*/1148typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;1149typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;1150struct _xsltStyleItemExtElement {1151XSLT_ITEM_COMMON_FIELDS1152xsltElemPreCompPtr item;1153};11541155/************************************************************************1156* *1157* Literal result elements *1158* *1159************************************************************************/11601161typedef struct _xsltEffectiveNs xsltEffectiveNs;1162typedef xsltEffectiveNs *xsltEffectiveNsPtr;1163struct _xsltEffectiveNs {1164xsltEffectiveNsPtr nextInStore; /* storage next */1165xsltEffectiveNsPtr next; /* next item in the list */1166const xmlChar *prefix;1167const xmlChar *nsName;1168/*1169* Indicates if eclared on the literal result element; dunno if really1170* needed.1171*/1172int holdByElem;1173};11741175/*1176* Info for literal result elements.1177* This will be set on the elem->psvi field and will be1178* shared by literal result elements, which have the same1179* excluded result namespaces; i.e., this *won't* be created uniquely1180* for every literal result element.1181*/1182typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;1183typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;1184struct _xsltStyleItemLRElementInfo {1185XSLT_ITEM_COMMON_FIELDS1186/*1187* @effectiveNs is the set of effective ns-nodes1188* on the literal result element, which will be added to the result1189* element if not already existing in the result tree.1190* This means that excluded namespaces (via exclude-result-prefixes,1191* extension-element-prefixes and the XSLT namespace) not added1192* to the set.1193* Namespace-aliasing was applied on the @effectiveNs.1194*/1195xsltEffectiveNsPtr effectiveNs;11961197};11981199#ifdef XSLT_REFACTORED12001201typedef struct _xsltNsAlias xsltNsAlias;1202typedef xsltNsAlias *xsltNsAliasPtr;1203struct _xsltNsAlias {1204xsltNsAliasPtr next; /* next in the list */1205xmlNsPtr literalNs;1206xmlNsPtr targetNs;1207xmlDocPtr docOfTargetNs;1208};1209#endif12101211#ifdef XSLT_REFACTORED_XSLT_NSCOMP12121213typedef struct _xsltNsMap xsltNsMap;1214typedef xsltNsMap *xsltNsMapPtr;1215struct _xsltNsMap {1216xsltNsMapPtr next; /* next in the list */1217xmlDocPtr doc;1218xmlNodePtr elem; /* the element holding the ns-decl */1219xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */1220const xmlChar *origNsName; /* the original XML namespace name */1221const xmlChar *newNsName; /* the mapped XML namespace name */1222};1223#endif12241225/************************************************************************1226* *1227* Compile-time structures for *internal* use only *1228* *1229************************************************************************/12301231typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;1232typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;12331234typedef struct _xsltNsList xsltNsList;1235typedef xsltNsList *xsltNsListPtr;1236struct _xsltNsList {1237xsltNsListPtr next; /* next in the list */1238xmlNsPtr ns;1239};12401241/*1242* xsltVarInfo:1243*1244* Used at compilation time for parameters and variables.1245*/1246typedef struct _xsltVarInfo xsltVarInfo;1247typedef xsltVarInfo *xsltVarInfoPtr;1248struct _xsltVarInfo {1249xsltVarInfoPtr next; /* next in the list */1250xsltVarInfoPtr prev;1251int depth; /* the depth in the tree */1252const xmlChar *name;1253const xmlChar *nsName;1254};12551256/**1257* xsltCompilerNodeInfo:1258*1259* Per-node information during compile-time.1260*/1261typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;1262typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;1263struct _xsltCompilerNodeInfo {1264xsltCompilerNodeInfoPtr next;1265xsltCompilerNodeInfoPtr prev;1266xmlNodePtr node;1267int depth;1268xsltTemplatePtr templ; /* The owning template */1269int category; /* XSLT element, LR-element or1270extension element */1271xsltStyleType type;1272xsltElemPreCompPtr item; /* The compiled information */1273/* The current in-scope namespaces */1274xsltNsListContainerPtr inScopeNs;1275/* The current excluded result namespaces */1276xsltPointerListPtr exclResultNs;1277/* The current extension instruction namespaces */1278xsltPointerListPtr extElemNs;12791280/* The current info for literal result elements. */1281xsltStyleItemLRElementInfoPtr litResElemInfo;1282/*1283* Set to 1 if in-scope namespaces changed,1284* or excluded result namespaces changed,1285* or extension element namespaces changed.1286* This will trigger creation of new infos1287* for literal result elements.1288*/1289int nsChanged;1290int preserveWhitespace;1291int stripWhitespace;1292int isRoot; /* whether this is the stylesheet's root node */1293int forwardsCompat; /* whether forwards-compatible mode is enabled */1294/* whether the content of an extension element was processed */1295int extContentHandled;1296/* the type of the current child */1297xsltStyleType curChildType;1298};12991300/**1301* XSLT_CCTXT:1302*1303* get pointer to compiler context1304*/1305#define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)13061307typedef enum {1308XSLT_ERROR_SEVERITY_ERROR = 0,1309XSLT_ERROR_SEVERITY_WARNING1310} xsltErrorSeverityType;13111312typedef struct _xsltCompilerCtxt xsltCompilerCtxt;1313typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;1314struct _xsltCompilerCtxt {1315void *errorCtxt; /* user specific error context */1316/*1317* used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */1318xsltErrorSeverityType errSeverity;1319int warnings; /* TODO: number of warnings found at1320compilation */1321int errors; /* TODO: number of errors found at1322compilation */1323xmlDictPtr dict;1324xsltStylesheetPtr style;1325int simplified; /* whether this is a simplified stylesheet */1326/* TODO: structured/unstructured error contexts. */1327int depth; /* Current depth of processing */13281329xsltCompilerNodeInfoPtr inode;1330xsltCompilerNodeInfoPtr inodeList;1331xsltCompilerNodeInfoPtr inodeLast;1332xsltPointerListPtr tmpList; /* Used for various purposes */1333/*1334* The XSLT version as specified by the stylesheet's root element.1335*/1336int isInclude;1337int hasForwardsCompat; /* whether forwards-compatible mode was used1338in a parsing episode */1339int maxNodeInfos; /* TEMP TODO: just for the interest */1340int maxLREs; /* TEMP TODO: just for the interest */1341/*1342* In order to keep the old behaviour, applying strict rules of1343* the spec can be turned off. This has effect only on special1344* mechanisms like whitespace-stripping in the stylesheet.1345*/1346int strict;1347xsltPrincipalStylesheetDataPtr psData;1348#ifdef XSLT_REFACTORED_XPATHCOMP1349xmlXPathContextPtr xpathCtxt;1350#endif1351xsltStyleItemUknownPtr unknownItem;1352int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */1353xsltNsAliasPtr nsAliases;1354xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */1355xsltVarInfoPtr ivar; /* topmost local variable/param. */1356};13571358#else /* XSLT_REFACTORED */1359/*1360* The old structures before refactoring.1361*/13621363/**1364* _xsltStylePreComp:1365*1366* The in-memory structure corresponding to XSLT stylesheet constructs1367* precomputed data.1368*/1369struct _xsltStylePreComp {1370xsltElemPreCompPtr next; /* chained list */1371xsltStyleType type; /* type of the element */1372xsltTransformFunction func; /* handling function */1373xmlNodePtr inst; /* the instruction */13741375/*1376* Pre computed values.1377*/13781379const xmlChar *stype; /* sort */1380int has_stype; /* sort */1381int number; /* sort */1382const xmlChar *order; /* sort */1383int has_order; /* sort */1384int descending; /* sort */1385const xmlChar *lang; /* sort */1386int has_lang; /* sort */1387xsltLocale locale; /* sort */1388const xmlChar *case_order; /* sort */1389int lower_first; /* sort */13901391const xmlChar *use; /* copy, element */1392int has_use; /* copy, element */13931394int noescape; /* text */13951396const xmlChar *name; /* element, attribute, pi */1397int has_name; /* element, attribute, pi */1398const xmlChar *ns; /* element */1399int has_ns; /* element */14001401const xmlChar *mode; /* apply-templates */1402const xmlChar *modeURI; /* apply-templates */14031404const xmlChar *test; /* if */14051406xsltTemplatePtr templ; /* call-template */14071408const xmlChar *select; /* sort, copy-of, value-of, apply-templates */14091410int ver11; /* document */1411const xmlChar *filename; /* document URL */1412int has_filename; /* document */14131414xsltNumberData numdata; /* number */14151416xmlXPathCompExprPtr comp; /* a precompiled XPath expression */1417xmlNsPtr *nsList; /* the namespaces in scope */1418int nsNr; /* the number of namespaces in scope */1419};14201421#endif /* XSLT_REFACTORED */142214231424/*1425* The in-memory structure corresponding to an XSLT Variable1426* or Param.1427*/1428typedef struct _xsltStackElem xsltStackElem;1429typedef xsltStackElem *xsltStackElemPtr;1430struct _xsltStackElem {1431struct _xsltStackElem *next;/* chained list */1432xsltStylePreCompPtr comp; /* the compiled form */1433int computed; /* was the evaluation done */1434const xmlChar *name; /* the local part of the name QName */1435const xmlChar *nameURI; /* the URI part of the name QName */1436const xmlChar *select; /* the eval string */1437xmlNodePtr tree; /* the sequence constructor if no eval1438string or the location */1439xmlXPathObjectPtr value; /* The value if computed */1440xmlDocPtr fragment; /* The Result Tree Fragments (needed for XSLT 1.0)1441which are bound to the variable's lifetime. */1442int level; /* the depth in the tree;1443-1 if persistent (e.g. a given xsl:with-param) */1444xsltTransformContextPtr context; /* The transformation context; needed to cache1445the variables */1446int flags;1447};14481449#ifdef XSLT_REFACTORED14501451struct _xsltPrincipalStylesheetData {1452/*1453* Namespace dictionary for ns-prefixes and ns-names:1454* TODO: Shared between stylesheets, and XPath mechanisms.1455* Not used yet.1456*/1457xmlDictPtr namespaceDict;1458/*1459* Global list of in-scope namespaces.1460*/1461xsltPointerListPtr inScopeNamespaces;1462/*1463* Global list of information for [xsl:]excluded-result-prefixes.1464*/1465xsltPointerListPtr exclResultNamespaces;1466/*1467* Global list of information for [xsl:]extension-element-prefixes.1468*/1469xsltPointerListPtr extElemNamespaces;1470xsltEffectiveNsPtr effectiveNs;1471#ifdef XSLT_REFACTORED_XSLT_NSCOMP1472/*1473* Namespace name map to get rid of string comparison of namespace names.1474*/1475xsltNsMapPtr nsMap;1476#endif1477};147814791480#endif1481/*1482* Note that we added a @compCtxt field to anchor an stylesheet compilation1483* context, since, due to historical reasons, various compile-time function1484* take only the stylesheet as argument and not a compilation context.1485*/1486struct _xsltStylesheet {1487/*1488* The stylesheet import relation is kept as a tree.1489*/1490struct _xsltStylesheet *parent;1491struct _xsltStylesheet *next;1492struct _xsltStylesheet *imports;14931494xsltDocumentPtr docList; /* the include document list */14951496/*1497* General data on the style sheet document.1498*/1499xmlDocPtr doc; /* the parsed XML stylesheet */1500xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and1501preserve space elements */1502int stripAll; /* strip-space * (1) preserve-space * (-1) */1503xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */15041505/*1506* Global variable or parameters.1507*/1508xsltStackElemPtr variables; /* linked list of param and variables */15091510/*1511* Template descriptions.1512*/1513xsltTemplatePtr templates; /* the ordered list of templates */1514void *templatesHash; /* hash table or wherever compiled templates1515informations are stored */1516void *rootMatch; /* template based on / */1517void *keyMatch; /* template based on key() */1518void *elemMatch; /* template based on * */1519void *attrMatch; /* template based on @* */1520void *parentMatch; /* template based on .. */1521void *textMatch; /* template based on text() */1522void *piMatch; /* template based on processing-instruction() */1523void *commentMatch; /* template based on comment() */15241525/*1526* Namespace aliases.1527* NOTE: Not used in the refactored code.1528*/1529xmlHashTablePtr nsAliases; /* the namespace alias hash tables */15301531/*1532* Attribute sets.1533*/1534xmlHashTablePtr attributeSets;/* the attribute sets hash tables */15351536/*1537* Namespaces.1538* TODO: Eliminate this.1539*/1540xmlHashTablePtr nsHash; /* the set of namespaces in use:1541ATTENTION: This is used for1542execution of XPath expressions; unfortunately1543it restricts the stylesheet to have distinct1544prefixes.1545TODO: We need to get rid of this.1546*/1547void *nsDefs; /* ATTENTION TODO: This is currently used to store1548xsltExtDefPtr (in extensions.c) and1549*not* xmlNsPtr.1550*/15511552/*1553* Key definitions.1554*/1555void *keys; /* key definitions */15561557/*1558* Output related stuff.1559*/1560xmlChar *method; /* the output method */1561xmlChar *methodURI; /* associated namespace if any */1562xmlChar *version; /* version string */1563xmlChar *encoding; /* encoding string */1564int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */15651566/*1567* Number formatting.1568*/1569xsltDecimalFormatPtr decimalFormat;1570int standalone; /* standalone = "yes" | "no" */1571xmlChar *doctypePublic; /* doctype-public string */1572xmlChar *doctypeSystem; /* doctype-system string */1573int indent; /* should output being indented */1574xmlChar *mediaType; /* media-type string */15751576/*1577* Precomputed blocks.1578*/1579xsltElemPreCompPtr preComps;/* list of precomputed blocks */1580int warnings; /* number of warnings found at compilation */1581int errors; /* number of errors found at compilation */15821583xmlChar *exclPrefix; /* last excluded prefixes */1584xmlChar **exclPrefixTab; /* array of excluded prefixes */1585int exclPrefixNr; /* number of excluded prefixes in scope */1586int exclPrefixMax; /* size of the array */15871588void *_private; /* user defined data */15891590/*1591* Extensions.1592*/1593xmlHashTablePtr extInfos; /* the extension data */1594int extrasNr; /* the number of extras required */15951596/*1597* For keeping track of nested includes1598*/1599xsltDocumentPtr includes; /* points to last nested include */16001601/*1602* dictionary: shared between stylesheet, context and documents.1603*/1604xmlDictPtr dict;1605/*1606* precompiled attribute value templates.1607*/1608void *attVTs;1609/*1610* if namespace-alias has an alias for the default stylesheet prefix1611* NOTE: Not used in the refactored code.1612*/1613const xmlChar *defaultAlias;1614/*1615* bypass pre-processing (already done) (used in imports)1616*/1617int nopreproc;1618/*1619* all document text strings were internalized1620*/1621int internalized;1622/*1623* Literal Result Element as Stylesheet c.f. section 2.31624*/1625int literal_result;1626/*1627* The principal stylesheet1628*/1629xsltStylesheetPtr principal;1630#ifdef XSLT_REFACTORED1631/*1632* Compilation context used during compile-time.1633*/1634xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */16351636xsltPrincipalStylesheetDataPtr principalData;1637#endif1638/*1639* Forwards-compatible processing1640*/1641int forwards_compatible;16421643xmlHashTablePtr namedTemplates; /* hash table of named templates */1644};16451646typedef struct _xsltTransformCache xsltTransformCache;1647typedef xsltTransformCache *xsltTransformCachePtr;1648struct _xsltTransformCache {1649xmlDocPtr RVT;1650int nbRVT;1651xsltStackElemPtr stackItems;1652int nbStackItems;1653#ifdef XSLT_DEBUG_PROFILE_CACHE1654int dbgCachedRVTs;1655int dbgReusedRVTs;1656int dbgCachedVars;1657int dbgReusedVars;1658#endif1659};16601661/*1662* The in-memory structure corresponding to an XSLT Transformation.1663*/1664typedef enum {1665XSLT_OUTPUT_XML = 0,1666XSLT_OUTPUT_HTML,1667XSLT_OUTPUT_TEXT1668} xsltOutputType;16691670typedef enum {1671XSLT_STATE_OK = 0,1672XSLT_STATE_ERROR,1673XSLT_STATE_STOPPED1674} xsltTransformState;16751676struct _xsltTransformContext {1677xsltStylesheetPtr style; /* the stylesheet used */1678xsltOutputType type; /* the type of output */16791680xsltTemplatePtr templ; /* the current template */1681int templNr; /* Nb of templates in the stack */1682int templMax; /* Size of the templtes stack */1683xsltTemplatePtr *templTab; /* the template stack */16841685xsltStackElemPtr vars; /* the current variable list */1686int varsNr; /* Nb of variable list in the stack */1687int varsMax; /* Size of the variable list stack */1688xsltStackElemPtr *varsTab; /* the variable list stack */1689int varsBase; /* the var base for current templ */16901691/*1692* Extensions1693*/1694xmlHashTablePtr extFunctions; /* the extension functions */1695xmlHashTablePtr extElements; /* the extension elements */1696xmlHashTablePtr extInfos; /* the extension data */16971698const xmlChar *mode; /* the current mode */1699const xmlChar *modeURI; /* the current mode URI */17001701xsltDocumentPtr docList; /* the document list */17021703xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */1704xmlNodePtr node; /* the current node being processed */1705xmlNodeSetPtr nodeList; /* the current node list */1706/* xmlNodePtr current; the node */17071708xmlDocPtr output; /* the resulting document */1709xmlNodePtr insert; /* the insertion node */17101711xmlXPathContextPtr xpathCtxt; /* the XPath context */1712xsltTransformState state; /* the current state */17131714/*1715* Global variables1716*/1717xmlHashTablePtr globalVars; /* the global variables and params */17181719xmlNodePtr inst; /* the instruction in the stylesheet */17201721int xinclude; /* should XInclude be processed */17221723const char * outputFile; /* the output URI if known */17241725int profile; /* is this run profiled */1726long prof; /* the current profiled value */1727int profNr; /* Nb of templates in the stack */1728int profMax; /* Size of the templtaes stack */1729long *profTab; /* the profile template stack */17301731void *_private; /* user defined data */17321733int extrasNr; /* the number of extras used */1734int extrasMax; /* the number of extras allocated */1735xsltRuntimeExtraPtr extras; /* extra per runtime informations */17361737xsltDocumentPtr styleList; /* the stylesheet docs list */1738void * sec; /* the security preferences if any */17391740xmlGenericErrorFunc error; /* a specific error handler */1741void * errctx; /* context for the error handler */17421743xsltSortFunc sortfunc; /* a ctxt specific sort routine */17441745/*1746* handling of temporary Result Value Tree1747* (XSLT 1.0 term: "Result Tree Fragment")1748*/1749xmlDocPtr tmpRVT; /* list of RVT without persistance */1750xmlDocPtr persistRVT; /* list of persistant RVTs */1751int ctxtflags; /* context processing flags */17521753/*1754* Speed optimization when coalescing text nodes1755*/1756const xmlChar *lasttext; /* last text node content */1757int lasttsize; /* last text node size */1758int lasttuse; /* last text node use */1759/*1760* Per Context Debugging1761*/1762int debugStatus; /* the context level debug status */1763unsigned long* traceCode; /* pointer to the variable holding the mask */17641765int parserOptions; /* parser options xmlParserOption */17661767/*1768* dictionary: shared between stylesheet, context and documents.1769*/1770xmlDictPtr dict;1771xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */1772/*1773* all document text strings are internalized1774*/1775int internalized;1776int nbKeys;1777int hasTemplKeyPatterns;1778xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */1779xmlNodePtr initialContextNode;1780xmlDocPtr initialContextDoc;1781xsltTransformCachePtr cache;1782void *contextVariable; /* the current variable item */1783xmlDocPtr localRVT; /* list of local tree fragments; will be freed when1784the instruction which created the fragment1785exits */1786xmlDocPtr localRVTBase; /* Obsolete */1787int keyInitLevel; /* Needed to catch recursive keys issues */1788int depth; /* Needed to catch recursions */1789int maxTemplateDepth;1790int maxTemplateVars;1791};17921793/**1794* CHECK_STOPPED:1795*1796* Macro to check if the XSLT processing should be stopped.1797* Will return from the function.1798*/1799#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;18001801/**1802* CHECK_STOPPEDE:1803*1804* Macro to check if the XSLT processing should be stopped.1805* Will goto the error: label.1806*/1807#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;18081809/**1810* CHECK_STOPPED0:1811*1812* Macro to check if the XSLT processing should be stopped.1813* Will return from the function with a 0 value.1814*/1815#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);18161817/*1818* The macro XML_CAST_FPTR is a hack to avoid a gcc warning about1819* possible incompatibilities between function pointers and object1820* pointers. It is defined in libxml/hash.h within recent versions1821* of libxml2, but is put here for compatibility.1822*/1823#ifndef XML_CAST_FPTR1824/**1825* XML_CAST_FPTR:1826* @fptr: pointer to a function1827*1828* Macro to do a casting from an object pointer to a1829* function pointer without encountering a warning from1830* gcc1831*1832* #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))1833* This macro violated ISO C aliasing rules (gcc4 on s390 broke)1834* so it is disabled now1835*/18361837#define XML_CAST_FPTR(fptr) fptr1838#endif1839/*1840* Functions associated to the internal types1841xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,1842xmlChar *name);1843*/1844XSLTPUBFUN xsltStylesheetPtr XSLTCALL1845xsltNewStylesheet (void);1846XSLTPUBFUN xsltStylesheetPtr XSLTCALL1847xsltParseStylesheetFile (const xmlChar* filename);1848XSLTPUBFUN void XSLTCALL1849xsltFreeStylesheet (xsltStylesheetPtr style);1850XSLTPUBFUN int XSLTCALL1851xsltIsBlank (xmlChar *str);1852XSLTPUBFUN void XSLTCALL1853xsltFreeStackElemList (xsltStackElemPtr elem);1854XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL1855xsltDecimalFormatGetByName(xsltStylesheetPtr style,1856xmlChar *name);1857XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL1858xsltDecimalFormatGetByQName(xsltStylesheetPtr style,1859const xmlChar *nsUri,1860const xmlChar *name);18611862XSLTPUBFUN xsltStylesheetPtr XSLTCALL1863xsltParseStylesheetProcess(xsltStylesheetPtr ret,1864xmlDocPtr doc);1865XSLTPUBFUN void XSLTCALL1866xsltParseStylesheetOutput(xsltStylesheetPtr style,1867xmlNodePtr cur);1868XSLTPUBFUN xsltStylesheetPtr XSLTCALL1869xsltParseStylesheetDoc (xmlDocPtr doc);1870XSLTPUBFUN xsltStylesheetPtr XSLTCALL1871xsltParseStylesheetImportedDoc(xmlDocPtr doc,1872xsltStylesheetPtr style);1873XSLTPUBFUN xsltStylesheetPtr XSLTCALL1874xsltLoadStylesheetPI (xmlDocPtr doc);1875XSLTPUBFUN void XSLTCALL1876xsltNumberFormat (xsltTransformContextPtr ctxt,1877xsltNumberDataPtr data,1878xmlNodePtr node);1879XSLTPUBFUN xmlXPathError XSLTCALL1880xsltFormatNumberConversion(xsltDecimalFormatPtr self,1881xmlChar *format,1882double number,1883xmlChar **result);18841885XSLTPUBFUN void XSLTCALL1886xsltParseTemplateContent(xsltStylesheetPtr style,1887xmlNodePtr templ);1888XSLTPUBFUN int XSLTCALL1889xsltAllocateExtra (xsltStylesheetPtr style);1890XSLTPUBFUN int XSLTCALL1891xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);1892/*1893* Extra functions for Result Value Trees1894*/1895XSLTPUBFUN xmlDocPtr XSLTCALL1896xsltCreateRVT (xsltTransformContextPtr ctxt);1897XSLTPUBFUN int XSLTCALL1898xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,1899xmlDocPtr RVT);1900XSLTPUBFUN int XSLTCALL1901xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,1902xmlDocPtr RVT);1903XSLTPUBFUN int XSLTCALL1904xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,1905xmlDocPtr RVT);1906XSLTPUBFUN int XSLTCALL1907xsltExtensionInstructionResultRegister(1908xsltTransformContextPtr ctxt,1909xmlXPathObjectPtr obj);1910XSLTPUBFUN int XSLTCALL1911xsltExtensionInstructionResultFinalize(1912xsltTransformContextPtr ctxt);1913XSLTPUBFUN int XSLTCALL1914xsltFlagRVTs(1915xsltTransformContextPtr ctxt,1916xmlXPathObjectPtr obj,1917void *val);1918XSLTPUBFUN void XSLTCALL1919xsltFreeRVTs (xsltTransformContextPtr ctxt);1920XSLTPUBFUN void XSLTCALL1921xsltReleaseRVT (xsltTransformContextPtr ctxt,1922xmlDocPtr RVT);1923/*1924* Extra functions for Attribute Value Templates1925*/1926XSLTPUBFUN void XSLTCALL1927xsltCompileAttr (xsltStylesheetPtr style,1928xmlAttrPtr attr);1929XSLTPUBFUN xmlChar * XSLTCALL1930xsltEvalAVT (xsltTransformContextPtr ctxt,1931void *avt,1932xmlNodePtr node);1933XSLTPUBFUN void XSLTCALL1934xsltFreeAVTList (void *avt);19351936/*1937* Extra function for successful xsltCleanupGlobals / xsltInit sequence.1938*/19391940XSLTPUBFUN void XSLTCALL1941xsltUninit (void);19421943/************************************************************************1944* *1945* Compile-time functions for *internal* use only *1946* *1947************************************************************************/19481949#ifdef XSLT_REFACTORED1950XSLTPUBFUN void XSLTCALL1951xsltParseSequenceConstructor(1952xsltCompilerCtxtPtr cctxt,1953xmlNodePtr start);1954XSLTPUBFUN int XSLTCALL1955xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,1956xmlNodePtr elem);1957#ifdef XSLT_REFACTORED_XSLT_NSCOMP1958XSLTPUBFUN int XSLTCALL1959xsltRestoreDocumentNamespaces(1960xsltNsMapPtr ns,1961xmlDocPtr doc);1962#endif1963#endif /* XSLT_REFACTORED */19641965/************************************************************************1966* *1967* Transformation-time functions for *internal* use only *1968* *1969************************************************************************/1970XSLTPUBFUN int XSLTCALL1971xsltInitCtxtKey (xsltTransformContextPtr ctxt,1972xsltDocumentPtr doc,1973xsltKeyDefPtr keyd);1974XSLTPUBFUN int XSLTCALL1975xsltInitAllDocKeys (xsltTransformContextPtr ctxt);1976#ifdef __cplusplus1977}1978#endif19791980#endif /* __XML_XSLT_H__ */1981198219831984