xslt: Import upstream release 1.1.38.
[wine.git] / libs / xslt / libxslt / xsltInternals.h
blob7de638e143dd17762113e024b831a9b70a510f71
1 /*
2 * Summary: internal data structures, constants and functions
3 * Description: Internal data structures, constants and functions used
4 * by the XSLT engine.
5 * They are not part of the API or ABI, i.e. they can change
6 * without prior notice, use carefully.
8 * Copy: See Copyright for the status of this software.
10 * Author: Daniel Veillard
13 #ifndef __XML_XSLT_INTERNALS_H__
14 #define __XML_XSLT_INTERNALS_H__
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"
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
30 /* #define XSLT_DEBUG_PROFILE_CACHE */
32 /**
33 * XSLT_IS_TEXT_NODE:
35 * check if the argument is a text node
37 #define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
38 (((n)->type == XML_TEXT_NODE) || \
39 ((n)->type == XML_CDATA_SECTION_NODE)))
42 /**
43 * XSLT_MARK_RES_TREE_FRAG:
45 * internal macro to set up tree fragments
47 #define XSLT_MARK_RES_TREE_FRAG(n) \
48 (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
50 /**
51 * XSLT_IS_RES_TREE_FRAG:
53 * internal macro to test tree fragments
55 #define XSLT_IS_RES_TREE_FRAG(n) \
56 ((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
57 ((n)->name != NULL) && ((n)->name[0] == ' '))
59 /**
60 * XSLT_REFACTORED_KEYCOMP:
62 * Internal define to enable on-demand xsl:key computation.
63 * That's the only mode now but the define is kept for compatibility
65 #define XSLT_REFACTORED_KEYCOMP
67 /**
68 * XSLT_FAST_IF:
70 * Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
71 * for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
73 #define XSLT_FAST_IF
75 /**
76 * XSLT_REFACTORED:
78 * Internal define to enable the refactored parts of Libxslt.
80 /* #define XSLT_REFACTORED */
81 /* ==================================================================== */
83 /**
84 * XSLT_REFACTORED_VARS:
86 * Internal define to enable the refactored variable part of libxslt
88 #define XSLT_REFACTORED_VARS
90 #ifdef XSLT_REFACTORED
92 extern const xmlChar *xsltXSLTAttrMarker;
95 /* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
97 /* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
99 /**
100 * XSLT_REFACTORED_XSLT_NSCOMP
102 * Internal define to enable the pointer-comparison of
103 * namespaces of XSLT elements.
105 /* #define XSLT_REFACTORED_XSLT_NSCOMP */
107 #ifdef XSLT_REFACTORED_XSLT_NSCOMP
109 extern const xmlChar *xsltConstNamespaceNameXSLT;
112 * IS_XSLT_ELEM_FAST:
114 * quick test to detect XSLT elements
116 #define IS_XSLT_ELEM_FAST(n) \
117 (((n) != NULL) && ((n)->ns != NULL) && \
118 ((n)->ns->href == xsltConstNamespaceNameXSLT))
121 * IS_XSLT_ATTR_FAST:
123 * quick test to detect XSLT attributes
125 #define IS_XSLT_ATTR_FAST(a) \
126 (((a) != NULL) && ((a)->ns != NULL) && \
127 ((a)->ns->href == xsltConstNamespaceNameXSLT))
130 * XSLT_HAS_INTERNAL_NSMAP:
132 * check for namespace mapping
134 #define XSLT_HAS_INTERNAL_NSMAP(s) \
135 (((s) != NULL) && ((s)->principal) && \
136 ((s)->principal->principalData) && \
137 ((s)->principal->principalData->nsMap))
140 * XSLT_GET_INTERNAL_NSMAP:
142 * get pointer to namespace map
144 #define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
146 #else /* XSLT_REFACTORED_XSLT_NSCOMP */
149 * IS_XSLT_ELEM_FAST:
151 * quick check whether this is an xslt element
153 #define IS_XSLT_ELEM_FAST(n) \
154 (((n) != NULL) && ((n)->ns != NULL) && \
155 (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
158 * IS_XSLT_ATTR_FAST:
160 * quick check for xslt namespace attribute
162 #define IS_XSLT_ATTR_FAST(a) \
163 (((a) != NULL) && ((a)->ns != NULL) && \
164 (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
167 #endif /* XSLT_REFACTORED_XSLT_NSCOMP */
171 * XSLT_REFACTORED_MANDATORY_VERSION:
173 * TODO: Currently disabled to surpress regression test failures, since
174 * the old behaviour was that a missing version attribute
175 * 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.
178 /* #define XSLT_REFACTORED_MANDATORY_VERSION */
181 * xsltPointerList:
183 * Pointer-list for various purposes.
185 typedef struct _xsltPointerList xsltPointerList;
186 typedef xsltPointerList *xsltPointerListPtr;
187 struct _xsltPointerList {
188 void **items;
189 int number;
190 int size;
193 #endif
196 * XSLT_REFACTORED_PARSING:
198 * Internal define to enable the refactored parts of Libxslt
199 * related to parsing.
201 /* #define XSLT_REFACTORED_PARSING */
204 * XSLT_MAX_SORT:
206 * Max number of specified xsl:sort on an element.
208 #define XSLT_MAX_SORT 15
211 * XSLT_PAT_NO_PRIORITY:
213 * Specific value for pattern without priority expressed.
215 #define XSLT_PAT_NO_PRIORITY -12345789
218 * xsltRuntimeExtra:
220 * Extra information added to the transformation context.
222 typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
223 typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
224 struct _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;
234 * XSLT_RUNTIME_EXTRA_LST:
235 * @ctxt: the transformation context
236 * @nr: the index
238 * Macro used to access extra information stored in the context
240 #define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
242 * XSLT_RUNTIME_EXTRA_FREE:
243 * @ctxt: the transformation context
244 * @nr: the index
246 * Macro used to free extra information stored in the context
248 #define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
250 * XSLT_RUNTIME_EXTRA:
251 * @ctxt: the transformation context
252 * @nr: the index
254 * Macro used to define extra information stored in the context
256 #define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
259 * xsltTemplate:
261 * The in-memory structure corresponding to an XSLT Template.
263 typedef struct _xsltTemplate xsltTemplate;
264 typedef xsltTemplate *xsltTemplatePtr;
265 struct _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 */
278 * TODO: @inheritedNsNr and @inheritedNs won't be used in the
279 * refactored code.
281 int inheritedNsNr; /* number of inherited namespaces */
282 xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
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 */
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 */
294 /* Conflict resolution */
295 int position;
299 * xsltDecimalFormat:
301 * Data structure of decimal-format.
303 typedef struct _xsltDecimalFormat xsltDecimalFormat;
304 typedef xsltDecimalFormat *xsltDecimalFormatPtr;
305 struct _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;
325 * xsltDocument:
327 * Data structure associated to a parsed document.
329 typedef struct _xsltDocument xsltDocument;
330 typedef xsltDocument *xsltDocumentPtr;
331 struct _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;
342 * xsltKeyDef:
344 * Representation of an xsl:key.
346 typedef struct _xsltKeyDef xsltKeyDef;
347 typedef xsltKeyDef *xsltKeyDefPtr;
348 struct _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 */
362 * xsltKeyTable:
364 * Holds the computed keys for key definitions of the same QName.
365 * Is owned by an xsltDocument.
367 typedef struct _xsltKeyTable xsltKeyTable;
368 typedef xsltKeyTable *xsltKeyTablePtr;
369 struct _xsltKeyTable {
370 struct _xsltKeyTable *next;
371 xmlChar *name;
372 xmlChar *nameURI;
373 xmlHashTablePtr keys;
377 * The in-memory structure corresponding to an XSLT Stylesheet.
378 * NOTE: most of the content is simply linked from the doc tree
379 * structure, no specific allocation is made.
381 typedef struct _xsltStylesheet xsltStylesheet;
382 typedef xsltStylesheet *xsltStylesheetPtr;
384 typedef struct _xsltTransformContext xsltTransformContext;
385 typedef xsltTransformContext *xsltTransformContextPtr;
388 * xsltElemPreComp:
390 * The in-memory structure corresponding to element precomputed data,
391 * designed to be extended by extension implementors.
393 typedef struct _xsltElemPreComp xsltElemPreComp;
394 typedef xsltElemPreComp *xsltElemPreCompPtr;
397 * xsltTransformFunction:
398 * @ctxt: the XSLT transformation context
399 * @node: the input node
400 * @inst: the stylesheet node
401 * @comp: the compiled information from the stylesheet
403 * Signature of the function associated to elements part of the
404 * stylesheet language like xsl:if or xsl:apply-templates.
406 typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
407 xmlNodePtr node,
408 xmlNodePtr inst,
409 xsltElemPreCompPtr comp);
412 * xsltSortFunc:
413 * @ctxt: a transformation context
414 * @sorts: the node-set to sort
415 * @nbsorts: the number of sorts
417 * Signature of the function to use during sorting
419 typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
420 int nbsorts);
422 typedef 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_EXTENSION
445 #ifdef XSLT_REFACTORED
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_COMPAT
454 #endif
455 } xsltStyleType;
458 * xsltElemPreCompDeallocator:
459 * @comp: the #xsltElemPreComp to free up
461 * Deallocates an #xsltElemPreComp structure.
463 typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
466 * xsltElemPreComp:
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, which
471 * derived stylesheet-structs do not have.
473 struct _xsltElemPreComp {
474 xsltElemPreCompPtr next; /* next item in the global chained
475 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 tree
479 corresponding to this item */
481 /* end of common part */
482 xsltElemPreCompDeallocator free; /* the deallocator */
486 * xsltStylePreComp:
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 elements
492 * 3) compiled forms of extension elements
494 typedef struct _xsltStylePreComp xsltStylePreComp;
495 typedef xsltStylePreComp *xsltStylePreCompPtr;
497 #ifdef XSLT_REFACTORED
500 * Some pointer-list utility functions.
502 XSLTPUBFUN xsltPointerListPtr XSLTCALL
503 xsltPointerListCreate (int initialSize);
504 XSLTPUBFUN void XSLTCALL
505 xsltPointerListFree (xsltPointerListPtr list);
506 XSLTPUBFUN void XSLTCALL
507 xsltPointerListClear (xsltPointerListPtr list);
508 XSLTPUBFUN int XSLTCALL
509 xsltPointerListAddSize (xsltPointerListPtr list,
510 void *item,
511 int initialSize);
513 /************************************************************************
515 * Refactored structures *
517 ************************************************************************/
519 typedef struct _xsltNsListContainer xsltNsListContainer;
520 typedef xsltNsListContainer *xsltNsListContainerPtr;
521 struct _xsltNsListContainer {
522 xmlNsPtr *list;
523 int totalNumber;
524 int xpathNumber;
528 * XSLT_ITEM_COMPATIBILITY_FIELDS:
530 * Fields for API compatibility to the structure
531 * _xsltElemPreComp which is used for extension functions.
532 * Note that @next is used for storage; it does not reflect a next
533 * sibling in the tree.
534 * TODO: Evaluate if we really need such a compatibility.
536 #define XSLT_ITEM_COMPATIBILITY_FIELDS \
537 xsltElemPreCompPtr next;\
538 xsltStyleType type;\
539 xsltTransformFunction func;\
540 xmlNodePtr inst;
543 * XSLT_ITEM_NAVIGATION_FIELDS:
545 * Currently empty.
546 * TODO: It is intended to hold navigational fields in the future.
548 #define XSLT_ITEM_NAVIGATION_FIELDS
550 xsltStylePreCompPtr parent;\
551 xsltStylePreCompPtr children;\
552 xsltStylePreCompPtr nextItem;
556 * XSLT_ITEM_NSINSCOPE_FIELDS:
558 * The in-scope namespaces.
560 #define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
563 * XSLT_ITEM_COMMON_FIELDS:
565 * Common fields used for all items.
567 #define XSLT_ITEM_COMMON_FIELDS \
568 XSLT_ITEM_COMPATIBILITY_FIELDS \
569 XSLT_ITEM_NAVIGATION_FIELDS \
570 XSLT_ITEM_NSINSCOPE_FIELDS
573 * _xsltStylePreComp:
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 elements
579 * 3) various properties for XSLT instructions (e.g. xsl:when,
580 * xsl:with-param)
582 * REVISIT TODO: Keep this structure equal to the fields
583 * defined by XSLT_ITEM_COMMON_FIELDS
585 struct _xsltStylePreComp {
586 xsltElemPreCompPtr next; /* next item in the global chained
587 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 tree
591 corresponding to this item. */
592 /* Currently no navigational fields. */
593 xsltNsListContainerPtr inScopeNs;
597 * xsltStyleBasicEmptyItem:
599 * Abstract structure only used as a short-cut for
600 * XSLT items with no extra fields.
601 * NOTE that it is intended that this structure looks the same as
602 * _xsltStylePreComp.
604 typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
605 typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
607 struct _xsltStyleBasicEmptyItem {
608 XSLT_ITEM_COMMON_FIELDS
612 * xsltStyleBasicExpressionItem:
614 * Abstract structure only used as a short-cut for
615 * XSLT items with just an expression.
617 typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
618 typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
620 struct _xsltStyleBasicExpressionItem {
621 XSLT_ITEM_COMMON_FIELDS
623 const xmlChar *select; /* TODO: Change this to "expression". */
624 xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
627 /************************************************************************
629 * XSLT-instructions/declarations *
631 ************************************************************************/
634 * xsltStyleItemElement:
636 * <!-- Category: instruction -->
637 * <xsl:element
638 * name = { qname }
639 * namespace = { uri-reference }
640 * use-attribute-sets = qnames>
641 * <!-- Content: template -->
642 * </xsl:element>
644 typedef struct _xsltStyleItemElement xsltStyleItemElement;
645 typedef xsltStyleItemElement *xsltStyleItemElementPtr;
647 struct _xsltStyleItemElement {
648 XSLT_ITEM_COMMON_FIELDS
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;
660 * xsltStyleItemAttribute:
662 * <!-- Category: instruction -->
663 * <xsl:attribute
664 * name = { qname }
665 * namespace = { uri-reference }>
666 * <!-- Content: template -->
667 * </xsl:attribute>
669 typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
670 typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
672 struct _xsltStyleItemAttribute {
673 XSLT_ITEM_COMMON_FIELDS
674 const xmlChar *name;
675 int has_name;
676 const xmlChar *ns;
677 const xmlChar *nsPrefix;
678 int has_ns;
682 * xsltStyleItemText:
684 * <!-- Category: instruction -->
685 * <xsl:text
686 * disable-output-escaping = "yes" | "no">
687 * <!-- Content: #PCDATA -->
688 * </xsl:text>
690 typedef struct _xsltStyleItemText xsltStyleItemText;
691 typedef xsltStyleItemText *xsltStyleItemTextPtr;
693 struct _xsltStyleItemText {
694 XSLT_ITEM_COMMON_FIELDS
695 int noescape; /* text */
699 * xsltStyleItemComment:
701 * <!-- Category: instruction -->
702 * <xsl:comment>
703 * <!-- Content: template -->
704 * </xsl:comment>
706 typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
707 typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
710 * xsltStyleItemPI:
712 * <!-- Category: instruction -->
713 * <xsl:processing-instruction
714 * name = { ncname }>
715 * <!-- Content: template -->
716 * </xsl:processing-instruction>
718 typedef struct _xsltStyleItemPI xsltStyleItemPI;
719 typedef xsltStyleItemPI *xsltStyleItemPIPtr;
721 struct _xsltStyleItemPI {
722 XSLT_ITEM_COMMON_FIELDS
723 const xmlChar *name;
724 int has_name;
728 * xsltStyleItemApplyImports:
730 * <!-- Category: instruction -->
731 * <xsl:apply-imports />
733 typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
734 typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
737 * xsltStyleItemApplyTemplates:
739 * <!-- Category: instruction -->
740 * <xsl:apply-templates
741 * select = node-set-expression
742 * mode = qname>
743 * <!-- Content: (xsl:sort | xsl:with-param)* -->
744 * </xsl:apply-templates>
746 typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
747 typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
749 struct _xsltStyleItemApplyTemplates {
750 XSLT_ITEM_COMMON_FIELDS
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 */
760 * xsltStyleItemCallTemplate:
762 * <!-- Category: instruction -->
763 * <xsl:call-template
764 * name = qname>
765 * <!-- Content: xsl:with-param* -->
766 * </xsl:call-template>
768 typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
769 typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
771 struct _xsltStyleItemCallTemplate {
772 XSLT_ITEM_COMMON_FIELDS
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 */
783 * xsltStyleItemCopy:
785 * <!-- Category: instruction -->
786 * <xsl:copy
787 * use-attribute-sets = qnames>
788 * <!-- Content: template -->
789 * </xsl:copy>
791 typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
792 typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
794 struct _xsltStyleItemCopy {
795 XSLT_ITEM_COMMON_FIELDS
796 const xmlChar *use; /* copy, element */
797 int has_use; /* copy, element */
801 * xsltStyleItemIf:
803 * <!-- Category: instruction -->
804 * <xsl:if
805 * test = boolean-expression>
806 * <!-- Content: template -->
807 * </xsl:if>
809 typedef struct _xsltStyleItemIf xsltStyleItemIf;
810 typedef xsltStyleItemIf *xsltStyleItemIfPtr;
812 struct _xsltStyleItemIf {
813 XSLT_ITEM_COMMON_FIELDS
815 const xmlChar *test; /* if */
816 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
821 * xsltStyleItemCopyOf:
823 * <!-- Category: instruction -->
824 * <xsl:copy-of
825 * select = expression />
827 typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
828 typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
831 * xsltStyleItemValueOf:
833 * <!-- Category: instruction -->
834 * <xsl:value-of
835 * select = string-expression
836 * disable-output-escaping = "yes" | "no" />
838 typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
839 typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
841 struct _xsltStyleItemValueOf {
842 XSLT_ITEM_COMMON_FIELDS
844 const xmlChar *select;
845 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
846 int noescape;
850 * xsltStyleItemNumber:
852 * <!-- Category: instruction -->
853 * <xsl:number
854 * level = "single" | "multiple" | "any"
855 * count = pattern
856 * from = pattern
857 * value = number-expression
858 * format = { string }
859 * lang = { nmtoken }
860 * letter-value = { "alphabetic" | "traditional" }
861 * grouping-separator = { char }
862 * grouping-size = { number } />
864 typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
865 typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
867 struct _xsltStyleItemNumber {
868 XSLT_ITEM_COMMON_FIELDS
869 xsltNumberData numdata; /* number */
873 * xsltStyleItemChoose:
875 * <!-- Category: instruction -->
876 * <xsl:choose>
877 * <!-- Content: (xsl:when+, xsl:otherwise?) -->
878 * </xsl:choose>
880 typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
881 typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
884 * xsltStyleItemFallback:
886 * <!-- Category: instruction -->
887 * <xsl:fallback>
888 * <!-- Content: template -->
889 * </xsl:fallback>
891 typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
892 typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
895 * xsltStyleItemForEach:
897 * <!-- Category: instruction -->
898 * <xsl:for-each
899 * select = node-set-expression>
900 * <!-- Content: (xsl:sort*, template) -->
901 * </xsl:for-each>
903 typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
904 typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
907 * xsltStyleItemMessage:
909 * <!-- Category: instruction -->
910 * <xsl:message
911 * terminate = "yes" | "no">
912 * <!-- Content: template -->
913 * </xsl:message>
915 typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
916 typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
918 struct _xsltStyleItemMessage {
919 XSLT_ITEM_COMMON_FIELDS
920 int terminate;
924 * xsltStyleItemDocument:
926 * NOTE: This is not an instruction of XSLT 1.0.
928 typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
929 typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
931 struct _xsltStyleItemDocument {
932 XSLT_ITEM_COMMON_FIELDS
933 int ver11; /* assigned: in xsltDocumentComp;
934 read: nowhere;
935 TODO: Check if we need. */
936 const xmlChar *filename; /* document URL */
937 int has_filename;
940 /************************************************************************
942 * Non-instructions (actually properties of instructions/declarations) *
944 ************************************************************************/
947 * xsltStyleBasicItemVariable:
949 * Basic struct for xsl:variable, xsl:param and xsl:with-param.
950 * It's currently important to have equal fields, since
951 * xsltParseStylesheetCallerParam() is used with xsl:with-param from
952 * the xslt side and with xsl:param from the exslt side (in
953 * exsltFuncFunctionFunction()).
955 * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
956 * have additional different fields.
958 typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
959 typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
961 struct _xsltStyleBasicItemVariable {
962 XSLT_ITEM_COMMON_FIELDS
964 const xmlChar *select;
965 xmlXPathCompExprPtr comp;
967 const xmlChar *name;
968 int has_name;
969 const xmlChar *ns;
970 int has_ns;
974 * xsltStyleItemVariable:
976 * <!-- Category: top-level-element -->
977 * <xsl:param
978 * name = qname
979 * select = expression>
980 * <!-- Content: template -->
981 * </xsl:param>
983 typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
984 typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
987 * xsltStyleItemParam:
989 * <!-- Category: top-level-element -->
990 * <xsl:param
991 * name = qname
992 * select = expression>
993 * <!-- Content: template -->
994 * </xsl:param>
996 typedef struct _xsltStyleItemParam xsltStyleItemParam;
997 typedef xsltStyleItemParam *xsltStyleItemParamPtr;
999 struct _xsltStyleItemParam {
1000 XSLT_ITEM_COMMON_FIELDS
1002 const xmlChar *select;
1003 xmlXPathCompExprPtr comp;
1005 const xmlChar *name;
1006 int has_name;
1007 const xmlChar *ns;
1008 int has_ns;
1012 * xsltStyleItemWithParam:
1014 * <xsl:with-param
1015 * name = qname
1016 * select = expression>
1017 * <!-- Content: template -->
1018 * </xsl:with-param>
1020 typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
1021 typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
1024 * xsltStyleItemSort:
1026 * Reflects the XSLT xsl:sort item.
1027 * Allowed parents: xsl:apply-templates, xsl:for-each
1028 * <xsl:sort
1029 * select = string-expression
1030 * lang = { nmtoken }
1031 * data-type = { "text" | "number" | qname-but-not-ncname }
1032 * order = { "ascending" | "descending" }
1033 * case-order = { "upper-first" | "lower-first" } />
1035 typedef struct _xsltStyleItemSort xsltStyleItemSort;
1036 typedef xsltStyleItemSort *xsltStyleItemSortPtr;
1038 struct _xsltStyleItemSort {
1039 XSLT_ITEM_COMMON_FIELDS
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 */
1052 const xmlChar *use;
1053 int has_use;
1055 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1057 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1062 * xsltStyleItemWhen:
1064 * <xsl:when
1065 * test = boolean-expression>
1066 * <!-- Content: template -->
1067 * </xsl:when>
1068 * Allowed parent: xsl:choose
1070 typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
1071 typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
1073 struct _xsltStyleItemWhen {
1074 XSLT_ITEM_COMMON_FIELDS
1076 const xmlChar *test;
1077 xmlXPathCompExprPtr comp;
1081 * xsltStyleItemOtherwise:
1083 * Allowed parent: xsl:choose
1084 * <xsl:otherwise>
1085 * <!-- Content: template -->
1086 * </xsl:otherwise>
1088 typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
1089 typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
1091 struct _xsltStyleItemOtherwise {
1092 XSLT_ITEM_COMMON_FIELDS
1095 typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
1096 typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
1098 struct _xsltStyleItemInclude {
1099 XSLT_ITEM_COMMON_FIELDS
1100 xsltDocumentPtr include;
1103 /************************************************************************
1105 * XSLT elements in forwards-compatible mode *
1107 ************************************************************************/
1109 typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
1110 typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
1111 struct _xsltStyleItemUknown {
1112 XSLT_ITEM_COMMON_FIELDS
1116 /************************************************************************
1118 * Extension elements *
1120 ************************************************************************/
1123 * xsltStyleItemExtElement:
1125 * Reflects extension elements.
1127 * NOTE: Due to the fact that the structure xsltElemPreComp is most
1128 * probably already heavily in use out there by users, so we cannot
1129 * easily change it, we'll create an intermediate structure which will
1130 * hold an xsltElemPreCompPtr.
1131 * BIG NOTE: The only problem I see here is that the user processes the
1132 * content of the stylesheet tree, possibly he'll lookup the node->psvi
1133 * fields in order to find subsequent extension functions.
1134 * In this case, the user's code will break, since the node->psvi
1135 * field will hold now the xsltStyleItemExtElementPtr and not
1136 * 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->_private
1139 * to node->psvi, so we have a precedent here, which, I think, should allow
1140 * us to change such semantics without headaches.
1142 typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
1143 typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
1144 struct _xsltStyleItemExtElement {
1145 XSLT_ITEM_COMMON_FIELDS
1146 xsltElemPreCompPtr item;
1149 /************************************************************************
1151 * Literal result elements *
1153 ************************************************************************/
1155 typedef struct _xsltEffectiveNs xsltEffectiveNs;
1156 typedef xsltEffectiveNs *xsltEffectiveNsPtr;
1157 struct _xsltEffectiveNs {
1158 xsltEffectiveNsPtr nextInStore; /* storage next */
1159 xsltEffectiveNsPtr next; /* next item in the list */
1160 const xmlChar *prefix;
1161 const xmlChar *nsName;
1163 * Indicates if eclared on the literal result element; dunno if really
1164 * needed.
1166 int holdByElem;
1170 * Info for literal result elements.
1171 * This will be set on the elem->psvi field and will be
1172 * shared by literal result elements, which have the same
1173 * excluded result namespaces; i.e., this *won't* be created uniquely
1174 * for every literal result element.
1176 typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
1177 typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
1178 struct _xsltStyleItemLRElementInfo {
1179 XSLT_ITEM_COMMON_FIELDS
1181 * @effectiveNs is the set of effective ns-nodes
1182 * on the literal result element, which will be added to the result
1183 * 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 added
1186 * to the set.
1187 * Namespace-aliasing was applied on the @effectiveNs.
1189 xsltEffectiveNsPtr effectiveNs;
1193 #ifdef XSLT_REFACTORED
1195 typedef struct _xsltNsAlias xsltNsAlias;
1196 typedef xsltNsAlias *xsltNsAliasPtr;
1197 struct _xsltNsAlias {
1198 xsltNsAliasPtr next; /* next in the list */
1199 xmlNsPtr literalNs;
1200 xmlNsPtr targetNs;
1201 xmlDocPtr docOfTargetNs;
1203 #endif
1205 #ifdef XSLT_REFACTORED_XSLT_NSCOMP
1207 typedef struct _xsltNsMap xsltNsMap;
1208 typedef xsltNsMap *xsltNsMapPtr;
1209 struct _xsltNsMap {
1210 xsltNsMapPtr next; /* next in the list */
1211 xmlDocPtr doc;
1212 xmlNodePtr elem; /* the element holding the ns-decl */
1213 xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
1214 const xmlChar *origNsName; /* the original XML namespace name */
1215 const xmlChar *newNsName; /* the mapped XML namespace name */
1217 #endif
1219 /************************************************************************
1221 * Compile-time structures for *internal* use only *
1223 ************************************************************************/
1225 typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
1226 typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
1228 typedef struct _xsltNsList xsltNsList;
1229 typedef xsltNsList *xsltNsListPtr;
1230 struct _xsltNsList {
1231 xsltNsListPtr next; /* next in the list */
1232 xmlNsPtr ns;
1236 * xsltVarInfo:
1238 * Used at compilation time for parameters and variables.
1240 typedef struct _xsltVarInfo xsltVarInfo;
1241 typedef xsltVarInfo *xsltVarInfoPtr;
1242 struct _xsltVarInfo {
1243 xsltVarInfoPtr next; /* next in the list */
1244 xsltVarInfoPtr prev;
1245 int depth; /* the depth in the tree */
1246 const xmlChar *name;
1247 const xmlChar *nsName;
1251 * xsltCompilerNodeInfo:
1253 * Per-node information during compile-time.
1255 typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
1256 typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
1257 struct _xsltCompilerNodeInfo {
1258 xsltCompilerNodeInfoPtr next;
1259 xsltCompilerNodeInfoPtr prev;
1260 xmlNodePtr node;
1261 int depth;
1262 xsltTemplatePtr templ; /* The owning template */
1263 int category; /* XSLT element, LR-element or
1264 extension element */
1265 xsltStyleType type;
1266 xsltElemPreCompPtr item; /* The compiled information */
1267 /* The current in-scope namespaces */
1268 xsltNsListContainerPtr inScopeNs;
1269 /* The current excluded result namespaces */
1270 xsltPointerListPtr exclResultNs;
1271 /* The current extension instruction namespaces */
1272 xsltPointerListPtr extElemNs;
1274 /* The current info for literal result elements. */
1275 xsltStyleItemLRElementInfoPtr litResElemInfo;
1277 * Set to 1 if in-scope namespaces changed,
1278 * or excluded result namespaces changed,
1279 * or extension element namespaces changed.
1280 * This will trigger creation of new infos
1281 * for literal result elements.
1283 int nsChanged;
1284 int preserveWhitespace;
1285 int stripWhitespace;
1286 int isRoot; /* whether this is the stylesheet's root node */
1287 int forwardsCompat; /* whether forwards-compatible mode is enabled */
1288 /* whether the content of an extension element was processed */
1289 int extContentHandled;
1290 /* the type of the current child */
1291 xsltStyleType curChildType;
1295 * XSLT_CCTXT:
1297 * get pointer to compiler context
1299 #define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)
1301 typedef enum {
1302 XSLT_ERROR_SEVERITY_ERROR = 0,
1303 XSLT_ERROR_SEVERITY_WARNING
1304 } xsltErrorSeverityType;
1306 typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
1307 typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
1308 struct _xsltCompilerCtxt {
1309 void *errorCtxt; /* user specific error context */
1311 * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
1312 xsltErrorSeverityType errSeverity;
1313 int warnings; /* TODO: number of warnings found at
1314 compilation */
1315 int errors; /* TODO: number of errors found at
1316 compilation */
1317 xmlDictPtr dict;
1318 xsltStylesheetPtr style;
1319 int simplified; /* whether this is a simplified stylesheet */
1320 /* TODO: structured/unstructured error contexts. */
1321 int depth; /* Current depth of processing */
1323 xsltCompilerNodeInfoPtr inode;
1324 xsltCompilerNodeInfoPtr inodeList;
1325 xsltCompilerNodeInfoPtr inodeLast;
1326 xsltPointerListPtr tmpList; /* Used for various purposes */
1328 * The XSLT version as specified by the stylesheet's root element.
1330 int isInclude;
1331 int hasForwardsCompat; /* whether forwards-compatible mode was used
1332 in a parsing episode */
1333 int maxNodeInfos; /* TEMP TODO: just for the interest */
1334 int maxLREs; /* TEMP TODO: just for the interest */
1336 * In order to keep the old behaviour, applying strict rules of
1337 * the spec can be turned off. This has effect only on special
1338 * mechanisms like whitespace-stripping in the stylesheet.
1340 int strict;
1341 xsltPrincipalStylesheetDataPtr psData;
1342 xsltStyleItemUknownPtr unknownItem;
1343 int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
1344 xsltNsAliasPtr nsAliases;
1345 xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
1346 xsltVarInfoPtr ivar; /* topmost local variable/param. */
1349 #else /* XSLT_REFACTORED */
1351 * The old structures before refactoring.
1355 * _xsltStylePreComp:
1357 * The in-memory structure corresponding to XSLT stylesheet constructs
1358 * precomputed data.
1360 struct _xsltStylePreComp {
1361 xsltElemPreCompPtr next; /* chained list */
1362 xsltStyleType type; /* type of the element */
1363 xsltTransformFunction func; /* handling function */
1364 xmlNodePtr inst; /* the instruction */
1367 * Pre computed values.
1370 const xmlChar *stype; /* sort */
1371 int has_stype; /* sort */
1372 int number; /* sort */
1373 const xmlChar *order; /* sort */
1374 int has_order; /* sort */
1375 int descending; /* sort */
1376 const xmlChar *lang; /* sort */
1377 int has_lang; /* sort */
1378 const xmlChar *case_order; /* sort */
1379 int lower_first; /* sort */
1381 const xmlChar *use; /* copy, element */
1382 int has_use; /* copy, element */
1384 int noescape; /* text */
1386 const xmlChar *name; /* element, attribute, pi */
1387 int has_name; /* element, attribute, pi */
1388 const xmlChar *ns; /* element */
1389 int has_ns; /* element */
1391 const xmlChar *mode; /* apply-templates */
1392 const xmlChar *modeURI; /* apply-templates */
1394 const xmlChar *test; /* if */
1396 xsltTemplatePtr templ; /* call-template */
1398 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1400 int ver11; /* document */
1401 const xmlChar *filename; /* document URL */
1402 int has_filename; /* document */
1404 xsltNumberData numdata; /* number */
1406 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1407 xmlNsPtr *nsList; /* the namespaces in scope */
1408 int nsNr; /* the number of namespaces in scope */
1411 #endif /* XSLT_REFACTORED */
1415 * The in-memory structure corresponding to an XSLT Variable
1416 * or Param.
1418 typedef struct _xsltStackElem xsltStackElem;
1419 typedef xsltStackElem *xsltStackElemPtr;
1420 struct _xsltStackElem {
1421 struct _xsltStackElem *next;/* chained list */
1422 xsltStylePreCompPtr comp; /* the compiled form */
1423 int computed; /* was the evaluation done */
1424 const xmlChar *name; /* the local part of the name QName */
1425 const xmlChar *nameURI; /* the URI part of the name QName */
1426 const xmlChar *select; /* the eval string */
1427 xmlNodePtr tree; /* the sequence constructor if no eval
1428 string or the location */
1429 xmlXPathObjectPtr value; /* The value if computed */
1430 xmlDocPtr fragment; /* The Result Tree Fragments (needed for XSLT 1.0)
1431 which are bound to the variable's lifetime. */
1432 int level; /* the depth in the tree;
1433 -1 if persistent (e.g. a given xsl:with-param) */
1434 xsltTransformContextPtr context; /* The transformation context; needed to cache
1435 the variables */
1436 int flags;
1439 #ifdef XSLT_REFACTORED
1441 struct _xsltPrincipalStylesheetData {
1443 * Namespace dictionary for ns-prefixes and ns-names:
1444 * TODO: Shared between stylesheets, and XPath mechanisms.
1445 * Not used yet.
1447 xmlDictPtr namespaceDict;
1449 * Global list of in-scope namespaces.
1451 xsltPointerListPtr inScopeNamespaces;
1453 * Global list of information for [xsl:]excluded-result-prefixes.
1455 xsltPointerListPtr exclResultNamespaces;
1457 * Global list of information for [xsl:]extension-element-prefixes.
1459 xsltPointerListPtr extElemNamespaces;
1460 xsltEffectiveNsPtr effectiveNs;
1461 #ifdef XSLT_REFACTORED_XSLT_NSCOMP
1463 * Namespace name map to get rid of string comparison of namespace names.
1465 xsltNsMapPtr nsMap;
1466 #endif
1470 #endif
1472 * Note that we added a @compCtxt field to anchor an stylesheet compilation
1473 * context, since, due to historical reasons, various compile-time function
1474 * take only the stylesheet as argument and not a compilation context.
1476 struct _xsltStylesheet {
1478 * The stylesheet import relation is kept as a tree.
1480 struct _xsltStylesheet *parent;
1481 struct _xsltStylesheet *next;
1482 struct _xsltStylesheet *imports;
1484 xsltDocumentPtr docList; /* the include document list */
1487 * General data on the style sheet document.
1489 xmlDocPtr doc; /* the parsed XML stylesheet */
1490 xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
1491 preserve space elements */
1492 int stripAll; /* strip-space * (1) preserve-space * (-1) */
1493 xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
1496 * Global variable or parameters.
1498 xsltStackElemPtr variables; /* linked list of param and variables */
1501 * Template descriptions.
1503 xsltTemplatePtr templates; /* the ordered list of templates */
1504 xmlHashTablePtr templatesHash; /* hash table or wherever compiled
1505 templates information is stored */
1506 struct _xsltCompMatch *rootMatch; /* template based on / */
1507 struct _xsltCompMatch *keyMatch; /* template based on key() */
1508 struct _xsltCompMatch *elemMatch; /* template based on * */
1509 struct _xsltCompMatch *attrMatch; /* template based on @* */
1510 struct _xsltCompMatch *parentMatch; /* template based on .. */
1511 struct _xsltCompMatch *textMatch; /* template based on text() */
1512 struct _xsltCompMatch *piMatch; /* template based on
1513 processing-instruction() */
1514 struct _xsltCompMatch *commentMatch; /* template based on comment() */
1517 * Namespace aliases.
1518 * NOTE: Not used in the refactored code.
1520 xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
1523 * Attribute sets.
1525 xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
1528 * Namespaces.
1529 * TODO: Eliminate this.
1531 xmlHashTablePtr nsHash; /* the set of namespaces in use:
1532 ATTENTION: This is used for
1533 execution of XPath expressions; unfortunately
1534 it restricts the stylesheet to have distinct
1535 prefixes.
1536 TODO: We need to get rid of this.
1538 void *nsDefs; /* ATTENTION TODO: This is currently used to store
1539 xsltExtDefPtr (in extensions.c) and
1540 *not* xmlNsPtr.
1544 * Key definitions.
1546 void *keys; /* key definitions */
1549 * Output related stuff.
1551 xmlChar *method; /* the output method */
1552 xmlChar *methodURI; /* associated namespace if any */
1553 xmlChar *version; /* version string */
1554 xmlChar *encoding; /* encoding string */
1555 int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
1558 * Number formatting.
1560 xsltDecimalFormatPtr decimalFormat;
1561 int standalone; /* standalone = "yes" | "no" */
1562 xmlChar *doctypePublic; /* doctype-public string */
1563 xmlChar *doctypeSystem; /* doctype-system string */
1564 int indent; /* should output being indented */
1565 xmlChar *mediaType; /* media-type string */
1568 * Precomputed blocks.
1570 xsltElemPreCompPtr preComps;/* list of precomputed blocks */
1571 int warnings; /* number of warnings found at compilation */
1572 int errors; /* number of errors found at compilation */
1574 xmlChar *exclPrefix; /* last excluded prefixes */
1575 xmlChar **exclPrefixTab; /* array of excluded prefixes */
1576 int exclPrefixNr; /* number of excluded prefixes in scope */
1577 int exclPrefixMax; /* size of the array */
1579 void *_private; /* user defined data */
1582 * Extensions.
1584 xmlHashTablePtr extInfos; /* the extension data */
1585 int extrasNr; /* the number of extras required */
1588 * For keeping track of nested includes
1590 xsltDocumentPtr includes; /* points to last nested include */
1593 * dictionary: shared between stylesheet, context and documents.
1595 xmlDictPtr dict;
1597 * precompiled attribute value templates.
1599 void *attVTs;
1601 * if namespace-alias has an alias for the default stylesheet prefix
1602 * NOTE: Not used in the refactored code.
1604 const xmlChar *defaultAlias;
1606 * bypass pre-processing (already done) (used in imports)
1608 int nopreproc;
1610 * all document text strings were internalized
1612 int internalized;
1614 * Literal Result Element as Stylesheet c.f. section 2.3
1616 int literal_result;
1618 * The principal stylesheet
1620 xsltStylesheetPtr principal;
1621 #ifdef XSLT_REFACTORED
1623 * Compilation context used during compile-time.
1625 xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
1627 xsltPrincipalStylesheetDataPtr principalData;
1628 #endif
1630 * Forwards-compatible processing
1632 int forwards_compatible;
1634 xmlHashTablePtr namedTemplates; /* hash table of named templates */
1636 xmlXPathContextPtr xpathCtxt;
1639 typedef struct _xsltTransformCache xsltTransformCache;
1640 typedef xsltTransformCache *xsltTransformCachePtr;
1641 struct _xsltTransformCache {
1642 xmlDocPtr RVT;
1643 int nbRVT;
1644 xsltStackElemPtr stackItems;
1645 int nbStackItems;
1646 #ifdef XSLT_DEBUG_PROFILE_CACHE
1647 int dbgCachedRVTs;
1648 int dbgReusedRVTs;
1649 int dbgCachedVars;
1650 int dbgReusedVars;
1651 #endif
1655 * The in-memory structure corresponding to an XSLT Transformation.
1657 typedef enum {
1658 XSLT_OUTPUT_XML = 0,
1659 XSLT_OUTPUT_HTML,
1660 XSLT_OUTPUT_TEXT
1661 } xsltOutputType;
1663 typedef void *
1664 (*xsltNewLocaleFunc)(const xmlChar *lang, int lowerFirst);
1665 typedef void
1666 (*xsltFreeLocaleFunc)(void *locale);
1667 typedef xmlChar *
1668 (*xsltGenSortKeyFunc)(void *locale, const xmlChar *lang);
1670 typedef enum {
1671 XSLT_STATE_OK = 0,
1672 XSLT_STATE_ERROR,
1673 XSLT_STATE_STOPPED
1674 } xsltTransformState;
1676 struct _xsltTransformContext {
1677 xsltStylesheetPtr style; /* the stylesheet used */
1678 xsltOutputType type; /* the type of output */
1680 xsltTemplatePtr templ; /* the current template */
1681 int templNr; /* Nb of templates in the stack */
1682 int templMax; /* Size of the templtes stack */
1683 xsltTemplatePtr *templTab; /* the template stack */
1685 xsltStackElemPtr vars; /* the current variable list */
1686 int varsNr; /* Nb of variable list in the stack */
1687 int varsMax; /* Size of the variable list stack */
1688 xsltStackElemPtr *varsTab; /* the variable list stack */
1689 int varsBase; /* the var base for current templ */
1692 * Extensions
1694 xmlHashTablePtr extFunctions; /* the extension functions */
1695 xmlHashTablePtr extElements; /* the extension elements */
1696 xmlHashTablePtr extInfos; /* the extension data */
1698 const xmlChar *mode; /* the current mode */
1699 const xmlChar *modeURI; /* the current mode URI */
1701 xsltDocumentPtr docList; /* the document list */
1703 xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */
1704 xmlNodePtr node; /* the current node being processed */
1705 xmlNodeSetPtr nodeList; /* the current node list */
1706 /* xmlNodePtr current; the node */
1708 xmlDocPtr output; /* the resulting document */
1709 xmlNodePtr insert; /* the insertion node */
1711 xmlXPathContextPtr xpathCtxt; /* the XPath context */
1712 xsltTransformState state; /* the current state */
1715 * Global variables
1717 xmlHashTablePtr globalVars; /* the global variables and params */
1719 xmlNodePtr inst; /* the instruction in the stylesheet */
1721 int xinclude; /* should XInclude be processed */
1723 const char * outputFile; /* the output URI if known */
1725 int profile; /* is this run profiled */
1726 long prof; /* the current profiled value */
1727 int profNr; /* Nb of templates in the stack */
1728 int profMax; /* Size of the templtaes stack */
1729 long *profTab; /* the profile template stack */
1731 void *_private; /* user defined data */
1733 int extrasNr; /* the number of extras used */
1734 int extrasMax; /* the number of extras allocated */
1735 xsltRuntimeExtraPtr extras; /* extra per runtime information */
1737 xsltDocumentPtr styleList; /* the stylesheet docs list */
1738 void * sec; /* the security preferences if any */
1740 xmlGenericErrorFunc error; /* a specific error handler */
1741 void * errctx; /* context for the error handler */
1743 xsltSortFunc sortfunc; /* a ctxt specific sort routine */
1746 * handling of temporary Result Value Tree
1747 * (XSLT 1.0 term: "Result Tree Fragment")
1749 xmlDocPtr tmpRVT; /* list of RVT without persistance */
1750 xmlDocPtr persistRVT; /* list of persistant RVTs */
1751 int ctxtflags; /* context processing flags */
1754 * Speed optimization when coalescing text nodes
1756 const xmlChar *lasttext; /* last text node content */
1757 int lasttsize; /* last text node size */
1758 int lasttuse; /* last text node use */
1760 * Per Context Debugging
1762 int debugStatus; /* the context level debug status */
1763 unsigned long* traceCode; /* pointer to the variable holding the mask */
1765 int parserOptions; /* parser options xmlParserOption */
1768 * dictionary: shared between stylesheet, context and documents.
1770 xmlDictPtr dict;
1771 xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */
1773 * all document text strings are internalized
1775 int internalized;
1776 int nbKeys;
1777 int hasTemplKeyPatterns;
1778 xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
1779 xmlNodePtr initialContextNode;
1780 xmlDocPtr initialContextDoc;
1781 xsltTransformCachePtr cache;
1782 void *contextVariable; /* the current variable item */
1783 xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
1784 the instruction which created the fragment
1785 exits */
1786 xmlDocPtr localRVTBase; /* Obsolete */
1787 int keyInitLevel; /* Needed to catch recursive keys issues */
1788 int depth; /* Needed to catch recursions */
1789 int maxTemplateDepth;
1790 int maxTemplateVars;
1791 unsigned long opLimit;
1792 unsigned long opCount;
1793 int sourceDocDirty;
1794 unsigned long currentId; /* For generate-id() */
1796 xsltNewLocaleFunc newLocale;
1797 xsltFreeLocaleFunc freeLocale;
1798 xsltGenSortKeyFunc genSortKey;
1802 * CHECK_STOPPED:
1804 * Macro to check if the XSLT processing should be stopped.
1805 * Will return from the function.
1807 #define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
1810 * CHECK_STOPPEDE:
1812 * Macro to check if the XSLT processing should be stopped.
1813 * Will goto the error: label.
1815 #define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
1818 * CHECK_STOPPED0:
1820 * Macro to check if the XSLT processing should be stopped.
1821 * Will return from the function with a 0 value.
1823 #define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
1826 * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
1827 * possible incompatibilities between function pointers and object
1828 * pointers. It is defined in libxml/hash.h within recent versions
1829 * of libxml2, but is put here for compatibility.
1831 #ifndef XML_CAST_FPTR
1833 * XML_CAST_FPTR:
1834 * @fptr: pointer to a function
1836 * Macro to do a casting from an object pointer to a
1837 * function pointer without encountering a warning from
1838 * gcc
1840 * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
1841 * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
1842 * so it is disabled now
1845 #define XML_CAST_FPTR(fptr) fptr
1846 #endif
1848 * Functions associated to the internal types
1849 xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
1850 xmlChar *name);
1852 XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1853 xsltNewStylesheet (void);
1854 XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1855 xsltParseStylesheetFile (const xmlChar* filename);
1856 XSLTPUBFUN void XSLTCALL
1857 xsltFreeStylesheet (xsltStylesheetPtr style);
1858 XSLTPUBFUN int XSLTCALL
1859 xsltIsBlank (xmlChar *str);
1860 XSLTPUBFUN void XSLTCALL
1861 xsltFreeStackElemList (xsltStackElemPtr elem);
1862 XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
1863 xsltDecimalFormatGetByName(xsltStylesheetPtr style,
1864 xmlChar *name);
1865 XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
1866 xsltDecimalFormatGetByQName(xsltStylesheetPtr style,
1867 const xmlChar *nsUri,
1868 const xmlChar *name);
1870 XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1871 xsltParseStylesheetProcess(xsltStylesheetPtr ret,
1872 xmlDocPtr doc);
1873 XSLTPUBFUN void XSLTCALL
1874 xsltParseStylesheetOutput(xsltStylesheetPtr style,
1875 xmlNodePtr cur);
1876 XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1877 xsltParseStylesheetDoc (xmlDocPtr doc);
1878 XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1879 xsltParseStylesheetImportedDoc(xmlDocPtr doc,
1880 xsltStylesheetPtr style);
1881 XSLTPUBFUN int XSLTCALL
1882 xsltParseStylesheetUser(xsltStylesheetPtr style,
1883 xmlDocPtr doc);
1884 XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1885 xsltLoadStylesheetPI (xmlDocPtr doc);
1886 XSLTPUBFUN void XSLTCALL
1887 xsltNumberFormat (xsltTransformContextPtr ctxt,
1888 xsltNumberDataPtr data,
1889 xmlNodePtr node);
1890 XSLTPUBFUN xmlXPathError XSLTCALL
1891 xsltFormatNumberConversion(xsltDecimalFormatPtr self,
1892 xmlChar *format,
1893 double number,
1894 xmlChar **result);
1896 XSLTPUBFUN void XSLTCALL
1897 xsltParseTemplateContent(xsltStylesheetPtr style,
1898 xmlNodePtr templ);
1899 XSLTPUBFUN int XSLTCALL
1900 xsltAllocateExtra (xsltStylesheetPtr style);
1901 XSLTPUBFUN int XSLTCALL
1902 xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);
1904 * Extra functions for Result Value Trees
1906 XSLTPUBFUN xmlDocPtr XSLTCALL
1907 xsltCreateRVT (xsltTransformContextPtr ctxt);
1908 XSLTPUBFUN int XSLTCALL
1909 xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,
1910 xmlDocPtr RVT);
1911 XSLTPUBFUN int XSLTCALL
1912 xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,
1913 xmlDocPtr RVT);
1914 XSLTPUBFUN int XSLTCALL
1915 xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,
1916 xmlDocPtr RVT);
1917 XSLTPUBFUN int XSLTCALL
1918 xsltExtensionInstructionResultRegister(
1919 xsltTransformContextPtr ctxt,
1920 xmlXPathObjectPtr obj);
1921 XSLTPUBFUN int XSLTCALL
1922 xsltExtensionInstructionResultFinalize(
1923 xsltTransformContextPtr ctxt);
1924 XSLTPUBFUN int XSLTCALL
1925 xsltFlagRVTs(
1926 xsltTransformContextPtr ctxt,
1927 xmlXPathObjectPtr obj,
1928 int val);
1929 XSLTPUBFUN void XSLTCALL
1930 xsltFreeRVTs (xsltTransformContextPtr ctxt);
1931 XSLTPUBFUN void XSLTCALL
1932 xsltReleaseRVT (xsltTransformContextPtr ctxt,
1933 xmlDocPtr RVT);
1935 * Extra functions for Attribute Value Templates
1937 XSLTPUBFUN void XSLTCALL
1938 xsltCompileAttr (xsltStylesheetPtr style,
1939 xmlAttrPtr attr);
1940 XSLTPUBFUN xmlChar * XSLTCALL
1941 xsltEvalAVT (xsltTransformContextPtr ctxt,
1942 void *avt,
1943 xmlNodePtr node);
1944 XSLTPUBFUN void XSLTCALL
1945 xsltFreeAVTList (void *avt);
1948 * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
1951 XSLTPUBFUN void XSLTCALL
1952 xsltUninit (void);
1954 /************************************************************************
1956 * Compile-time functions for *internal* use only *
1958 ************************************************************************/
1960 #ifdef XSLT_REFACTORED
1961 XSLTPUBFUN void XSLTCALL
1962 xsltParseSequenceConstructor(
1963 xsltCompilerCtxtPtr cctxt,
1964 xmlNodePtr start);
1965 XSLTPUBFUN int XSLTCALL
1966 xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,
1967 xmlNodePtr elem);
1968 #ifdef XSLT_REFACTORED_XSLT_NSCOMP
1969 XSLTPUBFUN int XSLTCALL
1970 xsltRestoreDocumentNamespaces(
1971 xsltNsMapPtr ns,
1972 xmlDocPtr doc);
1973 #endif
1974 #endif /* XSLT_REFACTORED */
1976 /************************************************************************
1978 * Transformation-time functions for *internal* use only *
1980 ************************************************************************/
1981 XSLTPUBFUN int XSLTCALL
1982 xsltInitCtxtKey (xsltTransformContextPtr ctxt,
1983 xsltDocumentPtr doc,
1984 xsltKeyDefPtr keyd);
1985 XSLTPUBFUN int XSLTCALL
1986 xsltInitAllDocKeys (xsltTransformContextPtr ctxt);
1987 #ifdef __cplusplus
1989 #endif
1991 #endif /* __XML_XSLT_H__ */