Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/xslt/libxslt/xsltInternals.h
4389 views
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
27
extern "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
* That's the only mode now but the define is kept for compatibility
64
*/
65
#define XSLT_REFACTORED_KEYCOMP
66
67
/**
68
* XSLT_FAST_IF:
69
*
70
* Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
71
* for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
72
*/
73
#define XSLT_FAST_IF
74
75
/**
76
* XSLT_REFACTORED:
77
*
78
* Internal define to enable the refactored parts of Libxslt.
79
*/
80
/* #define XSLT_REFACTORED */
81
/* ==================================================================== */
82
83
/**
84
* XSLT_REFACTORED_VARS:
85
*
86
* Internal define to enable the refactored variable part of libxslt
87
*/
88
#define XSLT_REFACTORED_VARS
89
90
#ifdef XSLT_REFACTORED
91
92
extern const xmlChar *xsltXSLTAttrMarker;
93
94
95
/* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
96
97
/* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
98
99
/**
100
* XSLT_REFACTORED_XSLT_NSCOMP
101
*
102
* Internal define to enable the pointer-comparison of
103
* namespaces of XSLT elements.
104
*/
105
/* #define XSLT_REFACTORED_XSLT_NSCOMP */
106
107
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
108
109
extern const xmlChar *xsltConstNamespaceNameXSLT;
110
111
/**
112
* IS_XSLT_ELEM_FAST:
113
*
114
* quick test to detect XSLT elements
115
*/
116
#define IS_XSLT_ELEM_FAST(n) \
117
(((n) != NULL) && ((n)->ns != NULL) && \
118
((n)->ns->href == xsltConstNamespaceNameXSLT))
119
120
/**
121
* IS_XSLT_ATTR_FAST:
122
*
123
* quick test to detect XSLT attributes
124
*/
125
#define IS_XSLT_ATTR_FAST(a) \
126
(((a) != NULL) && ((a)->ns != NULL) && \
127
((a)->ns->href == xsltConstNamespaceNameXSLT))
128
129
/**
130
* XSLT_HAS_INTERNAL_NSMAP:
131
*
132
* check for namespace mapping
133
*/
134
#define XSLT_HAS_INTERNAL_NSMAP(s) \
135
(((s) != NULL) && ((s)->principal) && \
136
((s)->principal->principalData) && \
137
((s)->principal->principalData->nsMap))
138
139
/**
140
* XSLT_GET_INTERNAL_NSMAP:
141
*
142
* get pointer to namespace map
143
*/
144
#define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
145
146
#else /* XSLT_REFACTORED_XSLT_NSCOMP */
147
148
/**
149
* IS_XSLT_ELEM_FAST:
150
*
151
* quick check whether this is an xslt element
152
*/
153
#define IS_XSLT_ELEM_FAST(n) \
154
(((n) != NULL) && ((n)->ns != NULL) && \
155
(xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
156
157
/**
158
* IS_XSLT_ATTR_FAST:
159
*
160
* quick check for xslt namespace attribute
161
*/
162
#define IS_XSLT_ATTR_FAST(a) \
163
(((a) != NULL) && ((a)->ns != NULL) && \
164
(xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
165
166
167
#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
168
169
170
/**
171
* XSLT_REFACTORED_MANDATORY_VERSION:
172
*
173
* TODO: Currently disabled to surpress regression test failures, 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.
177
*/
178
/* #define XSLT_REFACTORED_MANDATORY_VERSION */
179
180
/**
181
* xsltPointerList:
182
*
183
* Pointer-list for various purposes.
184
*/
185
typedef struct _xsltPointerList xsltPointerList;
186
typedef xsltPointerList *xsltPointerListPtr;
187
struct _xsltPointerList {
188
void **items;
189
int number;
190
int size;
191
};
192
193
#endif
194
195
/**
196
* XSLT_REFACTORED_PARSING:
197
*
198
* Internal define to enable the refactored parts of Libxslt
199
* related to parsing.
200
*/
201
/* #define XSLT_REFACTORED_PARSING */
202
203
/**
204
* XSLT_MAX_SORT:
205
*
206
* Max number of specified xsl:sort on an element.
207
*/
208
#define XSLT_MAX_SORT 15
209
210
/**
211
* XSLT_PAT_NO_PRIORITY:
212
*
213
* Specific value for pattern without priority expressed.
214
*/
215
#define XSLT_PAT_NO_PRIORITY -12345789
216
217
/**
218
* xsltRuntimeExtra:
219
*
220
* Extra information added to the transformation context.
221
*/
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;
231
};
232
233
/**
234
* XSLT_RUNTIME_EXTRA_LST:
235
* @ctxt: the transformation context
236
* @nr: the index
237
*
238
* Macro used to access extra information stored in the context
239
*/
240
#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
241
/**
242
* XSLT_RUNTIME_EXTRA_FREE:
243
* @ctxt: the transformation context
244
* @nr: the index
245
*
246
* Macro used to free extra information stored in the context
247
*/
248
#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
249
/**
250
* XSLT_RUNTIME_EXTRA:
251
* @ctxt: the transformation context
252
* @nr: the index
253
*
254
* Macro used to define extra information stored in the context
255
*/
256
#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
257
258
/**
259
* xsltTemplate:
260
*
261
* The in-memory structure corresponding to an XSLT Template.
262
*/
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 */
276
277
/*
278
* TODO: @inheritedNsNr and @inheritedNs won't be used in the
279
* refactored code.
280
*/
281
int inheritedNsNr; /* number of inherited namespaces */
282
xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
283
284
/* Profiling information */
285
int nbCalls; /* the number of time the template was called */
286
unsigned long time; /* the time spent in this template */
287
void *params; /* xsl:param instructions */
288
289
int templNr; /* Nb of templates in the stack */
290
int templMax; /* Size of the templtes stack */
291
xsltTemplatePtr *templCalledTab; /* templates called */
292
int *templCountTab; /* .. and how often */
293
294
/* Conflict resolution */
295
int position;
296
};
297
298
/**
299
* xsltDecimalFormat:
300
*
301
* Data structure of decimal-format.
302
*/
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;
322
};
323
324
/**
325
* xsltDocument:
326
*
327
* Data structure associated to a parsed document.
328
*/
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;
339
};
340
341
/**
342
* xsltKeyDef:
343
*
344
* Representation of an xsl:key.
345
*/
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 */
359
};
360
361
/**
362
* xsltKeyTable:
363
*
364
* Holds the computed keys for key definitions of the same QName.
365
* Is owned by an xsltDocument.
366
*/
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;
374
};
375
376
/*
377
* The in-memory structure corresponding to an XSLT Stylesheet.
378
* NOTE: most of the content is simply linked from the doc tree
379
* structure, no specific allocation is made.
380
*/
381
typedef struct _xsltStylesheet xsltStylesheet;
382
typedef xsltStylesheet *xsltStylesheetPtr;
383
384
typedef struct _xsltTransformContext xsltTransformContext;
385
typedef xsltTransformContext *xsltTransformContextPtr;
386
387
/**
388
* xsltElemPreComp:
389
*
390
* The in-memory structure corresponding to element precomputed data,
391
* designed to be extended by extension implementors.
392
*/
393
typedef struct _xsltElemPreComp xsltElemPreComp;
394
typedef xsltElemPreComp *xsltElemPreCompPtr;
395
396
/**
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
402
*
403
* Signature of the function associated to elements part of the
404
* stylesheet language like xsl:if or xsl:apply-templates.
405
*/
406
typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
407
xmlNodePtr node,
408
xmlNodePtr inst,
409
xsltElemPreCompPtr comp);
410
411
/**
412
* xsltSortFunc:
413
* @ctxt: a transformation context
414
* @sorts: the node-set to sort
415
* @nbsorts: the number of sorts
416
*
417
* Signature of the function to use during sorting
418
*/
419
typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
420
int nbsorts);
421
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
446
,
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;
456
457
/**
458
* xsltElemPreCompDeallocator:
459
* @comp: the #xsltElemPreComp to free up
460
*
461
* Deallocates an #xsltElemPreComp structure.
462
*/
463
typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
464
465
/**
466
* xsltElemPreComp:
467
*
468
* The basic structure for compiled items of the AST of the XSLT processor.
469
* This structure is also intended to be extended by extension implementors.
470
* TODO: This is somehow not nice, since it has a "free" field, which
471
* derived stylesheet-structs do not have.
472
*/
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 */
480
481
/* end of common part */
482
xsltElemPreCompDeallocator free; /* the deallocator */
483
};
484
485
/**
486
* xsltStylePreComp:
487
*
488
* The abstract basic structure for items of the XSLT processor.
489
* This includes:
490
* 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
491
* 2) compiled forms of literal result elements
492
* 3) compiled forms of extension elements
493
*/
494
typedef struct _xsltStylePreComp xsltStylePreComp;
495
typedef xsltStylePreComp *xsltStylePreCompPtr;
496
497
#ifdef XSLT_REFACTORED
498
499
/*
500
* Some pointer-list utility functions.
501
*/
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);
512
513
/************************************************************************
514
* *
515
* Refactored structures *
516
* *
517
************************************************************************/
518
519
typedef struct _xsltNsListContainer xsltNsListContainer;
520
typedef xsltNsListContainer *xsltNsListContainerPtr;
521
struct _xsltNsListContainer {
522
xmlNsPtr *list;
523
int totalNumber;
524
int xpathNumber;
525
};
526
527
/**
528
* XSLT_ITEM_COMPATIBILITY_FIELDS:
529
*
530
* Fields for API compatibility to the 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.
535
*/
536
#define XSLT_ITEM_COMPATIBILITY_FIELDS \
537
xsltElemPreCompPtr next;\
538
xsltStyleType type;\
539
xsltTransformFunction func;\
540
xmlNodePtr inst;
541
542
/**
543
* XSLT_ITEM_NAVIGATION_FIELDS:
544
*
545
* Currently empty.
546
* TODO: It is intended to hold navigational fields in the future.
547
*/
548
#define XSLT_ITEM_NAVIGATION_FIELDS
549
/*
550
xsltStylePreCompPtr parent;\
551
xsltStylePreCompPtr children;\
552
xsltStylePreCompPtr nextItem;
553
*/
554
555
/**
556
* XSLT_ITEM_NSINSCOPE_FIELDS:
557
*
558
* The in-scope namespaces.
559
*/
560
#define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
561
562
/**
563
* XSLT_ITEM_COMMON_FIELDS:
564
*
565
* Common fields used for all items.
566
*/
567
#define XSLT_ITEM_COMMON_FIELDS \
568
XSLT_ITEM_COMPATIBILITY_FIELDS \
569
XSLT_ITEM_NAVIGATION_FIELDS \
570
XSLT_ITEM_NSINSCOPE_FIELDS
571
572
/**
573
* _xsltStylePreComp:
574
*
575
* The abstract basic structure for items of the XSLT processor.
576
* This includes:
577
* 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)
578
* 2) compiled forms of literal result elements
579
* 3) various properties for XSLT instructions (e.g. xsl:when,
580
* xsl:with-param)
581
*
582
* REVISIT TODO: Keep this structure equal to the fields
583
* defined by XSLT_ITEM_COMMON_FIELDS
584
*/
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;
594
};
595
596
/**
597
* xsltStyleBasicEmptyItem:
598
*
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.
603
*/
604
typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
605
typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
606
607
struct _xsltStyleBasicEmptyItem {
608
XSLT_ITEM_COMMON_FIELDS
609
};
610
611
/**
612
* xsltStyleBasicExpressionItem:
613
*
614
* Abstract structure only used as a short-cut for
615
* XSLT items with just an expression.
616
*/
617
typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
618
typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
619
620
struct _xsltStyleBasicExpressionItem {
621
XSLT_ITEM_COMMON_FIELDS
622
623
const xmlChar *select; /* TODO: Change this to "expression". */
624
xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
625
};
626
627
/************************************************************************
628
* *
629
* XSLT-instructions/declarations *
630
* *
631
************************************************************************/
632
633
/**
634
* xsltStyleItemElement:
635
*
636
* <!-- Category: instruction -->
637
* <xsl:element
638
* name = { qname }
639
* namespace = { uri-reference }
640
* use-attribute-sets = qnames>
641
* <!-- Content: template -->
642
* </xsl:element>
643
*/
644
typedef struct _xsltStyleItemElement xsltStyleItemElement;
645
typedef xsltStyleItemElement *xsltStyleItemElementPtr;
646
647
struct _xsltStyleItemElement {
648
XSLT_ITEM_COMMON_FIELDS
649
650
const xmlChar *use;
651
int has_use;
652
const xmlChar *name;
653
int has_name;
654
const xmlChar *ns;
655
const xmlChar *nsPrefix;
656
int has_ns;
657
};
658
659
/**
660
* xsltStyleItemAttribute:
661
*
662
* <!-- Category: instruction -->
663
* <xsl:attribute
664
* name = { qname }
665
* namespace = { uri-reference }>
666
* <!-- Content: template -->
667
* </xsl:attribute>
668
*/
669
typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
670
typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
671
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;
679
};
680
681
/**
682
* xsltStyleItemText:
683
*
684
* <!-- Category: instruction -->
685
* <xsl:text
686
* disable-output-escaping = "yes" | "no">
687
* <!-- Content: #PCDATA -->
688
* </xsl:text>
689
*/
690
typedef struct _xsltStyleItemText xsltStyleItemText;
691
typedef xsltStyleItemText *xsltStyleItemTextPtr;
692
693
struct _xsltStyleItemText {
694
XSLT_ITEM_COMMON_FIELDS
695
int noescape; /* text */
696
};
697
698
/**
699
* xsltStyleItemComment:
700
*
701
* <!-- Category: instruction -->
702
* <xsl:comment>
703
* <!-- Content: template -->
704
* </xsl:comment>
705
*/
706
typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
707
typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
708
709
/**
710
* xsltStyleItemPI:
711
*
712
* <!-- Category: instruction -->
713
* <xsl:processing-instruction
714
* name = { ncname }>
715
* <!-- Content: template -->
716
* </xsl:processing-instruction>
717
*/
718
typedef struct _xsltStyleItemPI xsltStyleItemPI;
719
typedef xsltStyleItemPI *xsltStyleItemPIPtr;
720
721
struct _xsltStyleItemPI {
722
XSLT_ITEM_COMMON_FIELDS
723
const xmlChar *name;
724
int has_name;
725
};
726
727
/**
728
* xsltStyleItemApplyImports:
729
*
730
* <!-- Category: instruction -->
731
* <xsl:apply-imports />
732
*/
733
typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
734
typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
735
736
/**
737
* xsltStyleItemApplyTemplates:
738
*
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>
745
*/
746
typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
747
typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
748
749
struct _xsltStyleItemApplyTemplates {
750
XSLT_ITEM_COMMON_FIELDS
751
752
const xmlChar *mode; /* apply-templates */
753
const xmlChar *modeURI; /* apply-templates */
754
const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
755
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
756
/* TODO: with-params */
757
};
758
759
/**
760
* xsltStyleItemCallTemplate:
761
*
762
* <!-- Category: instruction -->
763
* <xsl:call-template
764
* name = qname>
765
* <!-- Content: xsl:with-param* -->
766
* </xsl:call-template>
767
*/
768
typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
769
typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
770
771
struct _xsltStyleItemCallTemplate {
772
XSLT_ITEM_COMMON_FIELDS
773
774
xsltTemplatePtr templ; /* call-template */
775
const xmlChar *name; /* element, attribute, pi */
776
int has_name; /* element, attribute, pi */
777
const xmlChar *ns; /* element */
778
int has_ns; /* element */
779
/* TODO: with-params */
780
};
781
782
/**
783
* xsltStyleItemCopy:
784
*
785
* <!-- Category: instruction -->
786
* <xsl:copy
787
* use-attribute-sets = qnames>
788
* <!-- Content: template -->
789
* </xsl:copy>
790
*/
791
typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
792
typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
793
794
struct _xsltStyleItemCopy {
795
XSLT_ITEM_COMMON_FIELDS
796
const xmlChar *use; /* copy, element */
797
int has_use; /* copy, element */
798
};
799
800
/**
801
* xsltStyleItemIf:
802
*
803
* <!-- Category: instruction -->
804
* <xsl:if
805
* test = boolean-expression>
806
* <!-- Content: template -->
807
* </xsl:if>
808
*/
809
typedef struct _xsltStyleItemIf xsltStyleItemIf;
810
typedef xsltStyleItemIf *xsltStyleItemIfPtr;
811
812
struct _xsltStyleItemIf {
813
XSLT_ITEM_COMMON_FIELDS
814
815
const xmlChar *test; /* if */
816
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
817
};
818
819
820
/**
821
* xsltStyleItemCopyOf:
822
*
823
* <!-- Category: instruction -->
824
* <xsl:copy-of
825
* select = expression />
826
*/
827
typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
828
typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
829
830
/**
831
* xsltStyleItemValueOf:
832
*
833
* <!-- Category: instruction -->
834
* <xsl:value-of
835
* select = string-expression
836
* disable-output-escaping = "yes" | "no" />
837
*/
838
typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
839
typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
840
841
struct _xsltStyleItemValueOf {
842
XSLT_ITEM_COMMON_FIELDS
843
844
const xmlChar *select;
845
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
846
int noescape;
847
};
848
849
/**
850
* xsltStyleItemNumber:
851
*
852
* <!-- Category: instruction -->
853
* <xsl: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 } />
863
*/
864
typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
865
typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
866
867
struct _xsltStyleItemNumber {
868
XSLT_ITEM_COMMON_FIELDS
869
xsltNumberData numdata; /* number */
870
};
871
872
/**
873
* xsltStyleItemChoose:
874
*
875
* <!-- Category: instruction -->
876
* <xsl:choose>
877
* <!-- Content: (xsl:when+, xsl:otherwise?) -->
878
* </xsl:choose>
879
*/
880
typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
881
typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
882
883
/**
884
* xsltStyleItemFallback:
885
*
886
* <!-- Category: instruction -->
887
* <xsl:fallback>
888
* <!-- Content: template -->
889
* </xsl:fallback>
890
*/
891
typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
892
typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
893
894
/**
895
* xsltStyleItemForEach:
896
*
897
* <!-- Category: instruction -->
898
* <xsl:for-each
899
* select = node-set-expression>
900
* <!-- Content: (xsl:sort*, template) -->
901
* </xsl:for-each>
902
*/
903
typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
904
typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
905
906
/**
907
* xsltStyleItemMessage:
908
*
909
* <!-- Category: instruction -->
910
* <xsl:message
911
* terminate = "yes" | "no">
912
* <!-- Content: template -->
913
* </xsl:message>
914
*/
915
typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
916
typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
917
918
struct _xsltStyleItemMessage {
919
XSLT_ITEM_COMMON_FIELDS
920
int terminate;
921
};
922
923
/**
924
* xsltStyleItemDocument:
925
*
926
* NOTE: This is not an instruction of XSLT 1.0.
927
*/
928
typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
929
typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
930
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;
938
};
939
940
/************************************************************************
941
* *
942
* Non-instructions (actually properties of instructions/declarations) *
943
* *
944
************************************************************************/
945
946
/**
947
* xsltStyleBasicItemVariable:
948
*
949
* Basic struct for xsl:variable, xsl:param and xsl:with-param.
950
* It's currently important to have equal fields, 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()).
954
*
955
* FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
956
* have additional different fields.
957
*/
958
typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
959
typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
960
961
struct _xsltStyleBasicItemVariable {
962
XSLT_ITEM_COMMON_FIELDS
963
964
const xmlChar *select;
965
xmlXPathCompExprPtr comp;
966
967
const xmlChar *name;
968
int has_name;
969
const xmlChar *ns;
970
int has_ns;
971
};
972
973
/**
974
* xsltStyleItemVariable:
975
*
976
* <!-- Category: top-level-element -->
977
* <xsl:param
978
* name = qname
979
* select = expression>
980
* <!-- Content: template -->
981
* </xsl:param>
982
*/
983
typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
984
typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
985
986
/**
987
* xsltStyleItemParam:
988
*
989
* <!-- Category: top-level-element -->
990
* <xsl:param
991
* name = qname
992
* select = expression>
993
* <!-- Content: template -->
994
* </xsl:param>
995
*/
996
typedef struct _xsltStyleItemParam xsltStyleItemParam;
997
typedef xsltStyleItemParam *xsltStyleItemParamPtr;
998
999
struct _xsltStyleItemParam {
1000
XSLT_ITEM_COMMON_FIELDS
1001
1002
const xmlChar *select;
1003
xmlXPathCompExprPtr comp;
1004
1005
const xmlChar *name;
1006
int has_name;
1007
const xmlChar *ns;
1008
int has_ns;
1009
};
1010
1011
/**
1012
* xsltStyleItemWithParam:
1013
*
1014
* <xsl:with-param
1015
* name = qname
1016
* select = expression>
1017
* <!-- Content: template -->
1018
* </xsl:with-param>
1019
*/
1020
typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
1021
typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
1022
1023
/**
1024
* xsltStyleItemSort:
1025
*
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" } />
1034
*/
1035
typedef struct _xsltStyleItemSort xsltStyleItemSort;
1036
typedef xsltStyleItemSort *xsltStyleItemSortPtr;
1037
1038
struct _xsltStyleItemSort {
1039
XSLT_ITEM_COMMON_FIELDS
1040
1041
const xmlChar *stype; /* sort */
1042
int has_stype; /* sort */
1043
int number; /* sort */
1044
const xmlChar *order; /* sort */
1045
int has_order; /* sort */
1046
int descending; /* sort */
1047
const xmlChar *lang; /* sort */
1048
int has_lang; /* sort */
1049
const xmlChar *case_order; /* sort */
1050
int lower_first; /* sort */
1051
1052
const xmlChar *use;
1053
int has_use;
1054
1055
const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1056
1057
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1058
};
1059
1060
1061
/**
1062
* xsltStyleItemWhen:
1063
*
1064
* <xsl:when
1065
* test = boolean-expression>
1066
* <!-- Content: template -->
1067
* </xsl:when>
1068
* Allowed parent: xsl:choose
1069
*/
1070
typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
1071
typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
1072
1073
struct _xsltStyleItemWhen {
1074
XSLT_ITEM_COMMON_FIELDS
1075
1076
const xmlChar *test;
1077
xmlXPathCompExprPtr comp;
1078
};
1079
1080
/**
1081
* xsltStyleItemOtherwise:
1082
*
1083
* Allowed parent: xsl:choose
1084
* <xsl:otherwise>
1085
* <!-- Content: template -->
1086
* </xsl:otherwise>
1087
*/
1088
typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
1089
typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
1090
1091
struct _xsltStyleItemOtherwise {
1092
XSLT_ITEM_COMMON_FIELDS
1093
};
1094
1095
typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
1096
typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
1097
1098
struct _xsltStyleItemInclude {
1099
XSLT_ITEM_COMMON_FIELDS
1100
xsltDocumentPtr include;
1101
};
1102
1103
/************************************************************************
1104
* *
1105
* XSLT elements in forwards-compatible mode *
1106
* *
1107
************************************************************************/
1108
1109
typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
1110
typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
1111
struct _xsltStyleItemUknown {
1112
XSLT_ITEM_COMMON_FIELDS
1113
};
1114
1115
1116
/************************************************************************
1117
* *
1118
* Extension elements *
1119
* *
1120
************************************************************************/
1121
1122
/*
1123
* xsltStyleItemExtElement:
1124
*
1125
* Reflects extension elements.
1126
*
1127
* NOTE: Due to the fact that the structure xsltElemPreComp is 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.
1141
*/
1142
typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
1143
typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
1144
struct _xsltStyleItemExtElement {
1145
XSLT_ITEM_COMMON_FIELDS
1146
xsltElemPreCompPtr item;
1147
};
1148
1149
/************************************************************************
1150
* *
1151
* Literal result elements *
1152
* *
1153
************************************************************************/
1154
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;
1162
/*
1163
* Indicates if eclared on the literal result element; dunno if really
1164
* needed.
1165
*/
1166
int holdByElem;
1167
};
1168
1169
/*
1170
* Info for literal result elements.
1171
* This will be set on the elem->psvi field and will 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.
1175
*/
1176
typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
1177
typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
1178
struct _xsltStyleItemLRElementInfo {
1179
XSLT_ITEM_COMMON_FIELDS
1180
/*
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.
1188
*/
1189
xsltEffectiveNsPtr effectiveNs;
1190
1191
};
1192
1193
#ifdef XSLT_REFACTORED
1194
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;
1202
};
1203
#endif
1204
1205
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
1206
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 */
1216
};
1217
#endif
1218
1219
/************************************************************************
1220
* *
1221
* Compile-time structures for *internal* use only *
1222
* *
1223
************************************************************************/
1224
1225
typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
1226
typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
1227
1228
typedef struct _xsltNsList xsltNsList;
1229
typedef xsltNsList *xsltNsListPtr;
1230
struct _xsltNsList {
1231
xsltNsListPtr next; /* next in the list */
1232
xmlNsPtr ns;
1233
};
1234
1235
/*
1236
* xsltVarInfo:
1237
*
1238
* Used at compilation time for parameters and variables.
1239
*/
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;
1248
};
1249
1250
/**
1251
* xsltCompilerNodeInfo:
1252
*
1253
* Per-node information during compile-time.
1254
*/
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;
1273
1274
/* The current info for literal result elements. */
1275
xsltStyleItemLRElementInfoPtr litResElemInfo;
1276
/*
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.
1282
*/
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;
1292
};
1293
1294
/**
1295
* XSLT_CCTXT:
1296
*
1297
* get pointer to compiler context
1298
*/
1299
#define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)
1300
1301
typedef enum {
1302
XSLT_ERROR_SEVERITY_ERROR = 0,
1303
XSLT_ERROR_SEVERITY_WARNING
1304
} xsltErrorSeverityType;
1305
1306
typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
1307
typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
1308
struct _xsltCompilerCtxt {
1309
void *errorCtxt; /* user specific error context */
1310
/*
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 */
1322
1323
xsltCompilerNodeInfoPtr inode;
1324
xsltCompilerNodeInfoPtr inodeList;
1325
xsltCompilerNodeInfoPtr inodeLast;
1326
xsltPointerListPtr tmpList; /* Used for various purposes */
1327
/*
1328
* The XSLT version as specified by the stylesheet's root element.
1329
*/
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 */
1335
/*
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.
1339
*/
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. */
1347
};
1348
1349
#else /* XSLT_REFACTORED */
1350
/*
1351
* The old structures before refactoring.
1352
*/
1353
1354
/**
1355
* _xsltStylePreComp:
1356
*
1357
* The in-memory structure corresponding to XSLT stylesheet constructs
1358
* precomputed data.
1359
*/
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 */
1365
1366
/*
1367
* Pre computed values.
1368
*/
1369
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 */
1380
1381
const xmlChar *use; /* copy, element */
1382
int has_use; /* copy, element */
1383
1384
int noescape; /* text */
1385
1386
const xmlChar *name; /* element, attribute, pi */
1387
int has_name; /* element, attribute, pi */
1388
const xmlChar *ns; /* element */
1389
int has_ns; /* element */
1390
1391
const xmlChar *mode; /* apply-templates */
1392
const xmlChar *modeURI; /* apply-templates */
1393
1394
const xmlChar *test; /* if */
1395
1396
xsltTemplatePtr templ; /* call-template */
1397
1398
const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1399
1400
int ver11; /* document */
1401
const xmlChar *filename; /* document URL */
1402
int has_filename; /* document */
1403
1404
xsltNumberData numdata; /* number */
1405
1406
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1407
xmlNsPtr *nsList; /* the namespaces in scope */
1408
int nsNr; /* the number of namespaces in scope */
1409
};
1410
1411
#endif /* XSLT_REFACTORED */
1412
1413
1414
/*
1415
* The in-memory structure corresponding to an XSLT Variable
1416
* or Param.
1417
*/
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;
1437
};
1438
1439
#ifdef XSLT_REFACTORED
1440
1441
struct _xsltPrincipalStylesheetData {
1442
/*
1443
* Namespace dictionary for ns-prefixes and ns-names:
1444
* TODO: Shared between stylesheets, and XPath mechanisms.
1445
* Not used yet.
1446
*/
1447
xmlDictPtr namespaceDict;
1448
/*
1449
* Global list of in-scope namespaces.
1450
*/
1451
xsltPointerListPtr inScopeNamespaces;
1452
/*
1453
* Global list of information for [xsl:]excluded-result-prefixes.
1454
*/
1455
xsltPointerListPtr exclResultNamespaces;
1456
/*
1457
* Global list of information for [xsl:]extension-element-prefixes.
1458
*/
1459
xsltPointerListPtr extElemNamespaces;
1460
xsltEffectiveNsPtr effectiveNs;
1461
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
1462
/*
1463
* Namespace name map to get rid of string comparison of namespace names.
1464
*/
1465
xsltNsMapPtr nsMap;
1466
#endif
1467
};
1468
1469
1470
#endif
1471
/*
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.
1475
*/
1476
struct _xsltStylesheet {
1477
/*
1478
* The stylesheet import relation is kept as a tree.
1479
*/
1480
struct _xsltStylesheet *parent;
1481
struct _xsltStylesheet *next;
1482
struct _xsltStylesheet *imports;
1483
1484
xsltDocumentPtr docList; /* the include document list */
1485
1486
/*
1487
* General data on the style sheet document.
1488
*/
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 */
1494
1495
/*
1496
* Global variable or parameters.
1497
*/
1498
xsltStackElemPtr variables; /* linked list of param and variables */
1499
1500
/*
1501
* Template descriptions.
1502
*/
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() */
1515
1516
/*
1517
* Namespace aliases.
1518
* NOTE: Not used in the refactored code.
1519
*/
1520
xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
1521
1522
/*
1523
* Attribute sets.
1524
*/
1525
xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
1526
1527
/*
1528
* Namespaces.
1529
* TODO: Eliminate this.
1530
*/
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.
1537
*/
1538
void *nsDefs; /* ATTENTION TODO: This is currently used to store
1539
xsltExtDefPtr (in extensions.c) and
1540
*not* xmlNsPtr.
1541
*/
1542
1543
/*
1544
* Key definitions.
1545
*/
1546
void *keys; /* key definitions */
1547
1548
/*
1549
* Output related stuff.
1550
*/
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" */
1556
1557
/*
1558
* Number formatting.
1559
*/
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 */
1566
1567
/*
1568
* Precomputed blocks.
1569
*/
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 */
1573
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 */
1578
1579
void *_private; /* user defined data */
1580
1581
/*
1582
* Extensions.
1583
*/
1584
xmlHashTablePtr extInfos; /* the extension data */
1585
int extrasNr; /* the number of extras required */
1586
1587
/*
1588
* For keeping track of nested includes
1589
*/
1590
xsltDocumentPtr includes; /* points to last nested include */
1591
1592
/*
1593
* dictionary: shared between stylesheet, context and documents.
1594
*/
1595
xmlDictPtr dict;
1596
/*
1597
* precompiled attribute value templates.
1598
*/
1599
void *attVTs;
1600
/*
1601
* if namespace-alias has an alias for the default stylesheet prefix
1602
* NOTE: Not used in the refactored code.
1603
*/
1604
const xmlChar *defaultAlias;
1605
/*
1606
* bypass pre-processing (already done) (used in imports)
1607
*/
1608
int nopreproc;
1609
/*
1610
* all document text strings were internalized
1611
*/
1612
int internalized;
1613
/*
1614
* Literal Result Element as Stylesheet c.f. section 2.3
1615
*/
1616
int literal_result;
1617
/*
1618
* The principal stylesheet
1619
*/
1620
xsltStylesheetPtr principal;
1621
#ifdef XSLT_REFACTORED
1622
/*
1623
* Compilation context used during compile-time.
1624
*/
1625
xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
1626
1627
xsltPrincipalStylesheetDataPtr principalData;
1628
#endif
1629
/*
1630
* Forwards-compatible processing
1631
*/
1632
int forwards_compatible;
1633
1634
xmlHashTablePtr namedTemplates; /* hash table of named templates */
1635
1636
xmlXPathContextPtr xpathCtxt;
1637
1638
unsigned long opLimit;
1639
unsigned long opCount;
1640
};
1641
1642
typedef struct _xsltTransformCache xsltTransformCache;
1643
typedef xsltTransformCache *xsltTransformCachePtr;
1644
struct _xsltTransformCache {
1645
xmlDocPtr RVT;
1646
int nbRVT;
1647
xsltStackElemPtr stackItems;
1648
int nbStackItems;
1649
#ifdef XSLT_DEBUG_PROFILE_CACHE
1650
int dbgCachedRVTs;
1651
int dbgReusedRVTs;
1652
int dbgCachedVars;
1653
int dbgReusedVars;
1654
#endif
1655
};
1656
1657
/*
1658
* The in-memory structure corresponding to an XSLT Transformation.
1659
*/
1660
typedef enum {
1661
XSLT_OUTPUT_XML = 0,
1662
XSLT_OUTPUT_HTML,
1663
XSLT_OUTPUT_TEXT
1664
} xsltOutputType;
1665
1666
typedef void *
1667
(*xsltNewLocaleFunc)(const xmlChar *lang, int lowerFirst);
1668
typedef void
1669
(*xsltFreeLocaleFunc)(void *locale);
1670
typedef xmlChar *
1671
(*xsltGenSortKeyFunc)(void *locale, const xmlChar *lang);
1672
1673
typedef enum {
1674
XSLT_STATE_OK = 0,
1675
XSLT_STATE_ERROR,
1676
XSLT_STATE_STOPPED
1677
} xsltTransformState;
1678
1679
struct _xsltTransformContext {
1680
xsltStylesheetPtr style; /* the stylesheet used */
1681
xsltOutputType type; /* the type of output */
1682
1683
xsltTemplatePtr templ; /* the current template */
1684
int templNr; /* Nb of templates in the stack */
1685
int templMax; /* Size of the templtes stack */
1686
xsltTemplatePtr *templTab; /* the template stack */
1687
1688
xsltStackElemPtr vars; /* the current variable list */
1689
int varsNr; /* Nb of variable list in the stack */
1690
int varsMax; /* Size of the variable list stack */
1691
xsltStackElemPtr *varsTab; /* the variable list stack */
1692
int varsBase; /* the var base for current templ */
1693
1694
/*
1695
* Extensions
1696
*/
1697
xmlHashTablePtr extFunctions; /* the extension functions */
1698
xmlHashTablePtr extElements; /* the extension elements */
1699
xmlHashTablePtr extInfos; /* the extension data */
1700
1701
const xmlChar *mode; /* the current mode */
1702
const xmlChar *modeURI; /* the current mode URI */
1703
1704
xsltDocumentPtr docList; /* the document list */
1705
1706
xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */
1707
xmlNodePtr node; /* the current node being processed */
1708
xmlNodeSetPtr nodeList; /* the current node list */
1709
/* xmlNodePtr current; the node */
1710
1711
xmlDocPtr output; /* the resulting document */
1712
xmlNodePtr insert; /* the insertion node */
1713
1714
xmlXPathContextPtr xpathCtxt; /* the XPath context */
1715
xsltTransformState state; /* the current state */
1716
1717
/*
1718
* Global variables
1719
*/
1720
xmlHashTablePtr globalVars; /* the global variables and params */
1721
1722
xmlNodePtr inst; /* the instruction in the stylesheet */
1723
1724
int xinclude; /* should XInclude be processed */
1725
1726
const char * outputFile; /* the output URI if known */
1727
1728
int profile; /* is this run profiled */
1729
long prof; /* the current profiled value */
1730
int profNr; /* Nb of templates in the stack */
1731
int profMax; /* Size of the templtaes stack */
1732
long *profTab; /* the profile template stack */
1733
1734
void *_private; /* user defined data */
1735
1736
int extrasNr; /* the number of extras used */
1737
int extrasMax; /* the number of extras allocated */
1738
xsltRuntimeExtraPtr extras; /* extra per runtime information */
1739
1740
xsltDocumentPtr styleList; /* the stylesheet docs list */
1741
void * sec; /* the security preferences if any */
1742
1743
xmlGenericErrorFunc error; /* a specific error handler */
1744
void * errctx; /* context for the error handler */
1745
1746
xsltSortFunc sortfunc; /* a ctxt specific sort routine */
1747
1748
/*
1749
* handling of temporary Result Value Tree
1750
* (XSLT 1.0 term: "Result Tree Fragment")
1751
*/
1752
xmlDocPtr tmpRVT; /* list of RVT without persistance */
1753
xmlDocPtr persistRVT; /* list of persistant RVTs */
1754
int ctxtflags; /* context processing flags */
1755
1756
/*
1757
* Speed optimization when coalescing text nodes
1758
*/
1759
const xmlChar *lasttext; /* last text node content */
1760
int lasttsize; /* last text node size */
1761
int lasttuse; /* last text node use */
1762
/*
1763
* Per Context Debugging
1764
*/
1765
int debugStatus; /* the context level debug status */
1766
unsigned long* traceCode; /* pointer to the variable holding the mask */
1767
1768
int parserOptions; /* parser options xmlParserOption */
1769
1770
/*
1771
* dictionary: shared between stylesheet, context and documents.
1772
*/
1773
xmlDictPtr dict;
1774
xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */
1775
/*
1776
* all document text strings are internalized
1777
*/
1778
int internalized;
1779
int nbKeys;
1780
int hasTemplKeyPatterns;
1781
xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
1782
xmlNodePtr initialContextNode;
1783
xmlDocPtr initialContextDoc;
1784
xsltTransformCachePtr cache;
1785
void *contextVariable; /* the current variable item */
1786
xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
1787
the instruction which created the fragment
1788
exits */
1789
xmlDocPtr localRVTBase; /* Obsolete */
1790
int keyInitLevel; /* Needed to catch recursive keys issues */
1791
int depth; /* Needed to catch recursions */
1792
int maxTemplateDepth;
1793
int maxTemplateVars;
1794
unsigned long opLimit;
1795
unsigned long opCount;
1796
int sourceDocDirty;
1797
unsigned long currentId; /* For generate-id() */
1798
1799
xsltNewLocaleFunc newLocale;
1800
xsltFreeLocaleFunc freeLocale;
1801
xsltGenSortKeyFunc genSortKey;
1802
};
1803
1804
/**
1805
* CHECK_STOPPED:
1806
*
1807
* Macro to check if the XSLT processing should be stopped.
1808
* Will return from the function.
1809
*/
1810
#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
1811
1812
/**
1813
* CHECK_STOPPEDE:
1814
*
1815
* Macro to check if the XSLT processing should be stopped.
1816
* Will goto the error: label.
1817
*/
1818
#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
1819
1820
/**
1821
* CHECK_STOPPED0:
1822
*
1823
* Macro to check if the XSLT processing should be stopped.
1824
* Will return from the function with a 0 value.
1825
*/
1826
#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
1827
1828
/*
1829
* The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
1830
* possible incompatibilities between function pointers and object
1831
* pointers. It is defined in libxml/hash.h within recent versions
1832
* of libxml2, but is put here for compatibility.
1833
*/
1834
#ifndef XML_CAST_FPTR
1835
/**
1836
* XML_CAST_FPTR:
1837
* @fptr: pointer to a function
1838
*
1839
* Macro to do a casting from an object pointer to a
1840
* function pointer without encountering a warning from
1841
* gcc
1842
*
1843
* #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
1844
* This macro violated ISO C aliasing rules (gcc4 on s390 broke)
1845
* so it is disabled now
1846
*/
1847
1848
#define XML_CAST_FPTR(fptr) fptr
1849
#endif
1850
/*
1851
* Functions associated to the internal types
1852
xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
1853
xmlChar *name);
1854
*/
1855
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1856
xsltNewStylesheet (void);
1857
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1858
xsltParseStylesheetFile (const xmlChar* filename);
1859
XSLTPUBFUN void XSLTCALL
1860
xsltFreeStylesheet (xsltStylesheetPtr style);
1861
XSLTPUBFUN int XSLTCALL
1862
xsltIsBlank (xmlChar *str);
1863
XSLTPUBFUN void XSLTCALL
1864
xsltFreeStackElemList (xsltStackElemPtr elem);
1865
XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
1866
xsltDecimalFormatGetByName(xsltStylesheetPtr style,
1867
xmlChar *name);
1868
XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
1869
xsltDecimalFormatGetByQName(xsltStylesheetPtr style,
1870
const xmlChar *nsUri,
1871
const xmlChar *name);
1872
1873
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1874
xsltParseStylesheetProcess(xsltStylesheetPtr ret,
1875
xmlDocPtr doc);
1876
XSLTPUBFUN void XSLTCALL
1877
xsltParseStylesheetOutput(xsltStylesheetPtr style,
1878
xmlNodePtr cur);
1879
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1880
xsltParseStylesheetDoc (xmlDocPtr doc);
1881
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1882
xsltParseStylesheetImportedDoc(xmlDocPtr doc,
1883
xsltStylesheetPtr style);
1884
XSLTPUBFUN int XSLTCALL
1885
xsltParseStylesheetUser(xsltStylesheetPtr style,
1886
xmlDocPtr doc);
1887
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1888
xsltLoadStylesheetPI (xmlDocPtr doc);
1889
XSLTPUBFUN void XSLTCALL
1890
xsltNumberFormat (xsltTransformContextPtr ctxt,
1891
xsltNumberDataPtr data,
1892
xmlNodePtr node);
1893
XSLTPUBFUN xmlXPathError XSLTCALL
1894
xsltFormatNumberConversion(xsltDecimalFormatPtr self,
1895
xmlChar *format,
1896
double number,
1897
xmlChar **result);
1898
1899
XSLTPUBFUN void XSLTCALL
1900
xsltParseTemplateContent(xsltStylesheetPtr style,
1901
xmlNodePtr templ);
1902
XSLTPUBFUN int XSLTCALL
1903
xsltAllocateExtra (xsltStylesheetPtr style);
1904
XSLTPUBFUN int XSLTCALL
1905
xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);
1906
/*
1907
* Extra functions for Result Value Trees
1908
*/
1909
XSLTPUBFUN xmlDocPtr XSLTCALL
1910
xsltCreateRVT (xsltTransformContextPtr ctxt);
1911
XSLTPUBFUN int XSLTCALL
1912
xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,
1913
xmlDocPtr RVT);
1914
XSLTPUBFUN int XSLTCALL
1915
xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,
1916
xmlDocPtr RVT);
1917
XSLTPUBFUN int XSLTCALL
1918
xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,
1919
xmlDocPtr RVT);
1920
XSLTPUBFUN int XSLTCALL
1921
xsltExtensionInstructionResultRegister(
1922
xsltTransformContextPtr ctxt,
1923
xmlXPathObjectPtr obj);
1924
XSLTPUBFUN int XSLTCALL
1925
xsltExtensionInstructionResultFinalize(
1926
xsltTransformContextPtr ctxt);
1927
XSLTPUBFUN int XSLTCALL
1928
xsltFlagRVTs(
1929
xsltTransformContextPtr ctxt,
1930
xmlXPathObjectPtr obj,
1931
int val);
1932
XSLTPUBFUN void XSLTCALL
1933
xsltFreeRVTs (xsltTransformContextPtr ctxt);
1934
XSLTPUBFUN void XSLTCALL
1935
xsltReleaseRVT (xsltTransformContextPtr ctxt,
1936
xmlDocPtr RVT);
1937
/*
1938
* Extra functions for Attribute Value Templates
1939
*/
1940
XSLTPUBFUN void XSLTCALL
1941
xsltCompileAttr (xsltStylesheetPtr style,
1942
xmlAttrPtr attr);
1943
XSLTPUBFUN xmlChar * XSLTCALL
1944
xsltEvalAVT (xsltTransformContextPtr ctxt,
1945
void *avt,
1946
xmlNodePtr node);
1947
XSLTPUBFUN void XSLTCALL
1948
xsltFreeAVTList (void *avt);
1949
1950
/*
1951
* Extra function for successful xsltCleanupGlobals / xsltInit sequence.
1952
*/
1953
1954
XSLTPUBFUN void XSLTCALL
1955
xsltUninit (void);
1956
1957
/************************************************************************
1958
* *
1959
* Compile-time functions for *internal* use only *
1960
* *
1961
************************************************************************/
1962
1963
#ifdef XSLT_REFACTORED
1964
XSLTPUBFUN void XSLTCALL
1965
xsltParseSequenceConstructor(
1966
xsltCompilerCtxtPtr cctxt,
1967
xmlNodePtr start);
1968
XSLTPUBFUN int XSLTCALL
1969
xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,
1970
xmlNodePtr elem);
1971
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
1972
XSLTPUBFUN int XSLTCALL
1973
xsltRestoreDocumentNamespaces(
1974
xsltNsMapPtr ns,
1975
xmlDocPtr doc);
1976
#endif
1977
#endif /* XSLT_REFACTORED */
1978
1979
/************************************************************************
1980
* *
1981
* Transformation-time functions for *internal* use only *
1982
* *
1983
************************************************************************/
1984
XSLTPUBFUN int XSLTCALL
1985
xsltInitCtxtKey (xsltTransformContextPtr ctxt,
1986
xsltDocumentPtr doc,
1987
xsltKeyDefPtr keyd);
1988
XSLTPUBFUN int XSLTCALL
1989
xsltInitAllDocKeys (xsltTransformContextPtr ctxt);
1990
#ifdef __cplusplus
1991
}
1992
#endif
1993
1994
#endif /* __XML_XSLT_H__ */
1995
1996