codekingpro/portable-devtools
114k
1/*2 * Summary: internal data structures, constants and functions3 * Description: Internal data structures, constants and functions used4 * by the XSLT engine.5 * They are not part of the API or ABI, i.e. they can change6 * without prior notice, use carefully.7 *8 * Copy: See Copyright for the status of this software.9 *10 * Author: Daniel Veillard11 */12 13#ifndef __XML_XSLT_INTERNALS_H__14#define __XML_XSLT_INTERNALS_H__15 16#include <libxml/tree.h>17#include <libxml/hash.h>18#include <libxml/xpath.h>19#include <libxml/xmlerror.h>20#include <libxml/dict.h>21#include <libxml/xmlstring.h>22#include <libxslt/xslt.h>23#include "xsltexports.h"24#include "numbersInternals.h"25 26#ifdef __cplusplus27extern "C" {28#endif29 30/* #define XSLT_DEBUG_PROFILE_CACHE */31 32/**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)))40 41 42/**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");49 50/**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] == ' '))58 59/**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_KEYCOMP66 67/**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_IF74 75/**76 * XSLT_REFACTORED:77 *78 * Internal define to enable the refactored parts of Libxslt.79 */80/* #define XSLT_REFACTORED */81/* ==================================================================== */82 83/**84 * XSLT_REFACTORED_VARS:85 *86 * Internal define to enable the refactored variable part of libxslt87 */88#define XSLT_REFACTORED_VARS89 90#ifdef XSLT_REFACTORED91 92extern const xmlChar *xsltXSLTAttrMarker;93 94 95/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */96 97/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */98 99/**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 */106 107#ifdef XSLT_REFACTORED_XSLT_NSCOMP108 109extern const xmlChar *xsltConstNamespaceNameXSLT;110 111/**112 * IS_XSLT_ELEM_FAST:113 *114 * quick test to detect XSLT elements115 */116#define IS_XSLT_ELEM_FAST(n) \117 (((n) != NULL) && ((n)->ns != NULL) && \118 ((n)->ns->href == xsltConstNamespaceNameXSLT))119 120/**121 * IS_XSLT_ATTR_FAST:122 *123 * quick test to detect XSLT attributes124 */125#define IS_XSLT_ATTR_FAST(a) \126 (((a) != NULL) && ((a)->ns != NULL) && \127 ((a)->ns->href == xsltConstNamespaceNameXSLT))128 129/**130 * XSLT_HAS_INTERNAL_NSMAP:131 *132 * check for namespace mapping133 */134#define XSLT_HAS_INTERNAL_NSMAP(s) \135 (((s) != NULL) && ((s)->principal) && \136 ((s)->principal->principalData) && \137 ((s)->principal->principalData->nsMap))138 139/**140 * XSLT_GET_INTERNAL_NSMAP:141 *142 * get pointer to namespace map143 */144#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)145 146#else /* XSLT_REFACTORED_XSLT_NSCOMP */147 148/**149 * IS_XSLT_ELEM_FAST:150 *151 * quick check whether this is an xslt element152 */153#define IS_XSLT_ELEM_FAST(n) \154 (((n) != NULL) && ((n)->ns != NULL) && \155 (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))156 157/**158 * IS_XSLT_ATTR_FAST:159 *160 * quick check for xslt namespace attribute161 */162#define IS_XSLT_ATTR_FAST(a) \163 (((a) != NULL) && ((a)->ns != NULL) && \164 (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))165 166 167#endif /* XSLT_REFACTORED_XSLT_NSCOMP */168 169 170/**171 * XSLT_REFACTORED_MANDATORY_VERSION:172 *173 * TODO: Currently disabled to surpress regression test failures, since174 * the old behaviour was that a missing version attribute175 * produced a only a warning and not an error, which was incerrect.176 * So the regression tests need to be fixed if this is enabled.177 */178/* #define XSLT_REFACTORED_MANDATORY_VERSION */179 180/**181 * xsltPointerList:182 *183 * Pointer-list for various purposes.184 */185typedef struct _xsltPointerList xsltPointerList;186typedef xsltPointerList *xsltPointerListPtr;187struct _xsltPointerList {188 void **items;189 int number;190 int size;191};192 193#endif194 195/**196 * XSLT_REFACTORED_PARSING:197 *198 * Internal define to enable the refactored parts of Libxslt199 * related to parsing.200 */201/* #define XSLT_REFACTORED_PARSING */202 203/**204 * XSLT_MAX_SORT:205 *206 * Max number of specified xsl:sort on an element.207 */208#define XSLT_MAX_SORT 15209 210/**211 * XSLT_PAT_NO_PRIORITY:212 *213 * Specific value for pattern without priority expressed.214 */215#define XSLT_PAT_NO_PRIORITY -12345789216 217/**218 * xsltRuntimeExtra:219 *220 * Extra information added to the transformation context.221 */222typedef struct _xsltRuntimeExtra xsltRuntimeExtra;223typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;224struct _xsltRuntimeExtra {225 void *info; /* pointer to the extra data */226 xmlFreeFunc deallocate; /* pointer to the deallocation routine */227 union { /* dual-purpose field */228 void *ptr; /* data not needing deallocation */229 int ival; /* integer value storage */230 } val;231};232 233/**234 * XSLT_RUNTIME_EXTRA_LST:235 * @ctxt: the transformation context236 * @nr: the index237 *238 * Macro used to access extra information stored in the context239 */240#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info241/**242 * XSLT_RUNTIME_EXTRA_FREE:243 * @ctxt: the transformation context244 * @nr: the index245 *246 * Macro used to free extra information stored in the context247 */248#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate249/**250 * XSLT_RUNTIME_EXTRA:251 * @ctxt: the transformation context252 * @nr: the index253 *254 * Macro used to define extra information stored in the context255 */256#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ257 258/**259 * xsltTemplate:260 *261 * The in-memory structure corresponding to an XSLT Template.262 */263typedef struct _xsltTemplate xsltTemplate;264typedef xsltTemplate *xsltTemplatePtr;265struct _xsltTemplate {266 struct _xsltTemplate *next;/* chained list sorted by priority */267 struct _xsltStylesheet *style;/* the containing stylesheet */268 xmlChar *match; /* the matching string */269 float priority; /* as given from the stylesheet, not computed */270 const xmlChar *name; /* the local part of the name QName */271 const xmlChar *nameURI; /* the URI part of the name QName */272 const xmlChar *mode;/* the local part of the mode QName */273 const xmlChar *modeURI;/* the URI part of the mode QName */274 xmlNodePtr content; /* the template replacement value */275 xmlNodePtr elem; /* the source element */276 277 /*278 * TODO: @inheritedNsNr and @inheritedNs won't be used in the279 * refactored code.280 */281 int inheritedNsNr; /* number of inherited namespaces */282 xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */283 284 /* Profiling information */285 int nbCalls; /* the number of time the template was called */286 unsigned long time; /* the time spent in this template */287 void *params; /* xsl:param instructions */288 289 int templNr; /* Nb of templates in the stack */290 int templMax; /* Size of the templtes stack */291 xsltTemplatePtr *templCalledTab; /* templates called */292 int *templCountTab; /* .. and how often */293 294 /* Conflict resolution */295 int position;296};297 298/**299 * xsltDecimalFormat:300 *301 * Data structure of decimal-format.302 */303typedef struct _xsltDecimalFormat xsltDecimalFormat;304typedef xsltDecimalFormat *xsltDecimalFormatPtr;305struct _xsltDecimalFormat {306 struct _xsltDecimalFormat *next; /* chained list */307 xmlChar *name;308 /* Used for interpretation of pattern */309 xmlChar *digit;310 xmlChar *patternSeparator;311 /* May appear in result */312 xmlChar *minusSign;313 xmlChar *infinity;314 xmlChar *noNumber; /* Not-a-number */315 /* Used for interpretation of pattern and may appear in result */316 xmlChar *decimalPoint;317 xmlChar *grouping;318 xmlChar *percent;319 xmlChar *permille;320 xmlChar *zeroDigit;321 const xmlChar *nsUri;322};323 324/**325 * xsltDocument:326 *327 * Data structure associated to a parsed document.328 */329typedef struct _xsltDocument xsltDocument;330typedef xsltDocument *xsltDocumentPtr;331struct _xsltDocument {332 struct _xsltDocument *next; /* documents are kept in a chained list */333 int main; /* is this the main document */334 xmlDocPtr doc; /* the parsed document */335 void *keys; /* key tables storage */336 struct _xsltDocument *includes; /* subsidiary includes */337 int preproc; /* pre-processing already done */338 int nbKeysComputed;339};340 341/**342 * xsltKeyDef:343 *344 * Representation of an xsl:key.345 */346typedef struct _xsltKeyDef xsltKeyDef;347typedef xsltKeyDef *xsltKeyDefPtr;348struct _xsltKeyDef {349 struct _xsltKeyDef *next;350 xmlNodePtr inst;351 xmlChar *name;352 xmlChar *nameURI;353 xmlChar *match;354 xmlChar *use;355 xmlXPathCompExprPtr comp;356 xmlXPathCompExprPtr usecomp;357 xmlNsPtr *nsList; /* the namespaces in scope */358 int nsNr; /* the number of namespaces in scope */359};360 361/**362 * xsltKeyTable:363 *364 * Holds the computed keys for key definitions of the same QName.365 * Is owned by an xsltDocument.366 */367typedef struct _xsltKeyTable xsltKeyTable;368typedef xsltKeyTable *xsltKeyTablePtr;369struct _xsltKeyTable {370 struct _xsltKeyTable *next;371 xmlChar *name;372 xmlChar *nameURI;373 xmlHashTablePtr keys;374};375 376/*377 * The in-memory structure corresponding to an XSLT Stylesheet.378 * NOTE: most of the content is simply linked from the doc tree379 * structure, no specific allocation is made.380 */381typedef struct _xsltStylesheet xsltStylesheet;382typedef xsltStylesheet *xsltStylesheetPtr;383 384typedef struct _xsltTransformContext xsltTransformContext;385typedef xsltTransformContext *xsltTransformContextPtr;386 387/**388 * xsltElemPreComp:389 *390 * The in-memory structure corresponding to element precomputed data,391 * designed to be extended by extension implementors.392 */393typedef struct _xsltElemPreComp xsltElemPreComp;394typedef xsltElemPreComp *xsltElemPreCompPtr;395 396/**397 * xsltTransformFunction:398 * @ctxt: the XSLT transformation context399 * @node: the input node400 * @inst: the stylesheet node401 * @comp: the compiled information from the stylesheet402 *403 * Signature of the function associated to elements part of the404 * stylesheet language like xsl:if or xsl:apply-templates.405 */406typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,407 xmlNodePtr node,408 xmlNodePtr inst,409 xsltElemPreCompPtr comp);410 411/**412 * xsltSortFunc:413 * @ctxt: a transformation context414 * @sorts: the node-set to sort415 * @nbsorts: the number of sorts416 *417 * Signature of the function to use during sorting418 */419typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,420 int nbsorts);421 422typedef enum {423 XSLT_FUNC_COPY=1,424 XSLT_FUNC_SORT,425 XSLT_FUNC_TEXT,426 XSLT_FUNC_ELEMENT,427 XSLT_FUNC_ATTRIBUTE,428 XSLT_FUNC_COMMENT,429 XSLT_FUNC_PI,430 XSLT_FUNC_COPYOF,431 XSLT_FUNC_VALUEOF,432 XSLT_FUNC_NUMBER,433 XSLT_FUNC_APPLYIMPORTS,434 XSLT_FUNC_CALLTEMPLATE,435 XSLT_FUNC_APPLYTEMPLATES,436 XSLT_FUNC_CHOOSE,437 XSLT_FUNC_IF,438 XSLT_FUNC_FOREACH,439 XSLT_FUNC_DOCUMENT,440 XSLT_FUNC_WITHPARAM,441 XSLT_FUNC_PARAM,442 XSLT_FUNC_VARIABLE,443 XSLT_FUNC_WHEN,444 XSLT_FUNC_EXTENSION445#ifdef XSLT_REFACTORED446 ,447 XSLT_FUNC_OTHERWISE,448 XSLT_FUNC_FALLBACK,449 XSLT_FUNC_MESSAGE,450 XSLT_FUNC_INCLUDE,451 XSLT_FUNC_ATTRSET,452 XSLT_FUNC_LITERAL_RESULT_ELEMENT,453 XSLT_FUNC_UNKOWN_FORWARDS_COMPAT454#endif455} xsltStyleType;456 457/**458 * xsltElemPreCompDeallocator:459 * @comp: the #xsltElemPreComp to free up460 *461 * Deallocates an #xsltElemPreComp structure.462 */463typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);464 465/**466 * xsltElemPreComp:467 *468 * The basic structure for compiled items of the AST of the XSLT processor.469 * This structure is also intended to be extended by extension implementors.470 * TODO: This is somehow not nice, since it has a "free" field, which471 * derived stylesheet-structs do not have.472 */473struct _xsltElemPreComp {474 xsltElemPreCompPtr next; /* next item in the global chained475 list held by xsltStylesheet. */476 xsltStyleType type; /* type of the element */477 xsltTransformFunction func; /* handling function */478 xmlNodePtr inst; /* the node in the stylesheet's tree479 corresponding to this item */480 481 /* end of common part */482 xsltElemPreCompDeallocator free; /* the deallocator */483};484 485/**486 * xsltStylePreComp:487 *488 * The abstract basic structure for items of the XSLT processor.489 * This includes:490 * 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)491 * 2) compiled forms of literal result elements492 * 3) compiled forms of extension elements493 */494typedef struct _xsltStylePreComp xsltStylePreComp;495typedef xsltStylePreComp *xsltStylePreCompPtr;496 497#ifdef XSLT_REFACTORED498 499/*500* Some pointer-list utility functions.501*/502XSLTPUBFUN xsltPointerListPtr XSLTCALL503 xsltPointerListCreate (int initialSize);504XSLTPUBFUN void XSLTCALL505 xsltPointerListFree (xsltPointerListPtr list);506XSLTPUBFUN void XSLTCALL507 xsltPointerListClear (xsltPointerListPtr list);508XSLTPUBFUN int XSLTCALL509 xsltPointerListAddSize (xsltPointerListPtr list,510 void *item,511 int initialSize);512 513/************************************************************************514 * *515 * Refactored structures *516 * *517 ************************************************************************/518 519typedef struct _xsltNsListContainer xsltNsListContainer;520typedef xsltNsListContainer *xsltNsListContainerPtr;521struct _xsltNsListContainer {522 xmlNsPtr *list;523 int totalNumber;524 int xpathNumber;525};526 527/**528 * XSLT_ITEM_COMPATIBILITY_FIELDS:529 *530 * Fields for API compatibility to the structure531 * _xsltElemPreComp which is used for extension functions.532 * Note that @next is used for storage; it does not reflect a next533 * sibling in the tree.534 * TODO: Evaluate if we really need such a compatibility.535 */536#define XSLT_ITEM_COMPATIBILITY_FIELDS \537 xsltElemPreCompPtr next;\538 xsltStyleType type;\539 xsltTransformFunction func;\540 xmlNodePtr inst;541 542/**543 * XSLT_ITEM_NAVIGATION_FIELDS:544 *545 * Currently empty.546 * TODO: It is intended to hold navigational fields in the future.547 */548#define XSLT_ITEM_NAVIGATION_FIELDS549/*550 xsltStylePreCompPtr parent;\551 xsltStylePreCompPtr children;\552 xsltStylePreCompPtr nextItem;553*/554 555/**556 * XSLT_ITEM_NSINSCOPE_FIELDS:557 *558 * The in-scope namespaces.559 */560#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;561 562/**563 * XSLT_ITEM_COMMON_FIELDS:564 *565 * Common fields used for all items.566 */567#define XSLT_ITEM_COMMON_FIELDS \568 XSLT_ITEM_COMPATIBILITY_FIELDS \569 XSLT_ITEM_NAVIGATION_FIELDS \570 XSLT_ITEM_NSINSCOPE_FIELDS571 572/**573 * _xsltStylePreComp:574 *575 * The abstract basic structure for items of the XSLT processor.576 * This includes:577 * 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)578 * 2) compiled forms of literal result elements579 * 3) various properties for XSLT instructions (e.g. xsl:when,580 * xsl:with-param)581 *582 * REVISIT TODO: Keep this structure equal to the fields583 * defined by XSLT_ITEM_COMMON_FIELDS584 */585struct _xsltStylePreComp {586 xsltElemPreCompPtr next; /* next item in the global chained587 list held by xsltStylesheet */588 xsltStyleType type; /* type of the item */589 xsltTransformFunction func; /* handling function */590 xmlNodePtr inst; /* the node in the stylesheet's tree591 corresponding to this item. */592 /* Currently no navigational fields. */593 xsltNsListContainerPtr inScopeNs;594};595 596/**597 * xsltStyleBasicEmptyItem:598 *599 * Abstract structure only used as a short-cut for600 * XSLT items with no extra fields.601 * NOTE that it is intended that this structure looks the same as602 * _xsltStylePreComp.603 */604typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;605typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;606 607struct _xsltStyleBasicEmptyItem {608 XSLT_ITEM_COMMON_FIELDS609};610 611/**612 * xsltStyleBasicExpressionItem:613 *614 * Abstract structure only used as a short-cut for615 * XSLT items with just an expression.616 */617typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;618typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;619 620struct _xsltStyleBasicExpressionItem {621 XSLT_ITEM_COMMON_FIELDS622 623 const xmlChar *select; /* TODO: Change this to "expression". */624 xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */625};626 627/************************************************************************628 * *629 * XSLT-instructions/declarations *630 * *631 ************************************************************************/632 633/**634 * xsltStyleItemElement:635 *636 * <!-- Category: instruction -->637 * <xsl:element638 * name = { qname }639 * namespace = { uri-reference }640 * use-attribute-sets = qnames>641 * <!-- Content: template -->642 * </xsl:element>643 */644typedef struct _xsltStyleItemElement xsltStyleItemElement;645typedef xsltStyleItemElement *xsltStyleItemElementPtr;646 647struct _xsltStyleItemElement {648 XSLT_ITEM_COMMON_FIELDS649 650 const xmlChar *use;651 int has_use;652 const xmlChar *name;653 int has_name;654 const xmlChar *ns;655 const xmlChar *nsPrefix;656 int has_ns;657};658 659/**660 * xsltStyleItemAttribute:661 *662 * <!-- Category: instruction -->663 * <xsl:attribute664 * name = { qname }665 * namespace = { uri-reference }>666 * <!-- Content: template -->667 * </xsl:attribute>668 */669typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;670typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;671 672struct _xsltStyleItemAttribute {673 XSLT_ITEM_COMMON_FIELDS674 const xmlChar *name;675 int has_name;676 const xmlChar *ns;677 const xmlChar *nsPrefix;678 int has_ns;679};680 681/**682 * xsltStyleItemText:683 *684 * <!-- Category: instruction -->685 * <xsl:text686 * disable-output-escaping = "yes" | "no">687 * <!-- Content: #PCDATA -->688 * </xsl:text>689 */690typedef struct _xsltStyleItemText xsltStyleItemText;691typedef xsltStyleItemText *xsltStyleItemTextPtr;692 693struct _xsltStyleItemText {694 XSLT_ITEM_COMMON_FIELDS695 int noescape; /* text */696};697 698/**699 * xsltStyleItemComment:700 *701 * <!-- Category: instruction -->702 * <xsl:comment>703 * <!-- Content: template -->704 * </xsl:comment>705 */706typedef xsltStyleBasicEmptyItem xsltStyleItemComment;707typedef xsltStyleItemComment *xsltStyleItemCommentPtr;708 709/**710 * xsltStyleItemPI:711 *712 * <!-- Category: instruction -->713 * <xsl:processing-instruction714 * name = { ncname }>715 * <!-- Content: template -->716 * </xsl:processing-instruction>717 */718typedef struct _xsltStyleItemPI xsltStyleItemPI;719typedef xsltStyleItemPI *xsltStyleItemPIPtr;720 721struct _xsltStyleItemPI {722 XSLT_ITEM_COMMON_FIELDS723 const xmlChar *name;724 int has_name;725};726 727/**728 * xsltStyleItemApplyImports:729 *730 * <!-- Category: instruction -->731 * <xsl:apply-imports />732 */733typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;734typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;735 736/**737 * xsltStyleItemApplyTemplates:738 *739 * <!-- Category: instruction -->740 * <xsl:apply-templates741 * select = node-set-expression742 * mode = qname>743 * <!-- Content: (xsl:sort | xsl:with-param)* -->744 * </xsl:apply-templates>745 */746typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;747typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;748 749struct _xsltStyleItemApplyTemplates {750 XSLT_ITEM_COMMON_FIELDS751 752 const xmlChar *mode; /* apply-templates */753 const xmlChar *modeURI; /* apply-templates */754 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */755 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */756 /* TODO: with-params */757};758 759/**760 * xsltStyleItemCallTemplate:761 *762 * <!-- Category: instruction -->763 * <xsl:call-template764 * name = qname>765 * <!-- Content: xsl:with-param* -->766 * </xsl:call-template>767 */768typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;769typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;770 771struct _xsltStyleItemCallTemplate {772 XSLT_ITEM_COMMON_FIELDS773 774 xsltTemplatePtr templ; /* call-template */775 const xmlChar *name; /* element, attribute, pi */776 int has_name; /* element, attribute, pi */777 const xmlChar *ns; /* element */778 int has_ns; /* element */779 /* TODO: with-params */780};781 782/**783 * xsltStyleItemCopy:784 *785 * <!-- Category: instruction -->786 * <xsl:copy787 * use-attribute-sets = qnames>788 * <!-- Content: template -->789 * </xsl:copy>790 */791typedef struct _xsltStyleItemCopy xsltStyleItemCopy;792typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;793 794struct _xsltStyleItemCopy {795 XSLT_ITEM_COMMON_FIELDS796 const xmlChar *use; /* copy, element */797 int has_use; /* copy, element */798};799 800/**801 * xsltStyleItemIf:802 *803 * <!-- Category: instruction -->804 * <xsl:if805 * test = boolean-expression>806 * <!-- Content: template -->807 * </xsl:if>808 */809typedef struct _xsltStyleItemIf xsltStyleItemIf;810typedef xsltStyleItemIf *xsltStyleItemIfPtr;811 812struct _xsltStyleItemIf {813 XSLT_ITEM_COMMON_FIELDS814 815 const xmlChar *test; /* if */816 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */817};818 819 820/**821 * xsltStyleItemCopyOf:822 *823 * <!-- Category: instruction -->824 * <xsl:copy-of825 * select = expression />826 */827typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;828typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;829 830/**831 * xsltStyleItemValueOf:832 *833 * <!-- Category: instruction -->834 * <xsl:value-of835 * select = string-expression836 * disable-output-escaping = "yes" | "no" />837 */838typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;839typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;840 841struct _xsltStyleItemValueOf {842 XSLT_ITEM_COMMON_FIELDS843 844 const xmlChar *select;845 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */846 int noescape;847};848 849/**850 * xsltStyleItemNumber:851 *852 * <!-- Category: instruction -->853 * <xsl:number854 * level = "single" | "multiple" | "any"855 * count = pattern856 * from = pattern857 * value = number-expression858 * format = { string }859 * lang = { nmtoken }860 * letter-value = { "alphabetic" | "traditional" }861 * grouping-separator = { char }862 * grouping-size = { number } />863 */864typedef struct _xsltStyleItemNumber xsltStyleItemNumber;865typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;866 867struct _xsltStyleItemNumber {868 XSLT_ITEM_COMMON_FIELDS869 xsltNumberData numdata; /* number */870};871 872/**873 * xsltStyleItemChoose:874 *875 * <!-- Category: instruction -->876 * <xsl:choose>877 * <!-- Content: (xsl:when+, xsl:otherwise?) -->878 * </xsl:choose>879 */880typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;881typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;882 883/**884 * xsltStyleItemFallback:885 *886 * <!-- Category: instruction -->887 * <xsl:fallback>888 * <!-- Content: template -->889 * </xsl:fallback>890 */891typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;892typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;893 894/**895 * xsltStyleItemForEach:896 *897 * <!-- Category: instruction -->898 * <xsl:for-each899 * select = node-set-expression>900 * <!-- Content: (xsl:sort*, template) -->901 * </xsl:for-each>902 */903typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;904typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;905 906/**907 * xsltStyleItemMessage:908 *909 * <!-- Category: instruction -->910 * <xsl:message911 * terminate = "yes" | "no">912 * <!-- Content: template -->913 * </xsl:message>914 */915typedef struct _xsltStyleItemMessage xsltStyleItemMessage;916typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;917 918struct _xsltStyleItemMessage {919 XSLT_ITEM_COMMON_FIELDS920 int terminate;921};922 923/**924 * xsltStyleItemDocument:925 *926 * NOTE: This is not an instruction of XSLT 1.0.927 */928typedef struct _xsltStyleItemDocument xsltStyleItemDocument;929typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;930 931struct _xsltStyleItemDocument {932 XSLT_ITEM_COMMON_FIELDS933 int ver11; /* assigned: in xsltDocumentComp;934 read: nowhere;935 TODO: Check if we need. */936 const xmlChar *filename; /* document URL */937 int has_filename;938};939 940/************************************************************************941 * *942 * Non-instructions (actually properties of instructions/declarations) *943 * *944 ************************************************************************/945 946/**947 * xsltStyleBasicItemVariable:948 *949 * Basic struct for xsl:variable, xsl:param and xsl:with-param.950 * It's currently important to have equal fields, since951 * xsltParseStylesheetCallerParam() is used with xsl:with-param from952 * the xslt side and with xsl:param from the exslt side (in953 * exsltFuncFunctionFunction()).954 *955 * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param956 * have additional different fields.957 */958typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;959typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;960 961struct _xsltStyleBasicItemVariable {962 XSLT_ITEM_COMMON_FIELDS963 964 const xmlChar *select;965 xmlXPathCompExprPtr comp;966 967 const xmlChar *name;968 int has_name;969 const xmlChar *ns;970 int has_ns;971};972 973/**974 * xsltStyleItemVariable:975 *976 * <!-- Category: top-level-element -->977 * <xsl:param978 * name = qname979 * select = expression>980 * <!-- Content: template -->981 * </xsl:param>982 */983typedef xsltStyleBasicItemVariable xsltStyleItemVariable;984typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;985 986/**987 * xsltStyleItemParam:988 *989 * <!-- Category: top-level-element -->990 * <xsl:param991 * name = qname992 * select = expression>993 * <!-- Content: template -->994 * </xsl:param>995 */996typedef struct _xsltStyleItemParam xsltStyleItemParam;997typedef xsltStyleItemParam *xsltStyleItemParamPtr;998 999struct _xsltStyleItemParam {1000 XSLT_ITEM_COMMON_FIELDS1001 1002 const xmlChar *select;1003 xmlXPathCompExprPtr comp;1004 1005 const xmlChar *name;1006 int has_name;1007 const xmlChar *ns;1008 int has_ns;1009};1010 1011/**1012 * xsltStyleItemWithParam:1013 *1014 * <xsl:with-param1015 * name = qname1016 * select = expression>1017 * <!-- Content: template -->1018 * </xsl:with-param>1019 */1020typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;1021typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;1022 1023/**1024 * xsltStyleItemSort:1025 *1026 * Reflects the XSLT xsl:sort item.1027 * Allowed parents: xsl:apply-templates, xsl:for-each1028 * <xsl:sort1029 * select = string-expression1030 * lang = { nmtoken }1031 * data-type = { "text" | "number" | qname-but-not-ncname }1032 * order = { "ascending" | "descending" }1033 * case-order = { "upper-first" | "lower-first" } />1034 */1035typedef struct _xsltStyleItemSort xsltStyleItemSort;1036typedef xsltStyleItemSort *xsltStyleItemSortPtr;1037 1038struct _xsltStyleItemSort {1039 XSLT_ITEM_COMMON_FIELDS1040 1041 const xmlChar *stype; /* sort */1042 int has_stype; /* sort */1043 int number; /* sort */1044 const xmlChar *order; /* sort */1045 int has_order; /* sort */1046 int descending; /* sort */1047 const xmlChar *lang; /* sort */1048 int has_lang; /* sort */1049 const xmlChar *case_order; /* sort */1050 int lower_first; /* sort */1051 1052 const xmlChar *use;1053 int has_use;1054 1055 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */1056 1057 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */1058};1059 1060 1061/**1062 * xsltStyleItemWhen:1063 *1064 * <xsl:when1065 * test = boolean-expression>1066 * <!-- Content: template -->1067 * </xsl:when>1068 * Allowed parent: xsl:choose1069 */1070typedef struct _xsltStyleItemWhen xsltStyleItemWhen;1071typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;1072 1073struct _xsltStyleItemWhen {1074 XSLT_ITEM_COMMON_FIELDS1075 1076 const xmlChar *test;1077 xmlXPathCompExprPtr comp;1078};1079 1080/**1081 * xsltStyleItemOtherwise:1082 *1083 * Allowed parent: xsl:choose1084 * <xsl:otherwise>1085 * <!-- Content: template -->1086 * </xsl:otherwise>1087 */1088typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;1089typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;1090 1091struct _xsltStyleItemOtherwise {1092 XSLT_ITEM_COMMON_FIELDS1093};1094 1095typedef struct _xsltStyleItemInclude xsltStyleItemInclude;1096typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;1097 1098struct _xsltStyleItemInclude {1099 XSLT_ITEM_COMMON_FIELDS1100 xsltDocumentPtr include;1101};1102 1103/************************************************************************1104 * *1105 * XSLT elements in forwards-compatible mode *1106 * *1107 ************************************************************************/1108 1109typedef struct _xsltStyleItemUknown xsltStyleItemUknown;1110typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;1111struct _xsltStyleItemUknown {1112 XSLT_ITEM_COMMON_FIELDS1113};1114 1115 1116/************************************************************************1117 * *1118 * Extension elements *1119 * *1120 ************************************************************************/1121 1122/*1123 * xsltStyleItemExtElement:1124 *1125 * Reflects extension elements.1126 *1127 * NOTE: Due to the fact that the structure xsltElemPreComp is most1128 * probably already heavily in use out there by users, so we cannot1129 * easily change it, we'll create an intermediate structure which will1130 * hold an xsltElemPreCompPtr.1131 * BIG NOTE: The only problem I see here is that the user processes the1132 * content of the stylesheet tree, possibly he'll lookup the node->psvi1133 * fields in order to find subsequent extension functions.1134 * In this case, the user's code will break, since the node->psvi1135 * field will hold now the xsltStyleItemExtElementPtr and not1136 * the xsltElemPreCompPtr.1137 * However the place where the structure is anchored in the node-tree,1138 * namely node->psvi, has beed already once been moved from node->_private1139 * to node->psvi, so we have a precedent here, which, I think, should allow1140 * us to change such semantics without headaches.1141 */1142typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;1143typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;1144struct _xsltStyleItemExtElement {1145 XSLT_ITEM_COMMON_FIELDS1146 xsltElemPreCompPtr item;1147};1148 1149/************************************************************************1150 * *1151 * Literal result elements *1152 * *1153 ************************************************************************/1154 1155typedef struct _xsltEffectiveNs xsltEffectiveNs;1156typedef xsltEffectiveNs *xsltEffectiveNsPtr;1157struct _xsltEffectiveNs {1158 xsltEffectiveNsPtr nextInStore; /* storage next */1159 xsltEffectiveNsPtr next; /* next item in the list */1160 const xmlChar *prefix;1161 const xmlChar *nsName;1162 /*1163 * Indicates if eclared on the literal result element; dunno if really1164 * needed.1165 */1166 int holdByElem;1167};1168 1169/*1170 * Info for literal result elements.1171 * This will be set on the elem->psvi field and will be1172 * shared by literal result elements, which have the same1173 * excluded result namespaces; i.e., this *won't* be created uniquely1174 * for every literal result element.1175 */1176typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;1177typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;1178struct _xsltStyleItemLRElementInfo {1179 XSLT_ITEM_COMMON_FIELDS1180 /*1181 * @effectiveNs is the set of effective ns-nodes1182 * on the literal result element, which will be added to the result1183 * element if not already existing in the result tree.1184 * This means that excluded namespaces (via exclude-result-prefixes,1185 * extension-element-prefixes and the XSLT namespace) not added1186 * to the set.1187 * Namespace-aliasing was applied on the @effectiveNs.1188 */1189 xsltEffectiveNsPtr effectiveNs;1190 1191};1192 1193#ifdef XSLT_REFACTORED1194 1195typedef struct _xsltNsAlias xsltNsAlias;1196typedef xsltNsAlias *xsltNsAliasPtr;1197struct _xsltNsAlias {1198 xsltNsAliasPtr next; /* next in the list */1199 xmlNsPtr literalNs;1200 xmlNsPtr targetNs;