/*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 "numbersInternals.h"2425#ifdef __cplusplus26extern "C" {27#endif2829/* #define XSLT_DEBUG_PROFILE_CACHE */3031/**32* XSLT_IS_TEXT_NODE:33*34* check if the argument is a text node35*/36#define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \37(((n)->type == XML_TEXT_NODE) || \38((n)->type == XML_CDATA_SECTION_NODE)))394041/**42* XSLT_MARK_RES_TREE_FRAG:43*44* internal macro to set up tree fragments45*/46#define XSLT_MARK_RES_TREE_FRAG(n) \47(n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");4849/**50* XSLT_IS_RES_TREE_FRAG:51*52* internal macro to test tree fragments53*/54#define XSLT_IS_RES_TREE_FRAG(n) \55((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \56((n)->name != NULL) && ((n)->name[0] == ' '))5758/**59* XSLT_REFACTORED_KEYCOMP:60*61* Internal define to enable on-demand xsl:key computation.62* That's the only mode now but the define is kept for compatibility63*/64#define XSLT_REFACTORED_KEYCOMP6566/**67* XSLT_FAST_IF:68*69* Internal define to enable usage of xmlXPathCompiledEvalToBoolean()70* for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">71*/72#define XSLT_FAST_IF7374/**75* XSLT_REFACTORED:76*77* Internal define to enable the refactored parts of Libxslt.78*/79/* #define XSLT_REFACTORED */80/* ==================================================================== */8182/**83* XSLT_REFACTORED_VARS:84*85* Internal define to enable the refactored variable part of libxslt86*/87#define XSLT_REFACTORED_VARS8889#ifdef XSLT_REFACTORED9091extern const xmlChar *xsltXSLTAttrMarker;929394/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */9596/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */9798/**99* XSLT_REFACTORED_XSLT_NSCOMP100*101* Internal define to enable the pointer-comparison of102* namespaces of XSLT elements.103*/104/* #define XSLT_REFACTORED_XSLT_NSCOMP */105106#ifdef XSLT_REFACTORED_XSLT_NSCOMP107108extern const xmlChar *xsltConstNamespaceNameXSLT;109110/**111* IS_XSLT_ELEM_FAST:112*113* quick test to detect XSLT elements114*/115#define IS_XSLT_ELEM_FAST(n) \116(((n) != NULL) && ((n)->ns != NULL) && \117((n)->ns->href == xsltConstNamespaceNameXSLT))118119/**120* IS_XSLT_ATTR_FAST:121*122* quick test to detect XSLT attributes123*/124#define IS_XSLT_ATTR_FAST(a) \125(((a) != NULL) && ((a)->ns != NULL) && \126((a)->ns->href == xsltConstNamespaceNameXSLT))127128/**129* XSLT_HAS_INTERNAL_NSMAP:130*131* check for namespace mapping132*/133#define XSLT_HAS_INTERNAL_NSMAP(s) \134(((s) != NULL) && ((s)->principal) && \135((s)->principal->principalData) && \136((s)->principal->principalData->nsMap))137138/**139* XSLT_GET_INTERNAL_NSMAP:140*141* get pointer to namespace map142*/143#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)144145#else /* XSLT_REFACTORED_XSLT_NSCOMP */146147/**148* IS_XSLT_ELEM_FAST:149*150* quick check whether this is an xslt element151*/152#define IS_XSLT_ELEM_FAST(n) \153(((n) != NULL) && ((n)->ns != NULL) && \154(xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))155156/**157* IS_XSLT_ATTR_FAST:158*159* quick check for xslt namespace attribute160*/161#define IS_XSLT_ATTR_FAST(a) \162(((a) != NULL) && ((a)->ns != NULL) && \163(xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))164165166#endif /* XSLT_REFACTORED_XSLT_NSCOMP */167168169/**170* XSLT_REFACTORED_MANDATORY_VERSION:171*172* TODO: Currently disabled to surpress regression test failures, since173* the old behaviour was that a missing version attribute174* produced a only a warning and not an error, which was incerrect.175* So the regression tests need to be fixed if this is enabled.176*/177/* #define XSLT_REFACTORED_MANDATORY_VERSION */178179/**180* xsltPointerList:181*182* Pointer-list for various purposes.183*/184typedef struct _xsltPointerList xsltPointerList;185typedef xsltPointerList *xsltPointerListPtr;186struct _xsltPointerList {187void **items;188int number;189int size;190};191192#endif193194/**195* XSLT_REFACTORED_PARSING:196*197* Internal define to enable the refactored parts of Libxslt198* related to parsing.199*/200/* #define XSLT_REFACTORED_PARSING */201202/**203* XSLT_MAX_SORT:204*205* Max number of specified xsl:sort on an element.206*/207#define XSLT_MAX_SORT 15208209/**210* XSLT_PAT_NO_PRIORITY:211*212* Specific value for pattern without priority expressed.213*/214#define XSLT_PAT_NO_PRIORITY -12345789215216/**217* xsltRuntimeExtra:218*219* Extra information added to the transformation context.220*/221typedef struct _xsltRuntimeExtra xsltRuntimeExtra;222typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;223struct _xsltRuntimeExtra {224void *info; /* pointer to the extra data */225xmlFreeFunc deallocate; /* pointer to the deallocation routine */226union { /* dual-purpose field */227void *ptr; /* data not needing deallocation */228int ival; /* integer value storage */229} val;230};231232/**233* XSLT_RUNTIME_EXTRA_LST:234* @ctxt: the transformation context235* @nr: the index236*237* Macro used to access extra information stored in the context238*/239#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info240/**241* XSLT_RUNTIME_EXTRA_FREE:242* @ctxt: the transformation context243* @nr: the index244*245* Macro used to free extra information stored in the context246*/247#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate248/**249* XSLT_RUNTIME_EXTRA:250* @ctxt: the transformation context251* @nr: the index252*253* Macro used to define extra information stored in the context254*/255#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ256257/**258* xsltTemplate:259*260* The in-memory structure corresponding to an XSLT Template.261*/262typedef struct _xsltTemplate xsltTemplate;263typedef xsltTemplate *xsltTemplatePtr;264struct _xsltTemplate {265struct _xsltTemplate *next;/* chained list sorted by priority */266struct _xsltStylesheet *style;/* the containing stylesheet */267xmlChar *match; /* the matching string */268float priority; /* as given from the stylesheet, not computed */269const xmlChar *name; /* the local part of the name QName */270const xmlChar *nameURI; /* the URI part of the name QName */271const xmlChar *mode;/* the local part of the mode QName */272const xmlChar *modeURI;/* the URI part of the mode QName */273xmlNodePtr content; /* the template replacement value */274xmlNodePtr elem; /* the source element */275276/*277* TODO: @inheritedNsNr and @inheritedNs won't be used in the278* refactored code.279*/280int inheritedNsNr; /* number of inherited namespaces */281xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */282283/* Profiling information */284int nbCalls; /* the number of time the template was called */285unsigned long time; /* the time spent in this template */286void *params; /* xsl:param instructions */287288int templNr; /* Nb of templates in the stack */289int templMax; /* Size of the templtes stack */290xsltTemplatePtr *templCalledTab; /* templates called */291int *templCountTab; /* .. and how often */292293/* Conflict resolution */294int position;295};296297/**298* xsltDecimalFormat:299*300* Data structure of decimal-format.301*/302typedef struct _xsltDecimalFormat xsltDecimalFormat;303typedef xsltDecimalFormat *xsltDecimalFormatPtr;304struct _xsltDecimalFormat {305struct _xsltDecimalFormat *next; /* chained list */306xmlChar *name;307/* Used for interpretation of pattern */308xmlChar *digit;309xmlChar *patternSeparator;310/* May appear in result */311xmlChar *minusSign;312xmlChar *infinity;313xmlChar *noNumber; /* Not-a-number */314/* Used for interpretation of pattern and may appear in result */315xmlChar *decimalPoint;316xmlChar *grouping;317xmlChar *percent;318xmlChar *permille;319xmlChar *zeroDigit;320const xmlChar *nsUri;321};322323/**324* xsltDocument:325*326* Data structure associated to a parsed document.327*/328typedef struct _xsltDocument xsltDocument;329typedef xsltDocument *xsltDocumentPtr;330struct _xsltDocument {331struct _xsltDocument *next; /* documents are kept in a chained list */332int main; /* is this the main document */333xmlDocPtr doc; /* the parsed document */334void *keys; /* key tables storage */335struct _xsltDocument *includes; /* subsidiary includes */336int preproc; /* pre-processing already done */337int nbKeysComputed;338};339340/**341* xsltKeyDef:342*343* Representation of an xsl:key.344*/345typedef struct _xsltKeyDef xsltKeyDef;346typedef xsltKeyDef *xsltKeyDefPtr;347struct _xsltKeyDef {348struct _xsltKeyDef *next;349xmlNodePtr inst;350xmlChar *name;351xmlChar *nameURI;352xmlChar *match;353xmlChar *use;354xmlXPathCompExprPtr comp;355xmlXPathCompExprPtr usecomp;356xmlNsPtr *nsList; /* the namespaces in scope */357int nsNr; /* the number of namespaces in scope */358};359360/**361* xsltKeyTable:362*363* Holds the computed keys for key definitions of the same QName.364* Is owned by an xsltDocument.365*/366typedef struct _xsltKeyTable xsltKeyTable;367typedef xsltKeyTable *xsltKeyTablePtr;368struct _xsltKeyTable {369struct _xsltKeyTable *next;370xmlChar *name;371xmlChar *nameURI;372xmlHashTablePtr keys;373};374375/*376* The in-memory structure corresponding to an XSLT Stylesheet.377* NOTE: most of the content is simply linked from the doc tree378* structure, no specific allocation is made.379*/380typedef struct _xsltStylesheet xsltStylesheet;381typedef xsltStylesheet *xsltStylesheetPtr;382383typedef struct _xsltTransformContext xsltTransformContext;384typedef xsltTransformContext *xsltTransformContextPtr;385386/**387* xsltElemPreComp:388*389* The in-memory structure corresponding to element precomputed data,390* designed to be extended by extension implementors.391*/392typedef struct _xsltElemPreComp xsltElemPreComp;393typedef xsltElemPreComp *xsltElemPreCompPtr;394395/**396* xsltTransformFunction:397* @ctxt: the XSLT transformation context398* @node: the input node399* @inst: the stylesheet node400* @comp: the compiled information from the stylesheet401*402* Signature of the function associated to elements part of the403* stylesheet language like xsl:if or xsl:apply-templates.404*/405typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,406xmlNodePtr node,407xmlNodePtr inst,408xsltElemPreCompPtr comp);409410/**411* xsltSortFunc:412* @ctxt: a transformation context413* @sorts: the node-set to sort414* @nbsorts: the number of sorts415*416* Signature of the function to use during sorting417*/418typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,419int nbsorts);420421typedef enum {422XSLT_FUNC_COPY=1,423XSLT_FUNC_SORT,424XSLT_FUNC_TEXT,425XSLT_FUNC_ELEMENT,426XSLT_FUNC_ATTRIBUTE,427XSLT_FUNC_COMMENT,428XSLT_FUNC_PI,429XSLT_FUNC_COPYOF,430XSLT_FUNC_VALUEOF,431XSLT_FUNC_NUMBER,432XSLT_FUNC_APPLYIMPORTS,433XSLT_FUNC_CALLTEMPLATE,434XSLT_FUNC_APPLYTEMPLATES,435XSLT_FUNC_CHOOSE,436XSLT_FUNC_IF,437XSLT_FUNC_FOREACH,438XSLT_FUNC_DOCUMENT,439XSLT_FUNC_WITHPARAM,440XSLT_FUNC_PARAM,441XSLT_FUNC_VARIABLE,442XSLT_FUNC_WHEN,443XSLT_FUNC_EXTENSION444#ifdef XSLT_REFACTORED445,446XSLT_FUNC_OTHERWISE,447XSLT_FUNC_FALLBACK,448XSLT_FUNC_MESSAGE,449XSLT_FUNC_INCLUDE,450XSLT_FUNC_ATTRSET,451XSLT_FUNC_LITERAL_RESULT_ELEMENT,452XSLT_FUNC_UNKOWN_FORWARDS_COMPAT453#endif454} xsltStyleType;455456/**457* xsltElemPreCompDeallocator:458* @comp: the #xsltElemPreComp to free up459*460* Deallocates an #xsltElemPreComp structure.461*/462typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);463464/**465* xsltElemPreComp:466*467* The basic structure for compiled items of the AST of the XSLT processor.468* This structure is also intended to be extended by extension implementors.469* TODO: This is somehow not nice, since it has a "free" field, which470* derived stylesheet-structs do not have.471*/472struct _xsltElemPreComp {473xsltElemPreCompPtr next; /* next item in the global chained474list held by xsltStylesheet. */475xsltStyleType type; /* type of the element */476xsltTransformFunction func; /* handling function */477xmlNodePtr inst; /* the node in the stylesheet's tree478corresponding to this item */479480/* end of common part */481xsltElemPreCompDeallocator free; /* the deallocator */482};483484/**485* xsltStylePreComp:486*487* The abstract basic structure for items of the XSLT processor.488* This includes:489* 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)490* 2) compiled forms of literal result elements491* 3) compiled forms of extension elements492*/493typedef struct _xsltStylePreComp xsltStylePreComp;494typedef xsltStylePreComp *xsltStylePreCompPtr;495496#ifdef XSLT_REFACTORED497498/*499* Some pointer-list utility functions.500*/501XSLTPUBFUN xsltPointerListPtr XSLTCALL502xsltPointerListCreate (int initialSize);503XSLTPUBFUN void XSLTCALL504xsltPointerListFree (xsltPointerListPtr list);505XSLTPUBFUN void XSLTCALL506xsltPointerListClear (xsltPointerListPtr list);507XSLTPUBFUN int XSLTCALL508xsltPointerListAddSize (xsltPointerListPtr list,509void *item,510int initialSize);511512/************************************************************************513* *514* Refactored structures *515* *516************************************************************************/517518typedef struct _xsltNsListContainer xsltNsListContainer;519typedef xsltNsListContainer *xsltNsListContainerPtr;520struct _xsltNsListContainer {521xmlNsPtr *list;522int totalNumber;523int xpathNumber;524};525526/**527* XSLT_ITEM_COMPATIBILITY_FIELDS:528*529* Fields for API compatibility to the structure530* _xsltElemPreComp which is used for extension functions.531* Note that @next is used for storage; it does not reflect a next532* sibling in the tree.533* TODO: Evaluate if we really need such a compatibility.534*/535#define XSLT_ITEM_COMPATIBILITY_FIELDS \536xsltElemPreCompPtr next;\537xsltStyleType type;\538xsltTransformFunction func;\539xmlNodePtr inst;540541/**542* XSLT_ITEM_NAVIGATION_FIELDS:543*544* Currently empty.545* TODO: It is intended to hold navigational fields in the future.546*/547#define XSLT_ITEM_NAVIGATION_FIELDS548/*549xsltStylePreCompPtr parent;\550xsltStylePreCompPtr children;\551xsltStylePreCompPtr nextItem;552*/553554/**555* XSLT_ITEM_NSINSCOPE_FIELDS:556*557* The in-scope namespaces.558*/559#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;560561/**562* XSLT_ITEM_COMMON_FIELDS:563*564* Common fields used for all items.565*/566#define XSLT_ITEM_COMMON_FIELDS \567XSLT_ITEM_COMPATIBILITY_FIELDS \568XSLT_ITEM_NAVIGATION_FIELDS \569XSLT_ITEM_NSINSCOPE_FIELDS570571/**572* _xsltStylePreComp:573*574* The abstract basic structure for items of the XSLT processor.575* This includes:576* 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)577* 2) compiled forms of literal result elements578* 3) various properties for XSLT instructions (e.g. xsl:when,579* xsl:with-param)580*581* REVISIT TODO: Keep this structure equal to the fields582* defined by XSLT_ITEM_COMMON_FIELDS583*/584struct _xsltStylePreComp {585xsltElemPreCompPtr next; /* next item in the global chained586list held by xsltStylesheet */587xsltStyleType type; /* type of the item */588xsltTransformFunction func; /* handling function */589xmlNodePtr inst; /* the node in the stylesheet's tree590corresponding to this item. */591/* Currently no navigational fields. */592xsltNsListContainerPtr inScopeNs;593};594595/**596* xsltStyleBasicEmptyItem:597*598* Abstract structure only used as a short-cut for599* XSLT items with no extra fields.600* NOTE that it is intended that this structure looks the same as601* _xsltStylePreComp.602*/603typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;604typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;605606struct _xsltStyleBasicEmptyItem {607XSLT_ITEM_COMMON_FIELDS608};609610/**611* xsltStyleBasicExpressionItem:612*613* Abstract structure only used as a short-cut for614* XSLT items with just an expression.615*/616typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;617typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;618619struct _xsltStyleBasicExpressionItem {620XSLT_ITEM_COMMON_FIELDS621622const xmlChar *select; /* TODO: Change this to "expression". */623xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */624};625626/************************************************************************627* *628* XSLT-instructions/declarations *629* *630************************************************************************/631632/**633* xsltStyleItemElement:634*635* <!-- Category: instruction -->636* <xsl:element637* name = { qname }638* namespace = { uri-reference }639* use-attribute-sets = qnames>640* <!-- Content: template -->641* </xsl:element>642*/643typedef struct _xsltStyleItemElement xsltStyleItemElement;644typedef xsltStyleItemElement *xsltStyleItemElementPtr;645646struct _xsltStyleItemElement {647XSLT_ITEM_COMMON_FIELDS648649const xmlChar *use;650int has_use;651const xmlChar *name;652int has_name;653const xmlChar *ns;654const xmlChar *nsPrefix;655int has_ns;656};657658/**659* xsltStyleItemAttribute:660*661* <!-- Category: instruction -->662* <xsl:attribute663* name = { qname }664* namespace = { uri-reference }>665* <!-- Content: template -->666* </xsl:attribute>667*/668typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;669typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;670671struct _xsltStyleItemAttribute {672XSLT_ITEM_COMMON_FIELDS673const xmlChar *name;674int has_name;675const xmlChar *ns;676const xmlChar *nsPrefix;677int has_ns;678};679680/**681* xsltStyleItemText:682*683* <!-- Category: instruction -->684* <xsl:text685* disable-output-escaping = "yes" | "no">686* <!-- Content: #PCDATA -->687* </xsl:text>688*/689typedef struct _xsltStyleItemText xsltStyleItemText;690typedef xsltStyleItemText *xsltStyleItemTextPtr;691692struct _xsltStyleItemText {693XSLT_ITEM_COMMON_FIELDS694int noescape; /* text */695};696697/**698* xsltStyleItemComment:699*700* <!-- Category: instruction -->701* <xsl:comment>702* <!-- Content: template -->703* </xsl:comment>704*/705typedef xsltStyleBasicEmptyItem xsltStyleItemComment;706typedef xsltStyleItemComment *xsltStyleItemCommentPtr;707708/**709* xsltStyleItemPI:710*711* <!-- Category: instruction -->712* <xsl:processing-instruction713* name = { ncname }>714* <!-- Content: template -->715* </xsl:processing-instruction>716*/717typedef struct _xsltStyleItemPI xsltStyleItemPI;718typedef xsltStyleItemPI *xsltStyleItemPIPtr;719720struct _xsltStyleItemPI {721XSLT_ITEM_COMMON_FIELDS722const xmlChar *name;723int has_name;724};725726/**727* xsltStyleItemApplyImports:728*729* <!-- Category: instruction -->730* <xsl:apply-imports />731*/732typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;733typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;734735/**736* xsltStyleItemApplyTemplates:737*738* <!-- Category: instruction -->739* <xsl:apply-templates740* select = node-set-expression741* mode = qname>742* <!-- Content: (xsl:sort | xsl:with-param)* -->743* </xsl:apply-templates>744*/745typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;746typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;747748struct _xsltStyleItemApplyTemplates {749XSLT_ITEM_COMMON_FIELDS750751const xmlChar *mode; /* apply-templates */752const xmlChar *modeURI; /* apply-templates */753const xmlChar *select; /* sort, copy-of, value-of, apply-templates */754xmlXPathCompExprPtr comp; /* a precompiled XPath expression */755/* TODO: with-params */756};757758/**759* xsltStyleItemCallTemplate:760*761* <!-- Category: instruction -->762* <xsl:call-template763* name = qname>764* <!-- Content: xsl:with-param* -->765* </xsl:call-template>766*/767typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;768typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;769770struct _xsltStyleItemCallTemplate {771XSLT_ITEM_COMMON_FIELDS772773xsltTemplatePtr templ; /* call-template */774const xmlChar *name; /* element, attribute, pi */775int has_name; /* element, attribute, pi */776const xmlChar *ns; /* element */777int has_ns; /* element */778/* TODO: with-params */779};780781/**782* xsltStyleItemCopy:783*784* <!-- Category: instruction -->785* <xsl:copy786* use-attribute-sets = qnames>787* <!-- Content: template -->788* </xsl:copy>789*/790typedef struct _xsltStyleItemCopy xsltStyleItemCopy;791typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;792793struct _xsltStyleItemCopy {794XSLT_ITEM_COMMON_FIELDS795const xmlChar *use; /* copy, element */796int has_use; /* copy, element */797};798799/**800* xsltStyleItemIf:801*802* <!-- Category: instruction -->803* <xsl:if804* test = boolean-expression>805* <!-- Content: template -->806* </xsl:if>807*/808typedef struct _xsltStyleItemIf xsltStyleItemIf;809typedef xsltStyleItemIf *xsltStyleItemIfPtr;810811struct _xsltStyleItemIf {812XSLT_ITEM_COMMON_FIELDS813814const xmlChar *test; /* if */815xmlXPathCompExprPtr comp; /* a precompiled XPath expression */816};817818819/**820* xsltStyleItemCopyOf:821*822* <!-- Category: instruction -->823* <xsl:copy-of824* select = expression />825*/826typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;827typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;828829/**830* xsltStyleItemValueOf:831*832* <!-- Category: instruction -->833* <xsl:value-of834* select = string-expression835* disable-output-escaping = "yes" | "no" />836*/837typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;838typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;839840struct _xsltStyleItemValueOf {841XSLT_ITEM_COMMON_FIELDS842843const xmlChar *select;844xmlXPathCompExprPtr comp; /* a precompiled XPath expression */845int noescape;846};847848/**849* xsltStyleItemNumber:850*851* <!-- Category: instruction -->852* <xsl:number853* level = "single" | "multiple" | "any"854* count = pattern855* from = pattern856* value = number-expression857* format = { string }858* lang = { nmtoken }859* letter-value = { "alphabetic" | "traditional" }860* grouping-separator = { char }861* grouping-size = { number } />862*/863typedef struct _xsltStyleItemNumber xsltStyleItemNumber;864typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;865866struct _xsltStyleItemNumber {867XSLT_ITEM_COMMON_FIELDS868xsltNumberData numdata; /* number */869};870871/**872* xsltStyleItemChoose:873*874* <!-- Category: instruction -->875* <xsl:choose>876* <!-- Content: (xsl:when+, xsl:otherwise?) -->877* </xsl:choose>878*/879typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;880typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;881882/**883* xsltStyleItemFallback:884*885* <!-- Category: instruction -->886* <xsl:fallback>887* <!-- Content: template -->888* </xsl:fallback>889*/890typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;891typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;892893/**894* xsltStyleItemForEach:895*896* <!-- Category: instruction -->897* <xsl:for-each898* select = node-set-expression>899* <!-- Content: (xsl:sort*, template) -->900* </xsl:for-each>901*/902typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;903typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;904905/**906* xsltStyleItemMessage:907*908* <!-- Category: instruction -->909* <xsl:message910* terminate = "yes" | "no">911* <!-- Content: template -->912* </xsl:message>913*/914typedef struct _xsltStyleItemMessage xsltStyleItemMessage;915typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;916917struct _xsltStyleItemMessage {918XSLT_ITEM_COMMON_FIELDS919int terminate;920};921922/**923* xsltStyleItemDocument:924*925* NOTE: This is not an instruction of XSLT 1.0.926*/927typedef struct _xsltStyleItemDocument xsltStyleItemDocument;928typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;929930struct _xsltStyleItemDocument {931XSLT_ITEM_COMMON_FIELDS932int ver11; /* assigned: in xsltDocumentComp;933read: nowhere;934TODO: Check if we need. */935const xmlChar *filename; /* document URL */936int has_filename;937};938939/************************************************************************940* *941* Non-instructions (actually properties of instructions/declarations) *942* *943************************************************************************/944945/**946* xsltStyleBasicItemVariable:947*948* Basic struct for xsl:variable, xsl:param and xsl:with-param.949* It's currently important to have equal fields, since950* xsltParseStylesheetCallerParam() is used with xsl:with-param from951* the xslt side and with xsl:param from the exslt side (in952* exsltFuncFunctionFunction()).953*954* FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param955* have additional different fields.956*/957typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;958typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;959960struct _xsltStyleBasicItemVariable {961XSLT_ITEM_COMMON_FIELDS962963const xmlChar *select;964xmlXPathCompExprPtr comp;965966const xmlChar *name;967int has_name;968const xmlChar *ns;969int has_ns;970};971972/**973* xsltStyleItemVariable:974*975* <!-- Category: top-level-element -->976* <xsl:param977* name = qname978* select = expression>979* <!-- Content: template -->980* </xsl:param>981*/982typedef xsltStyleBasicItemVariable xsltStyleItemVariable;983typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;984985/**986* xsltStyleItemParam:987*988* <!-- Category: top-level-element -->989* <xsl:param990* name = qname991* select = expression>992* <!-- Content: template -->993* </xsl:param>994*/995typedef struct _xsltStyleItemParam xsltStyleItemParam;996typedef xsltStyleItemParam *xsltStyleItemParamPtr;997998struct _xsltStyleItemParam {999XSLT_ITEM_COMMON_FIELDS10001001const xmlChar *select;1002xmlXPathCompExprPtr comp;10031004const xmlChar *name;1005int has_name;1006const xmlChar *ns;1007int has_ns;1008};10091010/**1011* xsltStyleItemWithParam:1012*1013* <xsl:with-param1014* name = qname1015* select = expression>1016* <!-- Content: template -->1017* </xsl:with-param>1018*/1019typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;1020typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;10211022/**1023* xsltStyleItemSort:1024*1025* Reflects the XSLT xsl:sort item.1026* Allowed parents: xsl:apply-templates, xsl:for-each1027* <xsl:sort1028* select = string-expression1029* lang = { nmtoken }1030* data-type = { "text" | "number" | qname-but-not-ncname }1031* order = { "ascending" | "descending" }1032* case-order = { "upper-first" | "lower-first" } />1033*/1034typedef struct _xsltStyleItemSort xsltStyleItemSort;1035typedef xsltStyleItemSort *xsltStyleItemSortPtr;10361037struct _xsltStyleItemSort {1038XSLT_ITEM_COMMON_FIELDS10391040const xmlChar *stype; /* sort */1041int has_stype; /* sort */1042int number; /* sort */1043const xmlChar *order; /* sort */1044int has_order; /* sort */1045int descending; /* sort */1046const xmlChar *lang; /* sort */1047int has_lang; /* sort */1048const xmlChar *case_order; /* sort */1049int lower_first; /* sort */10501051const xmlChar *use;1052int has_use;10531054const xmlChar *select; /* sort, copy-of, value-of, apply-templates */10551056xmlXPathCompExprPtr comp; /* a precompiled XPath expression */1057};105810591060/**1061* xsltStyleItemWhen:1062*1063* <xsl:when1064* test = boolean-expression>1065* <!-- Content: template -->1066* </xsl:when>1067* Allowed parent: xsl:choose1068*/1069typedef struct _xsltStyleItemWhen xsltStyleItemWhen;1070typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;10711072struct _xsltStyleItemWhen {1073XSLT_ITEM_COMMON_FIELDS10741075const xmlChar *test;1076xmlXPathCompExprPtr comp;1077};10781079/**1080* xsltStyleItemOtherwise:1081*1082* Allowed parent: xsl:choose1083* <xsl:otherwise>1084* <!-- Content: template -->1085* </xsl:otherwise>1086*/1087typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;1088typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;10891090struct _xsltStyleItemOtherwise {1091XSLT_ITEM_COMMON_FIELDS1092};10931094typedef struct _xsltStyleItemInclude xsltStyleItemInclude;1095typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;10961097struct _xsltStyleItemInclude {1098XSLT_ITEM_COMMON_FIELDS1099xsltDocumentPtr include;1100};11011102/************************************************************************1103* *1104* XSLT elements in forwards-compatible mode *1105* *1106************************************************************************/11071108typedef struct _xsltStyleItemUknown xsltStyleItemUknown;1109typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;1110struct _xsltStyleItemUknown {1111XSLT_ITEM_COMMON_FIELDS1112};111311141115/************************************************************************1116* *1117* Extension elements *1118* *1119************************************************************************/11201121/*1122* xsltStyleItemExtElement:1123*1124* Reflects extension elements.1125*1126* NOTE: Due to the fact that the structure xsltElemPreComp is most1127* probably already heavily in use out there by users, so we cannot1128* easily change it, we'll create an intermediate structure which will1129* hold an xsltElemPreCompPtr.1130* BIG NOTE: The only problem I see here is that the user processes the1131* content of the stylesheet tree, possibly he'll lookup the node->psvi1132* fields in order to find subsequent extension functions.1133* In this case, the user's code will break, since the node->psvi1134* field will hold now the xsltStyleItemExtElementPtr and not1135* the xsltElemPreCompPtr.1136* However the place where the structure is anchored in the node-tree,1137* namely node->psvi, has beed already once been moved from node->_private1138* to node->psvi, so we have a precedent here, which, I think, should allow1139* us to change such semantics without headaches.1140*/1141typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;1142typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;1143struct _xsltStyleItemExtElement {1144XSLT_ITEM_COMMON_FIELDS1145xsltElemPreCompPtr item;1146};11471148/************************************************************************1149* *1150* Literal result elements *1151* *1152************************************************************************/11531154typedef struct _xsltEffectiveNs xsltEffectiveNs;1155typedef xsltEffectiveNs *xsltEffectiveNsPtr;1156struct _xsltEffectiveNs {1157xsltEffectiveNsPtr nextInStore; /* storage next */1158xsltEffectiveNsPtr next; /* next item in the list */1159const xmlChar *prefix;1160const xmlChar *nsName;1161/*1162* Indicates if eclared on the literal result element; dunno if really1163* needed.1164*/1165int holdByElem;1166};11671168/*1169* Info for literal result elements.1170* This will be set on the elem->psvi field and will be1171* shared by literal result elements, which have the same1172* excluded result namespaces; i.e., this *won't* be created uniquely1173* for every literal result element.1174*/1175typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;1176typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;1177struct _xsltStyleItemLRElementInfo {1178XSLT_ITEM_COMMON_FIELDS1179/*1180* @effectiveNs is the set of effective ns-nodes1181* on the literal result element, which will be added to the result1182* element if not already existing in the result tree.1183* This means that excluded namespaces (via exclude-result-prefixes,1184* extension-element-prefixes and the XSLT namespace) not added1185* to the set.1186* Namespace-aliasing was applied on the @effectiveNs.1187*/1188xsltEffectiveNsPtr effectiveNs;11891190};11911192#ifdef XSLT_REFACTORED11931194typedef struct _xsltNsAlias xsltNsAlias;1195typedef xsltNsAlias *xsltNsAliasPtr;1196struct _xsltNsAlias {1197xsltNsAliasPtr next; /* next in the list */1198xmlNsPtr literalNs;1199xmlNsPtr targetNs;1200xmlDocPtr docOfTargetNs;1201};1202#endif12031204#ifdef XSLT_REFACTORED_XSLT_NSCOMP12051206typedef struct _xsltNsMap xsltNsMap;1207typedef xsltNsMap *xsltNsMapPtr;1208struct _xsltNsMap {1209xsltNsMapPtr next; /* next in the list */1210xmlDocPtr doc;1211xmlNodePtr elem; /* the element holding the ns-decl */1212xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */1213const xmlChar *origNsName; /* the original XML namespace name */1214const xmlChar *newNsName; /* the mapped XML namespace name */1215};1216#endif12171218/************************************************************************1219* *1220* Compile-time structures for *internal* use only *1221* *1222************************************************************************/12231224typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;1225typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;12261227typedef struct _xsltNsList xsltNsList;1228typedef xsltNsList *xsltNsListPtr;1229struct _xsltNsList {1230xsltNsListPtr next; /* next in the list */1231xmlNsPtr ns;1232};12331234/*1235* xsltVarInfo:1236*1237* Used at compilation time for parameters and variables.1238*/1239typedef struct _xsltVarInfo xsltVarInfo;1240typedef xsltVarInfo *xsltVarInfoPtr;1241struct _xsltVarInfo {1242xsltVarInfoPtr next; /* next in the list */1243xsltVarInfoPtr prev;1244int depth; /* the depth in the tree */1245const xmlChar *name;1246const xmlChar *nsName;1247};12481249/**1250* xsltCompilerNodeInfo:1251*1252* Per-node information during compile-time.1253*/1254typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;1255typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;1256struct _xsltCompilerNodeInfo {1257xsltCompilerNodeInfoPtr next;1258xsltCompilerNodeInfoPtr prev;1259xmlNodePtr node;1260int depth;1261xsltTemplatePtr templ; /* The owning template */1262int category; /* XSLT element, LR-element or1263extension element */1264xsltStyleType type;1265xsltElemPreCompPtr item; /* The compiled information */1266/* The current in-scope namespaces */1267xsltNsListContainerPtr inScopeNs;1268/* The current excluded result namespaces */1269xsltPointerListPtr exclResultNs;1270/* The current extension instruction namespaces */1271xsltPointerListPtr extElemNs;12721273/* The current info for literal result elements. */1274xsltStyleItemLRElementInfoPtr litResElemInfo;1275/*1276* Set to 1 if in-scope namespaces changed,1277* or excluded result namespaces changed,1278* or extension element namespaces changed.1279* This will trigger creation of new infos1280* for literal result elements.1281*/1282int nsChanged;1283int preserveWhitespace;1284int stripWhitespace;1285int isRoot; /* whether this is the stylesheet's root node */1286int forwardsCompat; /* whether forwards-compatible mode is enabled */1287/* whether the content of an extension element was processed */1288int extContentHandled;1289/* the type of the current child */1290xsltStyleType curChildType;1291};12921293/**1294* XSLT_CCTXT:1295*1296* get pointer to compiler context1297*/1298#define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)12991300typedef enum {1301XSLT_ERROR_SEVERITY_ERROR = 0,1302XSLT_ERROR_SEVERITY_WARNING1303} xsltErrorSeverityType;13041305typedef struct _xsltCompilerCtxt xsltCompilerCtxt;1306typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;1307struct _xsltCompilerCtxt {1308void *errorCtxt; /* user specific error context */1309/*1310* used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */1311xsltErrorSeverityType errSeverity;1312int warnings; /* TODO: number of warnings found at1313compilation */1314int errors; /* TODO: number of errors found at1315compilation */1316xmlDictPtr dict;1317xsltStylesheetPtr style;1318int simplified; /* whether this is a simplified stylesheet */1319/* TODO: structured/unstructured error contexts. */1320int depth; /* Current depth of processing */13211322xsltCompilerNodeInfoPtr inode;1323xsltCompilerNodeInfoPtr inodeList;1324xsltCompilerNodeInfoPtr inodeLast;1325xsltPointerListPtr tmpList; /* Used for various purposes */1326/*1327* The XSLT version as specified by the stylesheet's root element.1328*/1329int isInclude;1330int hasForwardsCompat; /* whether forwards-compatible mode was used1331in a parsing episode */1332int maxNodeInfos; /* TEMP TODO: just for the interest */1333int maxLREs; /* TEMP TODO: just for the interest */1334/*1335* In order to keep the old behaviour, applying strict rules of1336* the spec can be turned off. This has effect only on special1337* mechanisms like whitespace-stripping in the stylesheet.1338*/1339int strict;1340xsltPrincipalStylesheetDataPtr psData;1341xsltStyleItemUknownPtr unknownItem;1342int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */1343xsltNsAliasPtr nsAliases;1344xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */1345xsltVarInfoPtr ivar; /* topmost local variable/param. */1346};13471348#else /* XSLT_REFACTORED */1349/*1350* The old structures before refactoring.1351*/13521353/**1354* _xsltStylePreComp:1355*1356* The in-memory structure corresponding to XSLT stylesheet constructs1357* precomputed data.1358*/1359struct _xsltStylePreComp {1360xsltElemPreCompPtr next; /* chained list */1361xsltStyleType type; /* type of the element */1362xsltTransformFunction func; /* handling function */1363xmlNodePtr inst; /* the instruction */13641365/*1366* Pre computed values.1367*/13681369const xmlChar *stype; /* sort */1370int has_stype; /* sort */1371int number; /* sort */1372const xmlChar *order; /* sort */1373int has_order; /* sort */1374int descending; /* sort */1375const xmlChar *lang; /* sort */1376int has_lang; /* sort */1377const xmlChar *case_order; /* sort */1378int lower_first; /* sort */13791380const xmlChar *use; /* copy, element */1381int has_use; /* copy, element */13821383int noescape; /* text */13841385const xmlChar *name; /* element, attribute, pi */1386int has_name; /* element, attribute, pi */1387const xmlChar *ns; /* element */1388int has_ns; /* element */13891390const xmlChar *mode; /* apply-templates */1391const xmlChar *modeURI; /* apply-templates */13921393const xmlChar *test; /* if */13941395xsltTemplatePtr templ; /* call-template */13961397const xmlChar *select; /* sort, copy-of, value-of, apply-templates */13981399int ver11; /* document */1400const xmlChar *filename; /* document URL */1401int has_filename; /* document */14021403xsltNumberData numdata; /* number */14041405xmlXPathCompExprPtr comp; /* a precompiled XPath expression */1406xmlNsPtr *nsList; /* the namespaces in scope */1407int nsNr; /* the number of namespaces in scope */1408};14091410#endif /* XSLT_REFACTORED */141114121413/*1414* The in-memory structure corresponding to an XSLT Variable1415* or Param.1416*/1417typedef struct _xsltStackElem xsltStackElem;1418typedef xsltStackElem *xsltStackElemPtr;1419struct _xsltStackElem {1420struct _xsltStackElem *next;/* chained list */1421xsltStylePreCompPtr comp; /* the compiled form */1422int computed; /* was the evaluation done */1423const xmlChar *name; /* the local part of the name QName */1424const xmlChar *nameURI; /* the URI part of the name QName */1425const xmlChar *select; /* the eval string */1426xmlNodePtr tree; /* the sequence constructor if no eval1427string or the location */1428xmlXPathObjectPtr value; /* The value if computed */1429xmlDocPtr fragment; /* The Result Tree Fragments (needed for XSLT 1.0)1430which are bound to the variable's lifetime. */1431int level; /* the depth in the tree;1432-1 if persistent (e.g. a given xsl:with-param) */1433xsltTransformContextPtr context; /* The transformation context; needed to cache1434the variables */1435int flags;1436};14371438#ifdef XSLT_REFACTORED14391440struct _xsltPrincipalStylesheetData {1441/*1442* Namespace dictionary for ns-prefixes and ns-names:1443* TODO: Shared between stylesheets, and XPath mechanisms.1444* Not used yet.1445*/1446xmlDictPtr namespaceDict;1447/*1448* Global list of in-scope namespaces.1449*/1450xsltPointerListPtr inScopeNamespaces;1451/*1452* Global list of information for [xsl:]excluded-result-prefixes.1453*/1454xsltPointerListPtr exclResultNamespaces;1455/*1456* Global list of information for [xsl:]extension-element-prefixes.1457*/1458xsltPointerListPtr extElemNamespaces;1459xsltEffectiveNsPtr effectiveNs;1460#ifdef XSLT_REFACTORED_XSLT_NSCOMP1461/*1462* Namespace name map to get rid of string comparison of namespace names.1463*/1464xsltNsMapPtr nsMap;1465#endif1466};146714681469#endif1470/*1471* Note that we added a @compCtxt field to anchor an stylesheet compilation1472* context, since, due to historical reasons, various compile-time function1473* take only the stylesheet as argument and not a compilation context.1474*/1475struct _xsltStylesheet {1476/*1477* The stylesheet import relation is kept as a tree.1478*/1479struct _xsltStylesheet *parent;1480struct _xsltStylesheet *next;1481struct _xsltStylesheet *imports;14821483xsltDocumentPtr docList; /* the include document list */14841485/*1486* General data on the style sheet document.1487*/1488xmlDocPtr doc; /* the parsed XML stylesheet */1489xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and1490preserve space elements */1491int stripAll; /* strip-space * (1) preserve-space * (-1) */1492xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */14931494/*1495* Global variable or parameters.1496*/1497xsltStackElemPtr variables; /* linked list of param and variables */14981499/*1500* Template descriptions.1501*/1502xsltTemplatePtr templates; /* the ordered list of templates */1503xmlHashTablePtr templatesHash; /* hash table or wherever compiled1504templates information is stored */1505struct _xsltCompMatch *rootMatch; /* template based on / */1506struct _xsltCompMatch *keyMatch; /* template based on key() */1507struct _xsltCompMatch *elemMatch; /* template based on * */1508struct _xsltCompMatch *attrMatch; /* template based on @* */1509struct _xsltCompMatch *parentMatch; /* template based on .. */1510struct _xsltCompMatch *textMatch; /* template based on text() */1511struct _xsltCompMatch *piMatch; /* template based on1512processing-instruction() */1513struct _xsltCompMatch *commentMatch; /* template based on comment() */15141515/*1516* Namespace aliases.1517* NOTE: Not used in the refactored code.1518*/1519xmlHashTablePtr nsAliases; /* the namespace alias hash tables */15201521/*1522* Attribute sets.1523*/1524xmlHashTablePtr attributeSets;/* the attribute sets hash tables */15251526/*1527* Namespaces.1528* TODO: Eliminate this.1529*/1530xmlHashTablePtr nsHash; /* the set of namespaces in use:1531ATTENTION: This is used for1532execution of XPath expressions; unfortunately1533it restricts the stylesheet to have distinct1534prefixes.1535TODO: We need to get rid of this.1536*/1537void *nsDefs; /* ATTENTION TODO: This is currently used to store1538xsltExtDefPtr (in extensions.c) and1539*not* xmlNsPtr.1540*/15411542/*1543* Key definitions.1544*/1545void *keys; /* key definitions */15461547/*1548* Output related stuff.1549*/1550xmlChar *method; /* the output method */1551xmlChar *methodURI; /* associated namespace if any */1552xmlChar *version; /* version string */1553xmlChar *encoding; /* encoding string */1554int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */15551556/*1557* Number formatting.1558*/1559xsltDecimalFormatPtr decimalFormat;1560int standalone; /* standalone = "yes" | "no" */1561xmlChar *doctypePublic; /* doctype-public string */1562xmlChar *doctypeSystem; /* doctype-system string */1563int indent; /* should output being indented */1564xmlChar *mediaType; /* media-type string */15651566/*1567* Precomputed blocks.1568*/1569xsltElemPreCompPtr preComps;/* list of precomputed blocks */1570int warnings; /* number of warnings found at compilation */1571int errors; /* number of errors found at compilation */15721573xmlChar *exclPrefix; /* last excluded prefixes */1574xmlChar **exclPrefixTab; /* array of excluded prefixes */1575int exclPrefixNr; /* number of excluded prefixes in scope */1576int exclPrefixMax; /* size of the array */15771578void *_private; /* user defined data */15791580/*1581* Extensions.1582*/1583xmlHashTablePtr extInfos; /* the extension data */1584int extrasNr; /* the number of extras required */15851586/*1587* For keeping track of nested includes1588*/1589xsltDocumentPtr includes; /* points to last nested include */15901591/*1592* dictionary: shared between stylesheet, context and documents.1593*/1594xmlDictPtr dict;1595/*1596* precompiled attribute value templates.1597*/1598void *attVTs;1599/*1600* if namespace-alias has an alias for the default stylesheet prefix1601* NOTE: Not used in the refactored code.1602*/1603const xmlChar *defaultAlias;1604/*1605* bypass pre-processing (already done) (used in imports)1606*/1607int nopreproc;1608/*1609* all document text strings were internalized1610*/1611int internalized;1612/*1613* Literal Result Element as Stylesheet c.f. section 2.31614*/1615int literal_result;1616/*1617* The principal stylesheet1618*/1619xsltStylesheetPtr principal;1620#ifdef XSLT_REFACTORED1621/*1622* Compilation context used during compile-time.1623*/1624xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */16251626xsltPrincipalStylesheetDataPtr principalData;1627#endif1628/*1629* Forwards-compatible processing1630*/1631int forwards_compatible;16321633xmlHashTablePtr namedTemplates; /* hash table of named templates */16341635xmlXPathContextPtr xpathCtxt;16361637unsigned long opLimit;1638unsigned long opCount;1639};16401641typedef struct _xsltTransformCache xsltTransformCache;1642typedef xsltTransformCache *xsltTransformCachePtr;1643struct _xsltTransformCache {1644xmlDocPtr RVT;1645int nbRVT;1646xsltStackElemPtr stackItems;1647int nbStackItems;1648#ifdef XSLT_DEBUG_PROFILE_CACHE1649int dbgCachedRVTs;1650int dbgReusedRVTs;1651int dbgCachedVars;1652int dbgReusedVars;1653#endif1654};16551656/*1657* The in-memory structure corresponding to an XSLT Transformation.1658*/1659typedef enum {1660XSLT_OUTPUT_XML = 0,1661XSLT_OUTPUT_HTML,1662XSLT_OUTPUT_TEXT1663} xsltOutputType;16641665typedef void *1666(*xsltNewLocaleFunc)(const xmlChar *lang, int lowerFirst);1667typedef void1668(*xsltFreeLocaleFunc)(void *locale);1669typedef xmlChar *1670(*xsltGenSortKeyFunc)(void *locale, const xmlChar *lang);16711672typedef enum {1673XSLT_STATE_OK = 0,1674XSLT_STATE_ERROR,1675XSLT_STATE_STOPPED1676} xsltTransformState;16771678struct _xsltTransformContext {1679xsltStylesheetPtr style; /* the stylesheet used */1680xsltOutputType type; /* the type of output */16811682xsltTemplatePtr templ; /* the current template */1683int templNr; /* Nb of templates in the stack */1684int templMax; /* Size of the templtes stack */1685xsltTemplatePtr *templTab; /* the template stack */16861687xsltStackElemPtr vars; /* the current variable list */1688int varsNr; /* Nb of variable list in the stack */1689int varsMax; /* Size of the variable list stack */1690xsltStackElemPtr *varsTab; /* the variable list stack */1691int varsBase; /* the var base for current templ */16921693/*1694* Extensions1695*/1696xmlHashTablePtr extFunctions; /* the extension functions */1697xmlHashTablePtr extElements; /* the extension elements */1698xmlHashTablePtr extInfos; /* the extension data */16991700const xmlChar *mode; /* the current mode */1701const xmlChar *modeURI; /* the current mode URI */17021703xsltDocumentPtr docList; /* the document list */17041705xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */1706xmlNodePtr node; /* the current node being processed */1707xmlNodeSetPtr nodeList; /* the current node list */1708/* xmlNodePtr current; the node */17091710xmlDocPtr output; /* the resulting document */1711xmlNodePtr insert; /* the insertion node */17121713xmlXPathContextPtr xpathCtxt; /* the XPath context */1714xsltTransformState state; /* the current state */17151716/*1717* Global variables1718*/1719xmlHashTablePtr globalVars; /* the global variables and params */17201721xmlNodePtr inst; /* the instruction in the stylesheet */17221723int xinclude; /* should XInclude be processed */17241725const char * outputFile; /* the output URI if known */17261727int profile; /* is this run profiled */1728long prof; /* the current profiled value */1729int profNr; /* Nb of templates in the stack */1730int profMax; /* Size of the templtaes stack */1731long *profTab; /* the profile template stack */17321733void *_private; /* user defined data */17341735int extrasNr; /* the number of extras used */1736int extrasMax; /* the number of extras allocated */1737xsltRuntimeExtraPtr extras; /* extra per runtime information */17381739xsltDocumentPtr styleList; /* the stylesheet docs list */1740void * sec; /* the security preferences if any */17411742xmlGenericErrorFunc error; /* a specific error handler */1743void * errctx; /* context for the error handler */17441745xsltSortFunc sortfunc; /* a ctxt specific sort routine */17461747/*1748* handling of temporary Result Value Tree1749* (XSLT 1.0 term: "Result Tree Fragment")1750*/1751xmlDocPtr tmpRVT; /* list of RVT without persistance */1752xmlDocPtr persistRVT; /* list of persistant RVTs */1753int ctxtflags; /* context processing flags */17541755/*1756* Speed optimization when coalescing text nodes1757*/1758const xmlChar *lasttext; /* last text node content */1759int lasttsize; /* last text node size */1760int lasttuse; /* last text node use */1761/*1762* Per Context Debugging1763*/1764int debugStatus; /* the context level debug status */1765unsigned long* traceCode; /* pointer to the variable holding the mask */17661767int parserOptions; /* parser options xmlParserOption */17681769/*1770* dictionary: shared between stylesheet, context and documents.1771*/1772xmlDictPtr dict;1773xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */1774/*1775* all document text strings are internalized1776*/1777int internalized;1778int nbKeys;1779int hasTemplKeyPatterns;1780xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */1781xmlNodePtr initialContextNode;1782xmlDocPtr initialContextDoc;1783xsltTransformCachePtr cache;1784void *contextVariable; /* the current variable item */1785xmlDocPtr localRVT; /* list of local tree fragments; will be freed when1786the instruction which created the fragment1787exits */1788xmlDocPtr localRVTBase; /* Obsolete */1789int keyInitLevel; /* Needed to catch recursive keys issues */1790int depth; /* Needed to catch recursions */1791int maxTemplateDepth;1792int maxTemplateVars;1793unsigned long opLimit;1794unsigned long opCount;1795int sourceDocDirty;1796unsigned long currentId; /* For generate-id() */17971798xsltNewLocaleFunc newLocale;1799xsltFreeLocaleFunc freeLocale;1800xsltGenSortKeyFunc genSortKey;1801};18021803/**1804* CHECK_STOPPED:1805*1806* Macro to check if the XSLT processing should be stopped.1807* Will return from the function.1808*/1809#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;18101811/**1812* CHECK_STOPPEDE:1813*1814* Macro to check if the XSLT processing should be stopped.1815* Will goto the error: label.1816*/1817#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;18181819/**1820* CHECK_STOPPED0:1821*1822* Macro to check if the XSLT processing should be stopped.1823* Will return from the function with a 0 value.1824*/1825#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);18261827/*1828* The macro XML_CAST_FPTR is a hack to avoid a gcc warning about1829* possible incompatibilities between function pointers and object1830* pointers. It is defined in libxml/hash.h within recent versions1831* of libxml2, but is put here for compatibility.1832*/1833#ifndef XML_CAST_FPTR1834/**1835* XML_CAST_FPTR:1836* @fptr: pointer to a function1837*1838* Macro to do a casting from an object pointer to a1839* function pointer without encountering a warning from1840* gcc1841*1842* #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))1843* This macro violated ISO C aliasing rules (gcc4 on s390 broke)1844* so it is disabled now1845*/18461847#define XML_CAST_FPTR(fptr) fptr1848#endif1849/*1850* Functions associated to the internal types1851xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,1852xmlChar *name);1853*/1854XSLTPUBFUN xsltStylesheetPtr XSLTCALL1855xsltNewStylesheet (void);1856XSLTPUBFUN xsltStylesheetPtr XSLTCALL1857xsltParseStylesheetFile (const xmlChar* filename);1858XSLTPUBFUN void XSLTCALL1859xsltFreeStylesheet (xsltStylesheetPtr style);1860XSLTPUBFUN int XSLTCALL1861xsltIsBlank (xmlChar *str);1862XSLTPUBFUN void XSLTCALL1863xsltFreeStackElemList (xsltStackElemPtr elem);1864XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL1865xsltDecimalFormatGetByName(xsltStylesheetPtr style,1866xmlChar *name);1867XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL1868xsltDecimalFormatGetByQName(xsltStylesheetPtr style,1869const xmlChar *nsUri,1870const xmlChar *name);18711872XSLTPUBFUN xsltStylesheetPtr XSLTCALL1873xsltParseStylesheetProcess(xsltStylesheetPtr ret,1874xmlDocPtr doc);1875XSLTPUBFUN void XSLTCALL1876xsltParseStylesheetOutput(xsltStylesheetPtr style,1877xmlNodePtr cur);1878XSLTPUBFUN xsltStylesheetPtr XSLTCALL1879xsltParseStylesheetDoc (xmlDocPtr doc);1880XSLTPUBFUN xsltStylesheetPtr XSLTCALL1881xsltParseStylesheetImportedDoc(xmlDocPtr doc,1882xsltStylesheetPtr style);1883XSLTPUBFUN int XSLTCALL1884xsltParseStylesheetUser(xsltStylesheetPtr style,1885xmlDocPtr doc);1886XSLTPUBFUN xsltStylesheetPtr XSLTCALL1887xsltLoadStylesheetPI (xmlDocPtr doc);1888XSLTPUBFUN void XSLTCALL1889xsltNumberFormat (xsltTransformContextPtr ctxt,1890xsltNumberDataPtr data,1891xmlNodePtr node);1892XSLTPUBFUN xmlXPathError XSLTCALL1893xsltFormatNumberConversion(xsltDecimalFormatPtr self,1894xmlChar *format,1895double number,1896xmlChar **result);18971898XSLTPUBFUN void XSLTCALL1899xsltParseTemplateContent(xsltStylesheetPtr style,1900xmlNodePtr templ);1901XSLTPUBFUN int XSLTCALL1902xsltAllocateExtra (xsltStylesheetPtr style);1903XSLTPUBFUN int XSLTCALL1904xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);1905/*1906* Extra functions for Result Value Trees1907*/1908XSLTPUBFUN xmlDocPtr XSLTCALL1909xsltCreateRVT (xsltTransformContextPtr ctxt);1910XSLTPUBFUN int XSLTCALL1911xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,1912xmlDocPtr RVT);1913XSLTPUBFUN int XSLTCALL1914xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,1915xmlDocPtr RVT);1916XSLTPUBFUN int XSLTCALL1917xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,1918xmlDocPtr RVT);1919XSLTPUBFUN int XSLTCALL1920xsltExtensionInstructionResultRegister(1921xsltTransformContextPtr ctxt,1922xmlXPathObjectPtr obj);1923XSLTPUBFUN int XSLTCALL1924xsltExtensionInstructionResultFinalize(1925xsltTransformContextPtr ctxt);1926XSLTPUBFUN int XSLTCALL1927xsltFlagRVTs(1928xsltTransformContextPtr ctxt,1929xmlXPathObjectPtr obj,1930int val);1931XSLTPUBFUN void XSLTCALL1932xsltFreeRVTs (xsltTransformContextPtr ctxt);1933XSLTPUBFUN void XSLTCALL1934xsltReleaseRVT (xsltTransformContextPtr ctxt,1935xmlDocPtr RVT);1936/*1937* Extra functions for Attribute Value Templates1938*/1939XSLTPUBFUN void XSLTCALL1940xsltCompileAttr (xsltStylesheetPtr style,1941xmlAttrPtr attr);1942XSLTPUBFUN xmlChar * XSLTCALL1943xsltEvalAVT (xsltTransformContextPtr ctxt,1944void *avt,1945xmlNodePtr node);1946XSLTPUBFUN void XSLTCALL1947xsltFreeAVTList (void *avt);19481949/*1950* Extra function for successful xsltCleanupGlobals / xsltInit sequence.1951*/19521953XSLTPUBFUN void XSLTCALL1954xsltUninit (void);19551956/************************************************************************1957* *1958* Compile-time functions for *internal* use only *1959* *1960************************************************************************/19611962#ifdef XSLT_REFACTORED1963XSLTPUBFUN void XSLTCALL1964xsltParseSequenceConstructor(1965xsltCompilerCtxtPtr cctxt,1966xmlNodePtr start);1967XSLTPUBFUN int XSLTCALL1968xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,1969xmlNodePtr elem);1970#ifdef XSLT_REFACTORED_XSLT_NSCOMP1971XSLTPUBFUN int XSLTCALL1972xsltRestoreDocumentNamespaces(1973xsltNsMapPtr ns,1974xmlDocPtr doc);1975#endif1976#endif /* XSLT_REFACTORED */19771978/************************************************************************1979* *1980* Transformation-time functions for *internal* use only *1981* *1982************************************************************************/1983XSLTPUBFUN int XSLTCALL1984xsltInitCtxtKey (xsltTransformContextPtr ctxt,1985xsltDocumentPtr doc,1986xsltKeyDefPtr keyd);1987XSLTPUBFUN int XSLTCALL1988xsltInitAllDocKeys (xsltTransformContextPtr ctxt);1989#ifdef __cplusplus1990}1991#endif19921993#endif /* __XML_XSLT_H__ */199419951996