1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
|
/*
* xsltInternals.h: internal data structures, constants and functions used
* by the XSLT engine.
* They are not part of the API or ABI, i.e. they can change
* without prior notice, use carefully.
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#ifndef __XML_XSLT_INTERNALS_H__
#define __XML_XSLT_INTERNALS_H__
#include "libxml/tree.h"
#include "libxml/hash.h"
#include "libxml/xpath.h"
#include "libxml/xmlerror.h"
#include "libxslt/xslt.h"
#include "xsltexports.h"
#include "numbersInternals.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* XSLT_MAX_SORT:
*
* Max number of specified xsl:sort on an element.
*/
#define XSLT_MAX_SORT 15
/**
* XSLT_PAT_NO_PRIORITY:
*
* Specific value for pattern without priority expressed.
*/
#define XSLT_PAT_NO_PRIORITY -12345789
/**
* xsltRuntimeExtra:
*
* Extra information added to the transformation context.
*/
typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
struct _xsltRuntimeExtra {
void *info; /* pointer to the extra data */
xmlFreeFunc deallocate; /* pointer to the deallocation routine */
void *val; /* data not needing deallocation */
};
/**
* XSLT_RUNTIME_EXTRA_LST:
* @ctxt: the transformation context
* @nr: the index
*
* Macro used to access extra information stored in the context
*/
#define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
/**
* XSLT_RUNTIME_EXTRA_FREE:
* @ctxt: the transformation context
* @nr: the index
*
* Macro used to free extra information stored in the context
*/
#define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
/**
* XSLT_RUNTIME_EXTRA:
* @ctxt: the transformation context
* @nr: the index
*
* Macro used to define extra information stored in the context
*/
#define XSLT_RUNTIME_EXTRA(ctxt, nr) (ctxt)->extras[(nr)].val
/**
* xsltTemplate:
*
* The in-memory structure corresponding to an XSLT Template.
*/
typedef struct _xsltTemplate xsltTemplate;
typedef xsltTemplate *xsltTemplatePtr;
struct _xsltTemplate {
struct _xsltTemplate *next;/* chained list sorted by priority */
struct _xsltStylesheet *style;/* the containing stylesheet */
xmlChar *match; /* the matching string */
float priority; /* as given from the stylesheet, not computed */
xmlChar *name; /* the local part of the name QName */
xmlChar *nameURI; /* the URI part of the name QName */
xmlChar *mode; /* the local part of the mode QName */
xmlChar *modeURI; /* the URI part of the mode QName */
xmlNodePtr content; /* the template replacement value */
xmlNodePtr elem; /* the source element */
int inheritedNsNr; /* number of inherited namespaces */
xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
/* Profiling informations */
int nbCalls; /* the number of time the template was called */
unsigned long time; /* the time spent in this template */
};
/**
* xsltDecimalFormat:
*
* Data structure of decimal-format.
*/
typedef struct _xsltDecimalFormat xsltDecimalFormat;
typedef xsltDecimalFormat *xsltDecimalFormatPtr;
struct _xsltDecimalFormat {
struct _xsltDecimalFormat *next; /* chained list */
xmlChar *name;
/* Used for interpretation of pattern */
xmlChar *digit;
xmlChar *patternSeparator;
/* May appear in result */
xmlChar *minusSign;
xmlChar *infinity;
xmlChar *noNumber; /* Not-a-number */
/* Used for interpretation of pattern and may appear in result */
xmlChar *decimalPoint;
xmlChar *grouping;
xmlChar *percent;
xmlChar *permille;
xmlChar *zeroDigit;
};
/**
* xsltDocument:
*
* Data structure associated to a parsed document.
*/
typedef struct _xsltDocument xsltDocument;
typedef xsltDocument *xsltDocumentPtr;
struct _xsltDocument {
struct _xsltDocument *next; /* documents are kept in a chained list */
int main; /* is this the main document */
xmlDocPtr doc; /* the parsed document */
void *keys; /* key tables storage */
};
typedef struct _xsltTransformContext xsltTransformContext;
typedef xsltTransformContext *xsltTransformContextPtr;
/**
* xsltElemPreComp:
*
* The in-memory structure corresponding to element precomputed data,
* designed to be extended by extension implementors.
*/
typedef struct _xsltElemPreComp xsltElemPreComp;
typedef xsltElemPreComp *xsltElemPreCompPtr;
/**
* xsltTransformFunction:
* @ctxt: the XSLT transformation context
* @node: the input node
* @inst: the stylesheet node
* @comp: the compiled information from the stylesheet
*
* Signature of the function associated to elements part of the
* stylesheet language like xsl:if or xsl:apply-templates.
*/
typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
xmlNodePtr node,
xmlNodePtr inst,
xsltElemPreCompPtr comp);
/**
* xsltSortFunc:
* @ctxt: a transformation context
* @sorts: the node-set to sort
* @nbsorts: the number of sorts
*
* Signature of the function to use during sorting
*/
typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
int nbsorts);
typedef enum {
XSLT_FUNC_COPY=1,
XSLT_FUNC_SORT,
XSLT_FUNC_TEXT,
XSLT_FUNC_ELEMENT,
XSLT_FUNC_ATTRIBUTE,
XSLT_FUNC_COMMENT,
XSLT_FUNC_PI,
XSLT_FUNC_COPYOF,
XSLT_FUNC_VALUEOF,
XSLT_FUNC_NUMBER,
XSLT_FUNC_APPLYIMPORTS,
XSLT_FUNC_CALLTEMPLATE,
XSLT_FUNC_APPLYTEMPLATES,
XSLT_FUNC_CHOOSE,
XSLT_FUNC_IF,
XSLT_FUNC_FOREACH,
XSLT_FUNC_DOCUMENT,
XSLT_FUNC_WITHPARAM,
XSLT_FUNC_PARAM,
XSLT_FUNC_VARIABLE,
XSLT_FUNC_WHEN,
XSLT_FUNC_EXTENSION
} xsltStyleType;
/**
* xsltElemPreCompDeallocator:
* @comp: the #xsltElemPreComp to free up
*
* Deallocates an #xsltElemPreComp structure.
*/
typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
/**
* xsltElemPreComp:
*
* The in-memory structure corresponding to element precomputed data,
* designed to be extended by extension implementors.
*/
struct _xsltElemPreComp {
xsltElemPreCompPtr next; /* chained list */
xsltStyleType type; /* type of the element */
xsltTransformFunction func; /* handling function */
xmlNodePtr inst; /* the instruction */
/* end of common part */
xsltElemPreCompDeallocator free; /* the deallocator */
};
/**
* xsltStylePreComp:
*
* The in-memory structure corresponding to XSLT stylesheet constructs
* precomputed data.
*/
typedef struct _xsltStylePreComp xsltStylePreComp;
typedef xsltStylePreComp *xsltStylePreCompPtr;
struct _xsltStylePreComp {
xsltElemPreCompPtr next; /* chained list */
xsltStyleType type; /* type of the element */
xsltTransformFunction func; /* handling function */
xmlNodePtr inst; /* the instruction */
/*
* Pre computed values.
*/
xmlChar *stype; /* sort */
int has_stype; /* sort */
int number; /* sort */
xmlChar *order; /* sort */
int has_order; /* sort */
int descending; /* sort */
xmlChar *lang; /* sort */
int has_lang; /* sort */
xmlChar *case_order; /* sort */
int lower_first; /* sort */
xmlChar *use; /* copy, element */
int has_use; /* copy, element */
int noescape; /* text */
xmlChar *name; /* element, attribute, pi */
int has_name; /* element, attribute, pi */
xmlChar *ns; /* element */
int has_ns; /* element */
xmlChar *mode; /* apply-templates */
xmlChar *modeURI; /* apply-templates */
xmlChar *test; /* if */
xsltTemplatePtr templ; /* call-template */
xmlChar *select; /* sort, copy-of, value-of, apply-templates */
int ver11; /* document */
xmlChar *filename; /* document URL */
int has_filename; /* document */
xsltNumberData numdata; /* number */
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
xmlNsPtr *nsList; /* the namespaces in scope */
int nsNr; /* the number of namespaces in scope */
};
/*
* The in-memory structure corresponding to an XSLT Variable
* or Param.
*/
typedef struct _xsltStackElem xsltStackElem;
typedef xsltStackElem *xsltStackElemPtr;
struct _xsltStackElem {
struct _xsltStackElem *next;/* chained list */
xsltStylePreCompPtr comp; /* the compiled form */
int computed; /* was the evaluation done */
xmlChar *name; /* the local part of the name QName */
xmlChar *nameURI; /* the URI part of the name QName */
xmlChar *select; /* the eval string */
xmlNodePtr tree; /* the tree if no eval string or the location */
xmlXPathObjectPtr value; /* The value if computed */
};
/*
* The in-memory structure corresponding to an XSLT Stylesheet.
* NOTE: most of the content is simply linked from the doc tree
* structure, no specific allocation is made.
*/
typedef struct _xsltStylesheet xsltStylesheet;
typedef xsltStylesheet *xsltStylesheetPtr;
struct _xsltStylesheet {
/*
* The stylesheet import relation is kept as a tree.
*/
struct _xsltStylesheet *parent;
struct _xsltStylesheet *next;
struct _xsltStylesheet *imports;
xsltDocumentPtr docList; /* the include document list */
/*
* General data on the style sheet document.
*/
xmlDocPtr doc; /* the parsed XML stylesheet */
xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
preserve space elements */
int stripAll; /* strip-space * (1) preserve-space * (-1) */
xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
/*
* Global variable or parameters.
*/
xsltStackElemPtr variables; /* linked list of param and variables */
/*
* Template descriptions.
*/
xsltTemplatePtr templates; /* the ordered list of templates */
void *templatesHash; /* hash table or wherever compiled templates
informations are stored */
void *rootMatch; /* template based on / */
void *keyMatch; /* template based on key() */
void *elemMatch; /* template based on * */
void *attrMatch; /* template based on @* */
void *parentMatch; /* template based on .. */
void *textMatch; /* template based on text() */
void *piMatch; /* template based on processing-instruction() */
void *commentMatch; /* template based on comment() */
/*
* Namespace aliases.
*/
xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
/*
* Attribute sets.
*/
xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
/*
* Namespaces.
*/
xmlHashTablePtr nsHash; /* the set of namespaces in use */
void *nsDefs; /* the namespaces defined */
/*
* Key definitions.
*/
void *keys; /* key definitions */
/*
* Output related stuff.
*/
xmlChar *method; /* the output method */
xmlChar *methodURI; /* associated namespace if any */
xmlChar *version; /* version string */
xmlChar *encoding; /* encoding string */
int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
/*
* Number formatting.
*/
xsltDecimalFormatPtr decimalFormat;
int standalone; /* standalone = "yes" | "no" */
xmlChar *doctypePublic; /* doctype-public string */
xmlChar *doctypeSystem; /* doctype-system string */
int indent; /* should output being indented */
xmlChar *mediaType; /* media-type string */
/*
* Precomputed blocks.
*/
xsltElemPreCompPtr preComps;/* list of precomputed blocks */
int warnings; /* number of warnings found at compilation */
int errors; /* number of errors found at compilation */
xmlChar *exclPrefix; /* last excluded prefixes */
xmlChar **exclPrefixTab; /* array of excluded prefixes */
int exclPrefixNr; /* number of excluded prefixes in scope */
int exclPrefixMax; /* size of the array */
void *_private; /* user defined data */
/*
* Extensions.
*/
xmlHashTablePtr extInfos; /* the extension data */
int extrasNr; /* the number of extras required */
};
/*
* The in-memory structure corresponding to an XSLT Transformation.
*/
typedef enum {
XSLT_OUTPUT_XML = 0,
XSLT_OUTPUT_HTML,
XSLT_OUTPUT_TEXT
} xsltOutputType;
typedef enum {
XSLT_STATE_OK = 0,
XSLT_STATE_ERROR,
XSLT_STATE_STOPPED
} xsltTransformState;
struct _xsltTransformContext {
xsltStylesheetPtr style; /* the stylesheet used */
xsltOutputType type; /* the type of output */
xsltTemplatePtr templ; /* the current template */
int templNr; /* Nb of templates in the stack */
int templMax; /* Size of the templtes stack */
xsltTemplatePtr *templTab; /* the template stack */
xsltStackElemPtr vars; /* the current variable list */
int varsNr; /* Nb of variable list in the stack */
int varsMax; /* Size of the variable list stack */
xsltStackElemPtr *varsTab; /* the variable list stack */
int varsBase; /* the var base for current templ */
/*
* Extensions
*/
xmlHashTablePtr extFunctions; /* the extension functions */
xmlHashTablePtr extElements; /* the extension elements */
xmlHashTablePtr extInfos; /* the extension data */
const xmlChar *mode; /* the current mode */
const xmlChar *modeURI; /* the current mode URI */
xsltDocumentPtr docList; /* the document list */
xsltDocumentPtr document; /* the current document */
xmlNodePtr node; /* the current node being processed */
xmlNodeSetPtr nodeList; /* the current node list */
/* xmlNodePtr current; the node */
xmlDocPtr output; /* the resulting document */
xmlNodePtr insert; /* the insertion node */
xmlXPathContextPtr xpathCtxt; /* the XPath context */
xsltTransformState state; /* the current state */
/*
* Global variables
*/
xmlHashTablePtr globalVars; /* the global variables and params */
xmlNodePtr inst; /* the instruction in the stylesheet */
int xinclude; /* should XInclude be processed */
const char * outputFile; /* the output URI if known */
int profile; /* is this run profiled */
long prof; /* the current profiled value */
int profNr; /* Nb of templates in the stack */
int profMax; /* Size of the templtaes stack */
long *profTab; /* the profile template stack */
void *_private; /* user defined data */
int extrasNr; /* the number of extras used */
int extrasMax; /* the number of extras allocated */
xsltRuntimeExtraPtr extras; /* extra per runtime informations */
xsltDocumentPtr styleList; /* the stylesheet docs list */
void * sec; /* the security preferences if any */
xmlGenericErrorFunc error; /* a specific error handler */
void * errctx; /* context for the error handler */
xsltSortFunc sortfunc; /* a ctxt specific sort routine */
/*
* handling of temporary Result Value Tree
*/
xmlDocPtr tmpRVT; /* list of RVT without persistance */
xmlDocPtr persistRVT; /* list of persistant RVTs */
int ctxtflags; /* context processing flags */
/*
* Speed optimization when coalescing text nodes
*/
const xmlChar *lasttext; /* last text node content */
unsigned int lasttsize; /* last text node size */
unsigned int lasttuse; /* last text node use */
};
/**
* CHECK_STOPPED:
*
* Macro to check if the XSLT processing should be stopped.
* Will return from the function.
*/
#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
/**
* CHECK_STOPPEDE:
*
* Macro to check if the XSLT processing should be stopped.
* Will goto the error: label.
*/
#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
/**
* CHECK_STOPPED0:
*
* Macro to check if the XSLT processing should be stopped.
* Will return from the function with a 0 value.
*/
#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
/*
* Functions associated to the internal types
xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
xmlChar *name);
*/
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
xsltNewStylesheet (void);
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
xsltParseStylesheetFile (const xmlChar* filename);
XSLTPUBFUN void XSLTCALL
xsltFreeStylesheet (xsltStylesheetPtr sheet);
XSLTPUBFUN int XSLTCALL
xsltIsBlank (xmlChar *str);
XSLTPUBFUN void XSLTCALL
xsltFreeStackElemList (xsltStackElemPtr elem);
XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
xmlChar *name);
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
xsltParseStylesheetProcess(xsltStylesheetPtr ret,
xmlDocPtr doc);
XSLTPUBFUN void XSLTCALL
xsltParseStylesheetOutput(xsltStylesheetPtr style,
xmlNodePtr cur);
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
xsltParseStylesheetDoc (xmlDocPtr doc);
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
xsltParseStylesheetImportedDoc(xmlDocPtr doc);
XSLTPUBFUN xsltStylesheetPtr XSLTCALL
xsltLoadStylesheetPI (xmlDocPtr doc);
XSLTPUBFUN void XSLTCALL
xsltNumberFormat (xsltTransformContextPtr ctxt,
xsltNumberDataPtr data,
xmlNodePtr node);
XSLTPUBFUN xmlXPathError XSLTCALL
xsltFormatNumberConversion(xsltDecimalFormatPtr self,
xmlChar *format,
double number,
xmlChar **result);
XSLTPUBFUN void XSLTCALL
xsltParseTemplateContent(xsltStylesheetPtr style,
xmlNodePtr templ);
XSLTPUBFUN int XSLTCALL
xsltAllocateExtra (xsltStylesheetPtr style);
XSLTPUBFUN int XSLTCALL
xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);
/*
* Extra functions for Result Value Trees
*/
XSLTPUBFUN xmlDocPtr XSLTCALL
xsltCreateRVT (xsltTransformContextPtr ctxt);
XSLTPUBFUN int XSLTCALL
xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,
xmlDocPtr RVT);
XSLTPUBFUN int XSLTCALL
xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,
xmlDocPtr RVT);
XSLTPUBFUN void XSLTCALL
xsltFreeRVTs (xsltTransformContextPtr ctxt);
#ifdef __cplusplus
}
#endif
#endif /* __XML_XSLT_H__ */
|