VirtualBox

source: vbox/trunk/src/libs/libxslt-1.1.22/libxslt/xsltInternals.h@ 24345

Last change on this file since 24345 was 7296, checked in by vboxsync, 17 years ago

Added libxslt-1.1.22 sources.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 55.5 KB
Line 
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.
7 *
8 * Copy: See Copyright for the status of this software.
9 *
10 * Author: Daniel Veillard
11 */
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 __cplusplus
27extern "C" {
28#endif
29
30/* #define XSLT_DEBUG_PROFILE_CACHE */
31
32/**
33 * XSLT_IS_TEXT_NODE:
34 *
35 * check if the argument is a text node
36 */
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 fragments
46 */
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 fragments
54 */
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 */
64#define XSLT_REFACTORED_KEYCOMP
65
66/**
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_IF
73
74/**
75 * XSLT_REFACTORED:
76 *
77 * Internal define to enable the refactored parts of Libxslt.
78 */
79/* #define XSLT_REFACTORED */
80/* ==================================================================== */
81
82/**
83 * XSLT_REFACTORED_VARS:
84 *
85 * Internal define to enable the refactored variable part of libxslt
86 */
87#define XSLT_REFACTORED_VARS
88
89#ifdef XSLT_REFACTORED
90
91extern const xmlChar *xsltXSLTAttrMarker;
92
93
94/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
95
96/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
97
98/**
99 * XSLT_REFACTORED_XSLT_NSCOMP
100 *
101 * Internal define to enable the pointer-comparison of
102 * namespaces of XSLT elements.
103 */
104/* #define XSLT_REFACTORED_XSLT_NSCOMP */
105
106/**
107 * XSLT_REFACTORED_XPATHCOMP:
108 *
109 * Internal define to enable the optimization of the
110 * compilation of XPath expressions.
111 */
112#define XSLT_REFACTORED_XPATHCOMP
113
114#ifdef XSLT_REFACTORED_XSLT_NSCOMP
115
116extern const xmlChar *xsltConstNamespaceNameXSLT;
117
118/**
119 * IS_XSLT_ELEM_FAST:
120 *
121 * quick test to detect XSLT elements
122 */
123#define IS_XSLT_ELEM_FAST(n) \
124 (((n) != NULL) && ((n)->ns != NULL) && \
125 ((n)->ns->href == xsltConstNamespaceNameXSLT))
126
127/**
128 * IS_XSLT_ATTR_FAST:
129 *
130 * quick test to detect XSLT attributes
131 */
132#define IS_XSLT_ATTR_FAST(a) \
133 (((a) != NULL) && ((a)->ns != NULL) && \
134 ((a)->ns->href == xsltConstNamespaceNameXSLT))
135
136/**
137 * XSLT_HAS_INTERNAL_NSMAP:
138 *
139 * check for namespace mapping
140 */
141#define XSLT_HAS_INTERNAL_NSMAP(s) \
142 (((s) != NULL) && ((s)->principal) && \
143 ((s)->principal->principalData) && \
144 ((s)->principal->principalData->nsMap))
145
146/**
147 * XSLT_GET_INTERNAL_NSMAP:
148 *
149 * get pointer to namespace map
150 */
151#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
152
153#else /* XSLT_REFACTORED_XSLT_NSCOMP */
154
155/**
156 * IS_XSLT_ELEM_FAST:
157 *
158 * quick check whether this is an xslt element
159 */
160#define IS_XSLT_ELEM_FAST(n) \
161 (((n) != NULL) && ((n)->ns != NULL) && \
162 (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
163
164/**
165 * IS_XSLT_ATTR_FAST:
166 *
167 * quick check for xslt namespace attribute
168 */
169#define IS_XSLT_ATTR_FAST(a) \
170 (((a) != NULL) && ((a)->ns != NULL) && \
171 (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
172
173
174#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
175
176
177/**
178 * XSLT_REFACTORED_MANDATORY_VERSION:
179 *
180 * TODO: Currently disabled to surpress regression test failures, since
181 * the old behaviour was that a missing version attribute
182 * produced a only a warning and not an error, which was incerrect.
183 * So the regression tests need to be fixed if this is enabled.
184 */
185/* #define XSLT_REFACTORED_MANDATORY_VERSION */
186
187/**
188 * xsltPointerList:
189 *
190 * Pointer-list for various purposes.
191 */
192typedef struct _xsltPointerList xsltPointerList;
193typedef xsltPointerList *xsltPointerListPtr;
194struct _xsltPointerList {
195 void **items;
196 int number;
197 int size;
198};
199
200#endif
201
202/**
203 * XSLT_REFACTORED_PARSING:
204 *
205 * Internal define to enable the refactored parts of Libxslt
206 * related to parsing.
207 */
208/* #define XSLT_REFACTORED_PARSING */
209
210/**
211 * XSLT_MAX_SORT:
212 *
213 * Max number of specified xsl:sort on an element.
214 */
215#define XSLT_MAX_SORT 15
216
217/**
218 * XSLT_PAT_NO_PRIORITY:
219 *
220 * Specific value for pattern without priority expressed.
221 */
222#define XSLT_PAT_NO_PRIORITY -12345789
223
224/**
225 * xsltRuntimeExtra:
226 *
227 * Extra information added to the transformation context.
228 */
229typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
230typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
231struct _xsltRuntimeExtra {
232 void *info; /* pointer to the extra data */
233 xmlFreeFunc deallocate; /* pointer to the deallocation routine */
234 union { /* dual-purpose field */
235 void *ptr; /* data not needing deallocation */
236 int ival; /* integer value storage */
237 } val;
238};
239
240/**
241 * XSLT_RUNTIME_EXTRA_LST:
242 * @ctxt: the transformation context
243 * @nr: the index
244 *
245 * Macro used to access extra information stored in the context
246 */
247#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
248/**
249 * XSLT_RUNTIME_EXTRA_FREE:
250 * @ctxt: the transformation context
251 * @nr: the index
252 *
253 * Macro used to free extra information stored in the context
254 */
255#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
256/**
257 * XSLT_RUNTIME_EXTRA:
258 * @ctxt: the transformation context
259 * @nr: the index
260 *
261 * Macro used to define extra information stored in the context
262 */
263#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
264
265/**
266 * xsltTemplate:
267 *
268 * The in-memory structure corresponding to an XSLT Template.
269 */
270typedef struct _xsltTemplate xsltTemplate;
271typedef xsltTemplate *xsltTemplatePtr;
272struct _xsltTemplate {
273 struct _xsltTemplate *next;/* chained list sorted by priority */
274 struct _xsltStylesheet *style;/* the containing stylesheet */
275 xmlChar *match; /* the matching string */
276 float priority; /* as given from the stylesheet, not computed */
277 const xmlChar *name; /* the local part of the name QName */
278 const xmlChar *nameURI; /* the URI part of the name QName */
279 const xmlChar *mode;/* the local part of the mode QName */
280 const xmlChar *modeURI;/* the URI part of the mode QName */
281 xmlNodePtr content; /* the template replacement value */
282 xmlNodePtr elem; /* the source element */
283
284 /*
285 * TODO: @inheritedNsNr and @inheritedNs won't be used in the
286 * refactored code.
287 */
288 int inheritedNsNr; /* number of inherited namespaces */
289 xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
290
291 /* Profiling informations */
292 int nbCalls; /* the number of time the template was called */
293 unsigned long time; /* the time spent in this template */
294 void *params; /* xsl:param instructions */
295};
296
297/**
298 * xsltDecimalFormat:
299 *
300 * Data structure of decimal-format.
301 */
302typedef struct _xsltDecimalFormat xsltDecimalFormat;
303typedef xsltDecimalFormat *xsltDecimalFormatPtr;
304struct _xsltDecimalFormat {
305 struct _xsltDecimalFormat *next; /* chained list */
306 xmlChar *name;
307 /* Used for interpretation of pattern */
308 xmlChar *digit;
309 xmlChar *patternSeparator;
310 /* May appear in result */
311 xmlChar *minusSign;
312 xmlChar *infinity;
313 xmlChar *noNumber; /* Not-a-number */
314 /* Used for interpretation of pattern and may appear in result */
315 xmlChar *decimalPoint;
316 xmlChar *grouping;
317 xmlChar *percent;
318 xmlChar *permille;
319 xmlChar *zeroDigit;
320};
321
322/**
323 * xsltDocument:
324 *
325 * Data structure associated to a parsed document.
326 */
327typedef struct _xsltDocument xsltDocument;
328typedef xsltDocument *xsltDocumentPtr;
329struct _xsltDocument {
330 struct _xsltDocument *next; /* documents are kept in a chained list */
331 int main; /* is this the main document */
332 xmlDocPtr doc; /* the parsed document */
333 void *keys; /* key tables storage */
334 struct _xsltDocument *includes; /* subsidiary includes */
335 int preproc; /* pre-processing already done */
336 int nbKeysComputed;
337};
338
339/**
340 * xsltKeyDef:
341 *
342 * Representation of an xsl:key.
343 */
344typedef struct _xsltKeyDef xsltKeyDef;
345typedef xsltKeyDef *xsltKeyDefPtr;
346struct _xsltKeyDef {
347 struct _xsltKeyDef *next;
348 xmlNodePtr inst;
349 xmlChar *name;
350 xmlChar *nameURI;
351 xmlChar *match;
352 xmlChar *use;
353 xmlXPathCompExprPtr comp;
354 xmlXPathCompExprPtr usecomp;
355 xmlNsPtr *nsList; /* the namespaces in scope */
356 int nsNr; /* the number of namespaces in scope */
357};
358
359/**
360 * xsltKeyTable:
361 *
362 * Holds the computed keys for key definitions of the same QName.
363 * Is owned by an xsltDocument.
364 */
365typedef struct _xsltKeyTable xsltKeyTable;
366typedef xsltKeyTable *xsltKeyTablePtr;
367struct _xsltKeyTable {
368 struct _xsltKeyTable *next;
369 xmlChar *name;
370 xmlChar *nameURI;
371 xmlHashTablePtr keys;
372};
373
374/*
375 * The in-memory structure corresponding to an XSLT Stylesheet.
376 * NOTE: most of the content is simply linked from the doc tree
377 * structure, no specific allocation is made.
378 */
379typedef struct _xsltStylesheet xsltStylesheet;
380typedef xsltStylesheet *xsltStylesheetPtr;
381
382typedef struct _xsltTransformContext xsltTransformContext;
383typedef xsltTransformContext *xsltTransformContextPtr;
384
385/**
386 * xsltElemPreComp:
387 *
388 * The in-memory structure corresponding to element precomputed data,
389 * designed to be extended by extension implementors.
390 */
391typedef struct _xsltElemPreComp xsltElemPreComp;
392typedef xsltElemPreComp *xsltElemPreCompPtr;
393
394/**
395 * xsltTransformFunction:
396 * @ctxt: the XSLT transformation context
397 * @node: the input node
398 * @inst: the stylesheet node
399 * @comp: the compiled information from the stylesheet
400 *
401 * Signature of the function associated to elements part of the
402 * stylesheet language like xsl:if or xsl:apply-templates.
403 */
404typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
405 xmlNodePtr node,
406 xmlNodePtr inst,
407 xsltElemPreCompPtr comp);
408
409/**
410 * xsltSortFunc:
411 * @ctxt: a transformation context
412 * @sorts: the node-set to sort
413 * @nbsorts: the number of sorts
414 *
415 * Signature of the function to use during sorting
416 */
417typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
418 int nbsorts);
419
420typedef enum {
421 XSLT_FUNC_COPY=1,
422 XSLT_FUNC_SORT,
423 XSLT_FUNC_TEXT,
424 XSLT_FUNC_ELEMENT,
425 XSLT_FUNC_ATTRIBUTE,
426 XSLT_FUNC_COMMENT,
427 XSLT_FUNC_PI,
428 XSLT_FUNC_COPYOF,
429 XSLT_FUNC_VALUEOF,
430 XSLT_FUNC_NUMBER,
431 XSLT_FUNC_APPLYIMPORTS,
432 XSLT_FUNC_CALLTEMPLATE,
433 XSLT_FUNC_APPLYTEMPLATES,
434 XSLT_FUNC_CHOOSE,
435 XSLT_FUNC_IF,
436 XSLT_FUNC_FOREACH,
437 XSLT_FUNC_DOCUMENT,
438 XSLT_FUNC_WITHPARAM,
439 XSLT_FUNC_PARAM,
440 XSLT_FUNC_VARIABLE,
441 XSLT_FUNC_WHEN,
442 XSLT_FUNC_EXTENSION
443#ifdef XSLT_REFACTORED
444 ,
445 XSLT_FUNC_OTHERWISE,
446 XSLT_FUNC_FALLBACK,
447 XSLT_FUNC_MESSAGE,
448 XSLT_FUNC_INCLUDE,
449 XSLT_FUNC_ATTRSET,
450 XSLT_FUNC_LITERAL_RESULT_ELEMENT,
451 XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
452#endif
453} xsltStyleType;
454
455/**
456 * xsltElemPreCompDeallocator:
457 * @comp: the #xsltElemPreComp to free up
458 *
459 * Deallocates an #xsltElemPreComp structure.
460 */
461typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
462
463/**
464 * xsltElemPreComp:
465 *
466 * The basic structure for compiled items of the AST of the XSLT processor.
467 * This structure is also intended to be extended by extension implementors.
468 * TODO: This is somehow not nice, since it has a "free" field, which
469 * derived stylesheet-structs do not have.
470 */
471struct _xsltElemPreComp {
472 xsltElemPreCompPtr next; /* next item in the global chained
473 list hold by xsltStylesheet. */
474 xsltStyleType type; /* type of the element */
475 xsltTransformFunction func; /* handling function */
476 xmlNodePtr inst; /* the node in the stylesheet's tree
477 corresponding to this item */
478
479 /* end of common part */
480 xsltElemPreCompDeallocator free; /* the deallocator */
481};
482
483/**
484 * xsltStylePreComp:
485 *
486 * The abstract basic structure for items of the XSLT processor.
487 * This includes:
488 * 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
489 * 2) compiled forms of literal result elements
490 * 3) compiled forms of extension elements
491 */
492typedef struct _xsltStylePreComp xsltStylePreComp;
493typedef xsltStylePreComp *xsltStylePreCompPtr;
494
495#ifdef XSLT_REFACTORED
496
497/*
498* Some pointer-list utility functions.
499*/
500XSLTPUBFUN xsltPointerListPtr XSLTCALL
501 xsltPointerListCreate (int initialSize);
502XSLTPUBFUN void XSLTCALL
503 xsltPointerListFree (xsltPointerListPtr list);
504XSLTPUBFUN void XSLTCALL
505 xsltPointerListClear (xsltPointerListPtr list);
506XSLTPUBFUN int XSLTCALL
507 xsltPointerListAddSize (xsltPointerListPtr list,
508 void *item,
509 int initialSize);
510
511/************************************************************************
512 * *
513 * Refactored structures *
514 * *
515 ************************************************************************/
516
517typedef struct _xsltNsListContainer xsltNsListContainer;
518typedef xsltNsListContainer *xsltNsListContainerPtr;
519struct _xsltNsListContainer {
520 xmlNsPtr *list;
521 int totalNumber;
522 int xpathNumber;
523};
524
525/**
526 * XSLT_ITEM_COMPATIBILITY_FIELDS:
527 *
528 * Fields for API compatibility to the structure
529 * _xsltElemPreComp which is used for extension functions.
530 * Note that @next is used for storage; it does not reflect a next
531 * sibling in the tree.
532 * TODO: Evaluate if we really need such a compatibility.
533 */
534#define XSLT_ITEM_COMPATIBILITY_FIELDS \
535 xsltElemPreCompPtr next;\
536 xsltStyleType type;\
537 xsltTransformFunction func;\
538 xmlNodePtr inst;
539
540/**
541 * XSLT_ITEM_NAVIGATION_FIELDS:
542 *
543 * Currently empty.
544 * TODO: It is intended to hold navigational fields in the future.
545 */
546#define XSLT_ITEM_NAVIGATION_FIELDS
547/*
548 xsltStylePreCompPtr parent;\
549 xsltStylePreCompPtr children;\
550 xsltStylePreCompPtr nextItem;
551*/
552
553/**
554 * XSLT_ITEM_NSINSCOPE_FIELDS:
555 *
556 * The in-scope namespaces.
557 */
558#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
559
560/**
561 * XSLT_ITEM_COMMON_FIELDS:
562 *
563 * Common fields used for all items.
564 */
565#define XSLT_ITEM_COMMON_FIELDS \
566 XSLT_ITEM_COMPATIBILITY_FIELDS \
567 XSLT_ITEM_NAVIGATION_FIELDS \
568 XSLT_ITEM_NSINSCOPE_FIELDS
569
570/**
571 * _xsltStylePreComp:
572 *
573 * The abstract basic structure for items of the XSLT processor.
574 * This includes:
575 * 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)
576 * 2) compiled forms of literal result elements
577 * 3) various properties for XSLT instructions (e.g. xsl:when,
578 * xsl:with-param)
579 *
580 * REVISIT TODO: Keep this structure equal to the fields
581 * defined by XSLT_ITEM_COMMON_FIELDS
582 */
583struct _xsltStylePreComp {
584 xsltElemPreCompPtr next; /* next item in the global chained
585 list hold by xsltStylesheet */
586 xsltStyleType type; /* type of the item */
587 xsltTransformFunction func; /* handling function */
588 xmlNodePtr inst; /* the node in the stylesheet's tree
589 corresponding to this item. */
590 /* Currently no navigational fields. */
591 xsltNsListContainerPtr inScopeNs;
592};
593
594/**
595 * xsltStyleBasicEmptyItem:
596 *
597 * Abstract structure only used as a short-cut for
598 * XSLT items with no extra fields.
599 * NOTE that it is intended that this structure looks the same as
600 * _xsltStylePreComp.
601 */
602typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
603typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
604
605struct _xsltStyleBasicEmptyItem {
606 XSLT_ITEM_COMMON_FIELDS
607};
608
609/**
610 * xsltStyleBasicExpressionItem:
611 *
612 * Abstract structure only used as a short-cut for
613 * XSLT items with just an expression.
614 */
615typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
616typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
617
618struct _xsltStyleBasicExpressionItem {
619 XSLT_ITEM_COMMON_FIELDS
620
621 const xmlChar *select; /* TODO: Change this to "expression". */
622 xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
623};
624
625/************************************************************************
626 * *
627 * XSLT-instructions/declarations *
628 * *
629 ************************************************************************/
630
631/**
632 * xsltStyleItemElement:
633 *
634 * <!-- Category: instruction -->
635 * <xsl:element
636 * name = { qname }
637 * namespace = { uri-reference }
638 * use-attribute-sets = qnames>
639 * <!-- Content: template -->
640 * </xsl:element>
641 */
642typedef struct _xsltStyleItemElement xsltStyleItemElement;
643typedef xsltStyleItemElement *xsltStyleItemElementPtr;
644
645struct _xsltStyleItemElement {
646 XSLT_ITEM_COMMON_FIELDS
647
648 const xmlChar *use;
649 int has_use;
650 const xmlChar *name;
651 int has_name;
652 const xmlChar *ns;
653 const xmlChar *nsPrefix;
654 int has_ns;
655};
656
657/**
658 * xsltStyleItemAttribute:
659 *
660 * <!-- Category: instruction -->
661 * <xsl:attribute
662 * name = { qname }
663 * namespace = { uri-reference }>
664 * <!-- Content: template -->
665 * </xsl:attribute>
666 */
667typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
668typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
669
670struct _xsltStyleItemAttribute {
671 XSLT_ITEM_COMMON_FIELDS
672 const xmlChar *name;
673 int has_name;
674 const xmlChar *ns;
675 const xmlChar *nsPrefix;
676 int has_ns;
677};
678
679/**
680 * xsltStyleItemText:
681 *
682 * <!-- Category: instruction -->
683 * <xsl:text
684 * disable-output-escaping = "yes" | "no">
685 * <!-- Content: #PCDATA -->
686 * </xsl:text>
687 */
688typedef struct _xsltStyleItemText xsltStyleItemText;
689typedef xsltStyleItemText *xsltStyleItemTextPtr;
690
691struct _xsltStyleItemText {
692 XSLT_ITEM_COMMON_FIELDS
693 int noescape; /* text */
694};
695
696/**
697 * xsltStyleItemComment:
698 *
699 * <!-- Category: instruction -->
700 * <xsl:comment>
701 * <!-- Content: template -->
702 * </xsl:comment>
703 */
704typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
705typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
706
707/**
708 * xsltStyleItemPI:
709 *
710 * <!-- Category: instruction -->
711 * <xsl:processing-instruction
712 * name = { ncname }>
713 * <!-- Content: template -->
714 * </xsl:processing-instruction>
715 */
716typedef struct _xsltStyleItemPI xsltStyleItemPI;
717typedef xsltStyleItemPI *xsltStyleItemPIPtr;
718
719struct _xsltStyleItemPI {
720 XSLT_ITEM_COMMON_FIELDS
721 const xmlChar *name;
722 int has_name;
723};
724
725/**
726 * xsltStyleItemApplyImports:
727 *
728 * <!-- Category: instruction -->
729 * <xsl:apply-imports />
730 */
731typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
732typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
733
734/**
735 * xsltStyleItemApplyTemplates:
736 *
737 * <!-- Category: instruction -->
738 * <xsl:apply-templates
739 * select = node-set-expression
740 * mode = qname>
741 * <!-- Content: (xsl:sort | xsl:with-param)* -->
742 * </xsl:apply-templates>
743 */
744typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
745typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
746
747struct _xsltStyleItemApplyTemplates {
748 XSLT_ITEM_COMMON_FIELDS
749
750 const xmlChar *mode; /* apply-templates */
751 const xmlChar *modeURI; /* apply-templates */
752 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
753 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
754 /* TODO: with-params */
755};
756
757/**
758 * xsltStyleItemCallTemplate:
759 *
760 * <!-- Category: instruction -->
761 * <xsl:call-template
762 * name = qname>
763 * <!-- Content: xsl:with-param* -->
764 * </xsl:call-template>
765 */
766typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
767typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
768
769struct _xsltStyleItemCallTemplate {
770 XSLT_ITEM_COMMON_FIELDS
771
772 xsltTemplatePtr templ; /* call-template */
773 const xmlChar *name; /* element, attribute, pi */
774 int has_name; /* element, attribute, pi */
775 const xmlChar *ns; /* element */
776 int has_ns; /* element */
777 /* TODO: with-params */
778};
779
780/**
781 * xsltStyleItemCopy:
782 *
783 * <!-- Category: instruction -->
784 * <xsl:copy
785 * use-attribute-sets = qnames>
786 * <!-- Content: template -->
787 * </xsl:copy>
788 */
789typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
790typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
791
792struct _xsltStyleItemCopy {
793 XSLT_ITEM_COMMON_FIELDS
794 const xmlChar *use; /* copy, element */
795 int has_use; /* copy, element */
796};
797
798/**
799 * xsltStyleItemIf:
800 *
801 * <!-- Category: instruction -->
802 * <xsl:if
803 * test = boolean-expression>
804 * <!-- Content: template -->
805 * </xsl:if>
806 */
807typedef struct _xsltStyleItemIf xsltStyleItemIf;
808typedef xsltStyleItemIf *xsltStyleItemIfPtr;
809
810struct _xsltStyleItemIf {
811 XSLT_ITEM_COMMON_FIELDS
812
813 const xmlChar *test; /* if */
814 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
815};
816
817
818/**
819 * xsltStyleItemCopyOf:
820 *
821 * <!-- Category: instruction -->
822 * <xsl:copy-of
823 * select = expression />
824 */
825typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
826typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
827
828/**
829 * xsltStyleItemValueOf:
830 *
831 * <!-- Category: instruction -->
832 * <xsl:value-of
833 * select = string-expression
834 * disable-output-escaping = "yes" | "no" />
835 */
836typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
837typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
838
839struct _xsltStyleItemValueOf {
840 XSLT_ITEM_COMMON_FIELDS
841
842 const xmlChar *select;
843 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
844 int noescape;
845};
846
847/**
848 * xsltStyleItemNumber:
849 *
850 * <!-- Category: instruction -->
851 * <xsl:number
852 * level = "single" | "multiple" | "any"
853 * count = pattern
854 * from = pattern
855 * value = number-expression
856 * format = { string }
857 * lang = { nmtoken }
858 * letter-value = { "alphabetic" | "traditional" }
859 * grouping-separator = { char }
860 * grouping-size = { number } />
861 */
862typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
863typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
864
865struct _xsltStyleItemNumber {
866 XSLT_ITEM_COMMON_FIELDS
867 xsltNumberData numdata; /* number */
868};
869
870/**
871 * xsltStyleItemChoose:
872 *
873 * <!-- Category: instruction -->
874 * <xsl:choose>
875 * <!-- Content: (xsl:when+, xsl:otherwise?) -->
876 * </xsl:choose>
877 */
878typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
879typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
880
881/**
882 * xsltStyleItemFallback:
883 *
884 * <!-- Category: instruction -->
885 * <xsl:fallback>
886 * <!-- Content: template -->
887 * </xsl:fallback>
888 */
889typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
890typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
891
892/**
893 * xsltStyleItemForEach:
894 *
895 * <!-- Category: instruction -->
896 * <xsl:for-each
897 * select = node-set-expression>
898 * <!-- Content: (xsl:sort*, template) -->
899 * </xsl:for-each>
900 */
901typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
902typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
903
904/**
905 * xsltStyleItemMessage:
906 *
907 * <!-- Category: instruction -->
908 * <xsl:message
909 * terminate = "yes" | "no">
910 * <!-- Content: template -->
911 * </xsl:message>
912 */
913typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
914typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
915
916struct _xsltStyleItemMessage {
917 XSLT_ITEM_COMMON_FIELDS
918 int terminate;
919};
920
921/**
922 * xsltStyleItemDocument:
923 *
924 * NOTE: This is not an instruction of XSLT 1.0.
925 */
926typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
927typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
928
929struct _xsltStyleItemDocument {
930 XSLT_ITEM_COMMON_FIELDS
931 int ver11; /* assigned: in xsltDocumentComp;
932 read: nowhere;
933 TODO: Check if we need. */
934 const xmlChar *filename; /* document URL */
935 int has_filename;
936};
937
938/************************************************************************
939 * *
940 * Non-instructions (actually properties of instructions/declarations) *
941 * *
942 ************************************************************************/
943
944/**
945 * xsltStyleBasicItemVariable:
946 *
947 * Basic struct for xsl:variable, xsl:param and xsl:with-param.
948 * It's currently important to have equal fields, since
949 * xsltParseStylesheetCallerParam() is used with xsl:with-param from
950 * the xslt side and with xsl:param from the exslt side (in
951 * exsltFuncFunctionFunction()).
952 *
953 * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
954 * have additional different fields.
955 */
956typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
957typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
958
959struct _xsltStyleBasicItemVariable {
960 XSLT_ITEM_COMMON_FIELDS
961
962 const xmlChar *select;
963 xmlXPathCompExprPtr comp;
964
965 const xmlChar *name;
966 int has_name;
967 const xmlChar *ns;
968 int has_ns;
969};
970
971/**
972 * xsltStyleItemVariable:
973 *
974 * <!-- Category: top-level-element -->
975 * <xsl:param
976 * name = qname
977 * select = expression>
978 * <!-- Content: template -->
979 * </xsl:param>
980 */
981typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
982typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
983
984/**
985 * xsltStyleItemParam:
986 *
987 * <!-- Category: top-level-element -->
988 * <xsl:param
989 * name = qname
990 * select = expression>
991 * <!-- Content: template -->
992 * </xsl:param>
993 */
994typedef struct _xsltStyleItemParam xsltStyleItemParam;
995typedef xsltStyleItemParam *xsltStyleItemParamPtr;
996
997struct _xsltStyleItemParam {
998 XSLT_ITEM_COMMON_FIELDS
999
1000 const xmlChar *select;
1001 xmlXPathCompExprPtr comp;
1002
1003 const xmlChar *name;
1004 int has_name;
1005 const xmlChar *ns;
1006 int has_ns;
1007};
1008
1009/**
1010 * xsltStyleItemWithParam:
1011 *
1012 * <xsl:with-param
1013 * name = qname
1014 * select = expression>
1015 * <!-- Content: template -->
1016 * </xsl:with-param>
1017 */
1018typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
1019typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
1020
1021/**
1022 * xsltStyleItemSort:
1023 *
1024 * Reflects the XSLT xsl:sort item.
1025 * Allowed parents: xsl:apply-templates, xsl:for-each
1026 * <xsl:sort
1027 * select = string-expression
1028 * lang = { nmtoken }
1029 * data-type = { "text" | "number" | qname-but-not-ncname }
1030 * order = { "ascending" | "descending" }
1031 * case-order = { "upper-first" | "lower-first" } />
1032 */
1033typedef struct _xsltStyleItemSort xsltStyleItemSort;
1034typedef xsltStyleItemSort *xsltStyleItemSortPtr;
1035
1036struct _xsltStyleItemSort {
1037 XSLT_ITEM_COMMON_FIELDS
1038
1039 const xmlChar *stype; /* sort */
1040 int has_stype; /* sort */
1041 int number; /* sort */
1042 const xmlChar *order; /* sort */
1043 int has_order; /* sort */
1044 int descending; /* sort */
1045 const xmlChar *lang; /* sort */
1046 int has_lang; /* sort */
1047 const xmlChar *case_order; /* sort */
1048 int lower_first; /* sort */
1049
1050 const xmlChar *use;
1051 int has_use;
1052
1053 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1054
1055 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1056};
1057
1058
1059/**
1060 * xsltStyleItemWhen:
1061 *
1062 * <xsl:when
1063 * test = boolean-expression>
1064 * <!-- Content: template -->
1065 * </xsl:when>
1066 * Allowed parent: xsl:choose
1067 */
1068typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
1069typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
1070
1071struct _xsltStyleItemWhen {
1072 XSLT_ITEM_COMMON_FIELDS
1073
1074 const xmlChar *test;
1075 xmlXPathCompExprPtr comp;
1076};
1077
1078/**
1079 * xsltStyleItemOtherwise:
1080 *
1081 * Allowed parent: xsl:choose
1082 * <xsl:otherwise>
1083 * <!-- Content: template -->
1084 * </xsl:otherwise>
1085 */
1086typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
1087typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
1088
1089struct _xsltStyleItemOtherwise {
1090 XSLT_ITEM_COMMON_FIELDS
1091};
1092
1093typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
1094typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
1095
1096struct _xsltStyleItemInclude {
1097 XSLT_ITEM_COMMON_FIELDS
1098 xsltDocumentPtr include;
1099};
1100
1101/************************************************************************
1102 * *
1103 * XSLT elements in forwards-compatible mode *
1104 * *
1105 ************************************************************************/
1106
1107typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
1108typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
1109struct _xsltStyleItemUknown {
1110 XSLT_ITEM_COMMON_FIELDS
1111};
1112
1113
1114/************************************************************************
1115 * *
1116 * Extension elements *
1117 * *
1118 ************************************************************************/
1119
1120/*
1121 * xsltStyleItemExtElement:
1122 *
1123 * Reflects extension elements.
1124 *
1125 * NOTE: Due to the fact that the structure xsltElemPreComp is most
1126 * probably already heavily in use out there by users, so we cannot
1127 * easily change it, we'll create an intermediate structure which will
1128 * hold an xsltElemPreCompPtr.
1129 * BIG NOTE: The only problem I see here is that the user processes the
1130 * content of the stylesheet tree, possibly he'll lookup the node->psvi
1131 * fields in order to find subsequent extension functions.
1132 * In this case, the user's code will break, since the node->psvi
1133 * field will hold now the xsltStyleItemExtElementPtr and not
1134 * the xsltElemPreCompPtr.
1135 * However the place where the structure is anchored in the node-tree,
1136 * namely node->psvi, has beed already once been moved from node->_private
1137 * to node->psvi, so we have a precedent here, which, I think, should allow
1138 * us to change such semantics without headaches.
1139 */
1140typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
1141typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
1142struct _xsltStyleItemExtElement {
1143 XSLT_ITEM_COMMON_FIELDS
1144 xsltElemPreCompPtr item;
1145};
1146
1147/************************************************************************
1148 * *
1149 * Literal result elements *
1150 * *
1151 ************************************************************************/
1152
1153typedef struct _xsltEffectiveNs xsltEffectiveNs;
1154typedef xsltEffectiveNs *xsltEffectiveNsPtr;
1155struct _xsltEffectiveNs {
1156 xsltEffectiveNsPtr nextInStore; /* storage next */
1157 xsltEffectiveNsPtr next; /* next item in the list */
1158 const xmlChar *prefix;
1159 const xmlChar *nsName;
1160 /*
1161 * Indicates if eclared on the literal result element; dunno if really
1162 * needed.
1163 */
1164 int holdByElem;
1165};
1166
1167/*
1168 * Info for literal result elements.
1169 * This will be set on the elem->psvi field and will be
1170 * shared by literal result elements, which have the same
1171 * excluded result namespaces; i.e., this *won't* be created uniquely
1172 * for every literal result element.
1173 */
1174typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
1175typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
1176struct _xsltStyleItemLRElementInfo {
1177 XSLT_ITEM_COMMON_FIELDS
1178 /*
1179 * @effectiveNs is the set of effective ns-nodes
1180 * on the literal result element, which will be added to the result
1181 * element if not already existing in the result tree.
1182 * This means that excluded namespaces (via exclude-result-prefixes,
1183 * extension-element-prefixes and the XSLT namespace) not added
1184 * to the set.
1185 * Namespace-aliasing was applied on the @effectiveNs.
1186 */
1187 xsltEffectiveNsPtr effectiveNs;
1188
1189};
1190
1191#ifdef XSLT_REFACTORED
1192
1193typedef struct _xsltNsAlias xsltNsAlias;
1194typedef xsltNsAlias *xsltNsAliasPtr;
1195struct _xsltNsAlias {
1196 xsltNsAliasPtr next; /* next in the list */
1197 xmlNsPtr literalNs;
1198 xmlNsPtr targetNs;
1199 xmlDocPtr docOfTargetNs;
1200};
1201#endif
1202
1203#ifdef XSLT_REFACTORED_XSLT_NSCOMP
1204
1205typedef struct _xsltNsMap xsltNsMap;
1206typedef xsltNsMap *xsltNsMapPtr;
1207struct _xsltNsMap {
1208 xsltNsMapPtr next; /* next in the list */
1209 xmlDocPtr doc;
1210 xmlNodePtr elem; /* the element holding the ns-decl */
1211 xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
1212 const xmlChar *origNsName; /* the original XML namespace name */
1213 const xmlChar *newNsName; /* the mapped XML namespace name */
1214};
1215#endif
1216
1217/************************************************************************
1218 * *
1219 * Compile-time structures for *internal* use only *
1220 * *
1221 ************************************************************************/
1222
1223typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
1224typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
1225
1226typedef struct _xsltNsList xsltNsList;
1227typedef xsltNsList *xsltNsListPtr;
1228struct _xsltNsList {
1229 xsltNsListPtr next; /* next in the list */
1230 xmlNsPtr ns;
1231};
1232
1233/*
1234* xsltVarInfo:
1235*
1236* Used at compilation time for parameters and variables.
1237*/
1238typedef struct _xsltVarInfo xsltVarInfo;
1239typedef xsltVarInfo *xsltVarInfoPtr;
1240struct _xsltVarInfo {
1241 xsltVarInfoPtr next; /* next in the list */
1242 xsltVarInfoPtr prev;
1243 int depth; /* the depth in the tree */
1244 const xmlChar *name;
1245 const xmlChar *nsName;
1246};
1247
1248#define XSLT_ELEMENT_CATEGORY_XSLT 0
1249#define XSLT_ELEMENT_CATEGORY_EXTENSION 1
1250#define XSLT_ELEMENT_CATEGORY_LRE 2
1251
1252/**
1253 * xsltCompilerNodeInfo:
1254 *
1255 * Per-node information during compile-time.
1256 */
1257typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
1258typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
1259struct _xsltCompilerNodeInfo {
1260 xsltCompilerNodeInfoPtr next;
1261 xsltCompilerNodeInfoPtr prev;
1262 xmlNodePtr node;
1263 int depth;
1264 xsltTemplatePtr templ; /* The owning template */
1265 int category; /* XSLT element, LR-element or
1266 extension element */
1267 xsltStyleType type;
1268 xsltElemPreCompPtr item; /* The compiled information */
1269 /* The current in-scope namespaces */
1270 xsltNsListContainerPtr inScopeNs;
1271 /* The current excluded result namespaces */
1272 xsltPointerListPtr exclResultNs;
1273 /* The current extension instruction namespaces */
1274 xsltPointerListPtr extElemNs;
1275
1276 /* The current info for literal result elements. */
1277 xsltStyleItemLRElementInfoPtr litResElemInfo;
1278 /*
1279 * Set to 1 if in-scope namespaces changed,
1280 * or excluded result namespaces changed,
1281 * or extension element namespaces changed.
1282 * This will trigger creation of new infos
1283 * for literal result elements.
1284 */
1285 int nsChanged;
1286 int preserveWhitespace;
1287 int stripWhitespace;
1288 int isRoot; /* whether this is the stylesheet's root node */
1289 int forwardsCompat; /* whether forwards-compatible mode is enabled */
1290 /* whether the content of an extension element was processed */
1291 int extContentHandled;
1292 /* the type of the current child */
1293 xsltStyleType curChildType;
1294};
1295
1296/**
1297 * XSLT_CCTXT:
1298 *
1299 * get pointer to compiler context
1300 */
1301#define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)
1302
1303typedef enum {
1304 XSLT_ERROR_SEVERITY_ERROR = 0,
1305 XSLT_ERROR_SEVERITY_WARNING
1306} xsltErrorSeverityType;
1307
1308typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
1309typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
1310struct _xsltCompilerCtxt {
1311 void *errorCtxt; /* user specific error context */
1312 /*
1313 * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
1314 xsltErrorSeverityType errSeverity;
1315 int warnings; /* TODO: number of warnings found at
1316 compilation */
1317 int errors; /* TODO: number of errors found at
1318 compilation */
1319 xmlDictPtr dict;
1320 xsltStylesheetPtr style;
1321 int simplified; /* whether this is a simplified stylesheet */
1322 /* TODO: structured/unstructured error contexts. */
1323 int depth; /* Current depth of processing */
1324
1325 xsltCompilerNodeInfoPtr inode;
1326 xsltCompilerNodeInfoPtr inodeList;
1327 xsltCompilerNodeInfoPtr inodeLast;
1328 xsltPointerListPtr tmpList; /* Used for various purposes */
1329 /*
1330 * The XSLT version as specified by the stylesheet's root element.
1331 */
1332 int isInclude;
1333 int hasForwardsCompat; /* whether forwards-compatible mode was used
1334 in a parsing episode */
1335 int maxNodeInfos; /* TEMP TODO: just for the interest */
1336 int maxLREs; /* TEMP TODO: just for the interest */
1337 /*
1338 * In order to keep the old behaviour, applying strict rules of
1339 * the spec can be turned off. This has effect only on special
1340 * mechanisms like whitespace-stripping in the stylesheet.
1341 */
1342 int strict;
1343 xsltPrincipalStylesheetDataPtr psData;
1344#ifdef XSLT_REFACTORED_XPATHCOMP
1345 xmlXPathContextPtr xpathCtxt;
1346#endif
1347 xsltStyleItemUknownPtr unknownItem;
1348 int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
1349 xsltNsAliasPtr nsAliases;
1350 xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
1351 xsltVarInfoPtr ivar; /* topmost local variable/param. */
1352};
1353
1354#else /* XSLT_REFACTORED */
1355/*
1356* The old structures before refactoring.
1357*/
1358
1359/**
1360 * _xsltStylePreComp:
1361 *
1362 * The in-memory structure corresponding to XSLT stylesheet constructs
1363 * precomputed data.
1364 */
1365struct _xsltStylePreComp {
1366 xsltElemPreCompPtr next; /* chained list */
1367 xsltStyleType type; /* type of the element */
1368 xsltTransformFunction func; /* handling function */
1369 xmlNodePtr inst; /* the instruction */
1370
1371 /*
1372 * Pre computed values.
1373 */
1374
1375 const xmlChar *stype; /* sort */
1376 int has_stype; /* sort */
1377 int number; /* sort */
1378 const xmlChar *order; /* sort */
1379 int has_order; /* sort */
1380 int descending; /* sort */
1381 const xmlChar *lang; /* sort */
1382 int has_lang; /* sort */
1383 const xmlChar *case_order; /* sort */
1384 int lower_first; /* sort */
1385
1386 const xmlChar *use; /* copy, element */
1387 int has_use; /* copy, element */
1388
1389 int noescape; /* text */
1390
1391 const xmlChar *name; /* element, attribute, pi */
1392 int has_name; /* element, attribute, pi */
1393 const xmlChar *ns; /* element */
1394 int has_ns; /* element */
1395
1396 const xmlChar *mode; /* apply-templates */
1397 const xmlChar *modeURI; /* apply-templates */
1398
1399 const xmlChar *test; /* if */
1400
1401 xsltTemplatePtr templ; /* call-template */
1402
1403 const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1404
1405 int ver11; /* document */
1406 const xmlChar *filename; /* document URL */
1407 int has_filename; /* document */
1408
1409 xsltNumberData numdata; /* number */
1410
1411 xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1412 xmlNsPtr *nsList; /* the namespaces in scope */
1413 int nsNr; /* the number of namespaces in scope */
1414};
1415
1416#endif /* XSLT_REFACTORED */
1417
1418
1419#define XSLT_VAR_GLOBAL 1<<0
1420#define XSLT_VAR_IN_SELECT 1<<1
1421#define XSLT_TCTXT_VARIABLE(c) ((xsltStackElemPtr) (c)->contextVariable)
1422/*
1423 * The in-memory structure corresponding to an XSLT Variable
1424 * or Param.
1425 */
1426typedef struct _xsltStackElem xsltStackElem;
1427typedef xsltStackElem *xsltStackElemPtr;
1428struct _xsltStackElem {
1429 struct _xsltStackElem *next;/* chained list */
1430 xsltStylePreCompPtr comp; /* the compiled form */
1431 int computed; /* was the evaluation done */
1432 const xmlChar *name; /* the local part of the name QName */
1433 const xmlChar *nameURI; /* the URI part of the name QName */
1434 const xmlChar *select; /* the eval string */
1435 xmlNodePtr tree; /* the sequence constructor if no eval
1436 string or the location */
1437 xmlXPathObjectPtr value; /* The value if computed */
1438 xmlDocPtr fragment; /* The Result Tree Fragments (needed for XSLT 1.0)
1439 which are bound to the variable's lifetime. */
1440 int level; /* the depth in the tree;
1441 -1 if persistent (e.g. a given xsl:with-param) */
1442 xsltTransformContextPtr context; /* The transformation context; needed to cache
1443 the variables */
1444 int flags;
1445};
1446
1447#ifdef XSLT_REFACTORED
1448
1449struct _xsltPrincipalStylesheetData {
1450 /*
1451 * Namespace dictionary for ns-prefixes and ns-names:
1452 * TODO: Shared between stylesheets, and XPath mechanisms.
1453 * Not used yet.
1454 */
1455 xmlDictPtr namespaceDict;
1456 /*
1457 * Global list of in-scope namespaces.
1458 */
1459 xsltPointerListPtr inScopeNamespaces;
1460 /*
1461 * Global list of information for [xsl:]excluded-result-prefixes.
1462 */
1463 xsltPointerListPtr exclResultNamespaces;
1464 /*
1465 * Global list of information for [xsl:]extension-element-prefixes.
1466 */
1467 xsltPointerListPtr extElemNamespaces;
1468 xsltEffectiveNsPtr effectiveNs;
1469#ifdef XSLT_REFACTORED_XSLT_NSCOMP
1470 /*
1471 * Namespace name map to get rid of string comparison of namespace names.
1472 */
1473 xsltNsMapPtr nsMap;
1474#endif
1475};
1476
1477
1478#endif
1479/*
1480 * Note that we added a @compCtxt field to anchor an stylesheet compilation
1481 * context, since, due to historical reasons, various compile-time function
1482 * take only the stylesheet as argument and not a compilation context.
1483 */
1484struct _xsltStylesheet {
1485 /*
1486 * The stylesheet import relation is kept as a tree.
1487 */
1488 struct _xsltStylesheet *parent;
1489 struct _xsltStylesheet *next;
1490 struct _xsltStylesheet *imports;
1491
1492 xsltDocumentPtr docList; /* the include document list */
1493
1494 /*
1495 * General data on the style sheet document.
1496 */
1497 xmlDocPtr doc; /* the parsed XML stylesheet */
1498 xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
1499 preserve space elements */
1500 int stripAll; /* strip-space * (1) preserve-space * (-1) */
1501 xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
1502
1503 /*
1504 * Global variable or parameters.
1505 */
1506 xsltStackElemPtr variables; /* linked list of param and variables */
1507
1508 /*
1509 * Template descriptions.
1510 */
1511 xsltTemplatePtr templates; /* the ordered list of templates */
1512 void *templatesHash; /* hash table or wherever compiled templates
1513 informations are stored */
1514 void *rootMatch; /* template based on / */
1515 void *keyMatch; /* template based on key() */
1516 void *elemMatch; /* template based on * */
1517 void *attrMatch; /* template based on @* */
1518 void *parentMatch; /* template based on .. */
1519 void *textMatch; /* template based on text() */
1520 void *piMatch; /* template based on processing-instruction() */
1521 void *commentMatch; /* template based on comment() */
1522
1523 /*
1524 * Namespace aliases.
1525 * NOTE: Not used in the refactored code.
1526 */
1527 xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
1528
1529 /*
1530 * Attribute sets.
1531 */
1532 xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
1533
1534 /*
1535 * Namespaces.
1536 * TODO: Eliminate this.
1537 */
1538 xmlHashTablePtr nsHash; /* the set of namespaces in use:
1539 ATTENTION: This is used for
1540 execution of XPath expressions; unfortunately
1541 it restricts the stylesheet to have distinct
1542 prefixes.
1543 TODO: We need to get rid of this.
1544 */
1545 void *nsDefs; /* ATTENTION TODO: This is currently used to store
1546 xsltExtDefPtr (in extensions.c) and
1547 *not* xmlNsPtr.
1548 */
1549
1550 /*
1551 * Key definitions.
1552 */
1553 void *keys; /* key definitions */
1554
1555 /*
1556 * Output related stuff.
1557 */
1558 xmlChar *method; /* the output method */
1559 xmlChar *methodURI; /* associated namespace if any */
1560 xmlChar *version; /* version string */
1561 xmlChar *encoding; /* encoding string */
1562 int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
1563
1564 /*
1565 * Number formatting.
1566 */
1567 xsltDecimalFormatPtr decimalFormat;
1568 int standalone; /* standalone = "yes" | "no" */
1569 xmlChar *doctypePublic; /* doctype-public string */
1570 xmlChar *doctypeSystem; /* doctype-system string */
1571 int indent; /* should output being indented */
1572 xmlChar *mediaType; /* media-type string */
1573
1574 /*
1575 * Precomputed blocks.
1576 */
1577 xsltElemPreCompPtr preComps;/* list of precomputed blocks */
1578 int warnings; /* number of warnings found at compilation */
1579 int errors; /* number of errors found at compilation */
1580
1581 xmlChar *exclPrefix; /* last excluded prefixes */
1582 xmlChar **exclPrefixTab; /* array of excluded prefixes */
1583 int exclPrefixNr; /* number of excluded prefixes in scope */
1584 int exclPrefixMax; /* size of the array */
1585
1586 void *_private; /* user defined data */
1587
1588 /*
1589 * Extensions.
1590 */
1591 xmlHashTablePtr extInfos; /* the extension data */
1592 int extrasNr; /* the number of extras required */
1593
1594 /*
1595 * For keeping track of nested includes
1596 */
1597 xsltDocumentPtr includes; /* points to last nested include */
1598
1599 /*
1600 * dictionary: shared between stylesheet, context and documents.
1601 */
1602 xmlDictPtr dict;
1603 /*
1604 * precompiled attribute value templates.
1605 */
1606 void *attVTs;
1607 /*
1608 * if namespace-alias has an alias for the default stylesheet prefix
1609 * NOTE: Not used in the refactored code.
1610 */
1611 const xmlChar *defaultAlias;
1612 /*
1613 * bypass pre-processing (already done) (used in imports)
1614 */
1615 int nopreproc;
1616 /*
1617 * all document text strings were internalized
1618 */
1619 int internalized;
1620 /*
1621 * Literal Result Element as Stylesheet c.f. section 2.3
1622 */
1623 int literal_result;
1624 /*
1625 * The principal stylesheet
1626 */
1627 xsltStylesheetPtr principal;
1628#ifdef XSLT_REFACTORED
1629 /*
1630 * Compilation context used during compile-time.
1631 */
1632 xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
1633
1634 xsltPrincipalStylesheetDataPtr principalData;
1635#endif
1636};
1637
1638typedef struct _xsltTransformCache xsltTransformCache;
1639typedef xsltTransformCache *xsltTransformCachePtr;
1640struct _xsltTransformCache {
1641 xmlDocPtr RVT;
1642 int nbRVT;
1643 xsltStackElemPtr stackItems;
1644 int nbStackItems;
1645#ifdef XSLT_DEBUG_PROFILE_CACHE
1646 int dbgCachedRVTs;
1647 int dbgReusedRVTs;
1648 int dbgCachedVars;
1649 int dbgReusedVars;
1650#endif
1651};
1652
1653/*
1654 * The in-memory structure corresponding to an XSLT Transformation.
1655 */
1656typedef enum {
1657 XSLT_OUTPUT_XML = 0,
1658 XSLT_OUTPUT_HTML,
1659 XSLT_OUTPUT_TEXT
1660} xsltOutputType;
1661
1662typedef enum {
1663 XSLT_STATE_OK = 0,
1664 XSLT_STATE_ERROR,
1665 XSLT_STATE_STOPPED
1666} xsltTransformState;
1667
1668struct _xsltTransformContext {
1669 xsltStylesheetPtr style; /* the stylesheet used */
1670 xsltOutputType type; /* the type of output */
1671
1672 xsltTemplatePtr templ; /* the current template */
1673 int templNr; /* Nb of templates in the stack */
1674 int templMax; /* Size of the templtes stack */
1675 xsltTemplatePtr *templTab; /* the template stack */
1676
1677 xsltStackElemPtr vars; /* the current variable list */
1678 int varsNr; /* Nb of variable list in the stack */
1679 int varsMax; /* Size of the variable list stack */
1680 xsltStackElemPtr *varsTab; /* the variable list stack */
1681 int varsBase; /* the var base for current templ */
1682
1683 /*
1684 * Extensions
1685 */
1686 xmlHashTablePtr extFunctions; /* the extension functions */
1687 xmlHashTablePtr extElements; /* the extension elements */
1688 xmlHashTablePtr extInfos; /* the extension data */
1689
1690 const xmlChar *mode; /* the current mode */
1691 const xmlChar *modeURI; /* the current mode URI */
1692
1693 xsltDocumentPtr docList; /* the document list */
1694
1695 xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */
1696 xmlNodePtr node; /* the current node being processed */
1697 xmlNodeSetPtr nodeList; /* the current node list */
1698 /* xmlNodePtr current; the node */
1699
1700 xmlDocPtr output; /* the resulting document */
1701 xmlNodePtr insert; /* the insertion node */
1702
1703 xmlXPathContextPtr xpathCtxt; /* the XPath context */
1704 xsltTransformState state; /* the current state */
1705
1706 /*
1707 * Global variables
1708 */
1709 xmlHashTablePtr globalVars; /* the global variables and params */
1710
1711 xmlNodePtr inst; /* the instruction in the stylesheet */
1712
1713 int xinclude; /* should XInclude be processed */
1714
1715 const char * outputFile; /* the output URI if known */
1716
1717 int profile; /* is this run profiled */
1718 long prof; /* the current profiled value */
1719 int profNr; /* Nb of templates in the stack */
1720 int profMax; /* Size of the templtaes stack */
1721 long *profTab; /* the profile template stack */
1722
1723 void *_private; /* user defined data */
1724
1725 int extrasNr; /* the number of extras used */
1726 int extrasMax; /* the number of extras allocated */
1727 xsltRuntimeExtraPtr extras; /* extra per runtime informations */
1728
1729 xsltDocumentPtr styleList; /* the stylesheet docs list */
1730 void * sec; /* the security preferences if any */
1731
1732 xmlGenericErrorFunc error; /* a specific error handler */
1733 void * errctx; /* context for the error handler */
1734
1735 xsltSortFunc sortfunc; /* a ctxt specific sort routine */
1736
1737 /*
1738 * handling of temporary Result Value Tree
1739 * (XSLT 1.0 term: "Result Tree Fragment")
1740 */
1741 xmlDocPtr tmpRVT; /* list of RVT without persistance */
1742 xmlDocPtr persistRVT; /* list of persistant RVTs */
1743 int ctxtflags; /* context processing flags */
1744
1745 /*
1746 * Speed optimization when coalescing text nodes
1747 */
1748 const xmlChar *lasttext; /* last text node content */
1749 unsigned int lasttsize; /* last text node size */
1750 unsigned int lasttuse; /* last text node use */
1751 /*
1752 * Per Context Debugging
1753 */
1754 int debugStatus; /* the context level debug status */
1755 unsigned long* traceCode; /* pointer to the variable holding the mask */
1756
1757 int parserOptions; /* parser options xmlParserOption */
1758
1759 /*
1760 * dictionary: shared between stylesheet, context and documents.
1761 */
1762 xmlDictPtr dict;
1763 xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */
1764 /*
1765 * all document text strings are internalized
1766 */
1767 int internalized;
1768 int nbKeys;
1769 int hasTemplKeyPatterns;
1770 xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
1771 xmlNodePtr initialContextNode;
1772 xmlDocPtr initialContextDoc;
1773 xsltTransformCachePtr cache;
1774 void *contextVariable; /* the current variable item */
1775 xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
1776 the instruction which created the fragment
1777 exits */
1778 xmlDocPtr localRVTBase;
1779};
1780
1781/**
1782 * CHECK_STOPPED:
1783 *
1784 * Macro to check if the XSLT processing should be stopped.
1785 * Will return from the function.
1786 */
1787#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
1788
1789/**
1790 * CHECK_STOPPEDE:
1791 *
1792 * Macro to check if the XSLT processing should be stopped.
1793 * Will goto the error: label.
1794 */
1795#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
1796
1797/**
1798 * CHECK_STOPPED0:
1799 *
1800 * Macro to check if the XSLT processing should be stopped.
1801 * Will return from the function with a 0 value.
1802 */
1803#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
1804
1805/*
1806 * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
1807 * possible incompatibilities between function pointers and object
1808 * pointers. It is defined in libxml/hash.h within recent versions
1809 * of libxml2, but is put here for compatibility.
1810 */
1811#ifndef XML_CAST_FPTR
1812/**
1813 * XML_CAST_FPTR:
1814 * @fptr: pointer to a function
1815 *
1816 * Macro to do a casting from an object pointer to a
1817 * function pointer without encountering a warning from
1818 * gcc
1819 *
1820 * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
1821 * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
1822 * so it is disabled now
1823 */
1824
1825#define XML_CAST_FPTR(fptr) fptr
1826#endif
1827/*
1828 * Functions associated to the internal types
1829xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
1830 xmlChar *name);
1831 */
1832XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1833 xsltNewStylesheet (void);
1834XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1835 xsltParseStylesheetFile (const xmlChar* filename);
1836XSLTPUBFUN void XSLTCALL
1837 xsltFreeStylesheet (xsltStylesheetPtr style);
1838XSLTPUBFUN int XSLTCALL
1839 xsltIsBlank (xmlChar *str);
1840XSLTPUBFUN void XSLTCALL
1841 xsltFreeStackElemList (xsltStackElemPtr elem);
1842XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
1843 xsltDecimalFormatGetByName(xsltStylesheetPtr style,
1844 xmlChar *name);
1845
1846XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1847 xsltParseStylesheetProcess(xsltStylesheetPtr ret,
1848 xmlDocPtr doc);
1849XSLTPUBFUN void XSLTCALL
1850 xsltParseStylesheetOutput(xsltStylesheetPtr style,
1851 xmlNodePtr cur);
1852XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1853 xsltParseStylesheetDoc (xmlDocPtr doc);
1854XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1855 xsltParseStylesheetImportedDoc(xmlDocPtr doc,
1856 xsltStylesheetPtr style);
1857XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1858 xsltLoadStylesheetPI (xmlDocPtr doc);
1859XSLTPUBFUN void XSLTCALL
1860 xsltNumberFormat (xsltTransformContextPtr ctxt,
1861 xsltNumberDataPtr data,
1862 xmlNodePtr node);
1863XSLTPUBFUN xmlXPathError XSLTCALL
1864 xsltFormatNumberConversion(xsltDecimalFormatPtr self,
1865 xmlChar *format,
1866 double number,
1867 xmlChar **result);
1868
1869XSLTPUBFUN void XSLTCALL
1870 xsltParseTemplateContent(xsltStylesheetPtr style,
1871 xmlNodePtr templ);
1872XSLTPUBFUN int XSLTCALL
1873 xsltAllocateExtra (xsltStylesheetPtr style);
1874XSLTPUBFUN int XSLTCALL
1875 xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);
1876/*
1877 * Extra functions for Result Value Trees
1878 */
1879XSLTPUBFUN xmlDocPtr XSLTCALL
1880 xsltCreateRVT (xsltTransformContextPtr ctxt);
1881XSLTPUBFUN int XSLTCALL
1882 xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,
1883 xmlDocPtr RVT);
1884XSLTPUBFUN int XSLTCALL
1885 xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,
1886 xmlDocPtr RVT);
1887XSLTPUBFUN int XSLTCALL
1888 xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,
1889 xmlDocPtr RVT);
1890XSLTPUBFUN int XSLTCALL
1891 xsltExtensionInstructionResultRegister(
1892 xsltTransformContextPtr ctxt,
1893 xmlXPathObjectPtr obj);
1894XSLTPUBFUN int XSLTCALL
1895 xsltExtensionInstructionResultFinalize(
1896 xsltTransformContextPtr ctxt);
1897XSLTPUBFUN void XSLTCALL
1898 xsltFreeRVTs (xsltTransformContextPtr ctxt);
1899XSLTPUBFUN void XSLTCALL
1900 xsltReleaseRVT (xsltTransformContextPtr ctxt,
1901 xmlDocPtr RVT);
1902XSLTPUBFUN int XSLTCALL
1903 xsltTransStorageAdd (xsltTransformContextPtr ctxt,
1904 void *id,
1905 void *data);
1906XSLTPUBFUN void * XSLTCALL
1907 xsltTransStorageRemove (xsltTransformContextPtr ctxt,
1908 void *id);
1909
1910/*
1911 * Extra functions for Attribute Value Templates
1912 */
1913XSLTPUBFUN void XSLTCALL
1914 xsltCompileAttr (xsltStylesheetPtr style,
1915 xmlAttrPtr attr);
1916XSLTPUBFUN xmlChar * XSLTCALL
1917 xsltEvalAVT (xsltTransformContextPtr ctxt,
1918 void *avt,
1919 xmlNodePtr node);
1920XSLTPUBFUN void XSLTCALL
1921 xsltFreeAVTList (void *avt);
1922
1923/*
1924 * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
1925 */
1926
1927XSLTPUBFUN void XSLTCALL
1928 xsltUninit (void);
1929
1930/************************************************************************
1931 * *
1932 * Compile-time functions for *internal* use only *
1933 * *
1934 ************************************************************************/
1935
1936#ifdef XSLT_REFACTORED
1937XSLTPUBFUN void XSLTCALL
1938 xsltParseSequenceConstructor(
1939 xsltCompilerCtxtPtr cctxt,
1940 xmlNodePtr start);
1941XSLTPUBFUN int XSLTCALL
1942 xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,
1943 xmlNodePtr elem);
1944#ifdef XSLT_REFACTORED_XSLT_NSCOMP
1945XSLTPUBFUN int XSLTCALL
1946 xsltRestoreDocumentNamespaces(
1947 xsltNsMapPtr ns,
1948 xmlDocPtr doc);
1949#endif
1950#endif /* XSLT_REFACTORED */
1951
1952/************************************************************************
1953 * *
1954 * Transformation-time functions for *internal* use only *
1955 * *
1956 ************************************************************************/
1957XSLTPUBFUN int XSLTCALL
1958 xsltInitCtxtKey (xsltTransformContextPtr ctxt,
1959 xsltDocumentPtr doc,
1960 xsltKeyDefPtr keyd);
1961
1962#ifdef __cplusplus
1963}
1964#endif
1965
1966#endif /* __XML_XSLT_H__ */
1967
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette