content_server 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/bin/backup_server +8 -20
  2. data/bin/content_server +8 -20
  3. data/bin/testing_memory +60 -0
  4. data/bin/testing_server +57 -0
  5. data/ext/run_in_background/mkrf_conf.rb +34 -0
  6. data/lib/content_data/content_data.rb +613 -0
  7. data/lib/content_data/version.rb +3 -0
  8. data/lib/content_data.rb +6 -0
  9. data/lib/content_server/backup_server.rb +65 -86
  10. data/lib/content_server/content_server.rb +47 -77
  11. data/lib/content_server/file_streamer.rb +27 -33
  12. data/lib/content_server/queue_copy.rb +154 -49
  13. data/lib/content_server/queue_indexer.rb +19 -11
  14. data/lib/content_server/remote_content.rb +41 -23
  15. data/lib/content_server/server.rb +91 -0
  16. data/lib/content_server/version.rb +1 -1
  17. data/lib/content_server.rb +0 -15
  18. data/lib/email/email.rb +87 -0
  19. data/lib/email/version.rb +3 -0
  20. data/lib/email.rb +4 -0
  21. data/lib/file_copy/copy.rb +68 -0
  22. data/lib/file_copy/version.rb +4 -0
  23. data/lib/file_copy.rb +4 -0
  24. data/lib/file_indexing/index_agent.rb +170 -0
  25. data/lib/file_indexing/indexer_patterns.rb +72 -0
  26. data/lib/file_indexing/version.rb +3 -0
  27. data/lib/file_indexing.rb +9 -0
  28. data/lib/file_monitoring/file_monitoring.rb +105 -0
  29. data/lib/file_monitoring/monitor_path.rb +304 -0
  30. data/lib/file_monitoring/version.rb +3 -0
  31. data/lib/file_monitoring.rb +29 -0
  32. data/lib/file_utils/file_generator/README +97 -0
  33. data/lib/file_utils/file_generator/file_generator.rb +156 -0
  34. data/lib/file_utils/file_utils.rb +260 -0
  35. data/lib/file_utils/version.rb +3 -0
  36. data/lib/file_utils.rb +4 -0
  37. data/lib/log/version.rb +3 -0
  38. data/lib/log.rb +188 -0
  39. data/lib/networking/tcp.rb +213 -0
  40. data/lib/networking/version.rb +3 -0
  41. data/lib/networking.rb +4 -0
  42. data/lib/params/version.rb +3 -0
  43. data/lib/params.rb +419 -0
  44. data/lib/process_monitoring/monitoring.rb +85 -0
  45. data/lib/process_monitoring/monitoring_info.rb +79 -0
  46. data/lib/process_monitoring/send_email.rb +40 -0
  47. data/lib/process_monitoring/thread_safe_hash.rb +77 -0
  48. data/lib/process_monitoring/version.rb +3 -0
  49. data/lib/process_monitoring.rb +6 -0
  50. data/lib/run_in_background/version.rb +3 -0
  51. data/lib/run_in_background.rb +432 -0
  52. data/lib/testing_memory/testing_memory.rb +187 -0
  53. data/lib/testing_server/testing_server.rb +236 -0
  54. data/lib/testing_server/version.rb +3 -0
  55. data/lib/testing_server.rb +12 -0
  56. data/lib/validations/index_validations.rb +106 -0
  57. data/lib/validations/version.rb +3 -0
  58. data/lib/validations.rb +4 -0
  59. data/spec/content_data/validations_spec.rb +113 -0
  60. data/spec/file_copy/copy_spec.rb +54 -0
  61. data/spec/file_indexing/index_agent_spec.rb +53 -0
  62. data/spec/networking/tcp_spec.rb +95 -0
  63. data/spec/validations/index_validations_spec.rb +77 -0
  64. data/test/content_data/content_data_test.rb +290 -0
  65. data/test/file_generator/file_generator_spec.rb +84 -0
  66. data/test/file_indexing/index_agent_test/New.txt +0 -0
  67. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libexslt.dll +0 -0
  68. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libxslt.dll +0 -0
  69. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/xsltproc.exe +0 -0
  70. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exslt.h +102 -0
  71. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltconfig.h +73 -0
  72. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltexports.h +140 -0
  73. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/libexslt.h +29 -0
  74. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/attributes.h +38 -0
  75. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/documents.h +93 -0
  76. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extensions.h +262 -0
  77. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extra.h +80 -0
  78. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/functions.h +78 -0
  79. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/imports.h +75 -0
  80. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/keys.h +53 -0
  81. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/libxslt.h +30 -0
  82. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/namespaces.h +68 -0
  83. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/numbersInternals.h +69 -0
  84. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/pattern.h +81 -0
  85. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/preproc.h +43 -0
  86. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/security.h +104 -0
  87. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/templates.h +77 -0
  88. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/transform.h +207 -0
  89. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/trio.h +216 -0
  90. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/triodef.h +220 -0
  91. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/variables.h +91 -0
  92. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/win32config.h +101 -0
  93. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xslt.h +103 -0
  94. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltInternals.h +1967 -0
  95. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltconfig.h +172 -0
  96. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltexports.h +142 -0
  97. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltlocale.h +57 -0
  98. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltutils.h +309 -0
  99. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltwin32config.h +105 -0
  100. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt.lib +0 -0
  101. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt_a.lib +0 -0
  102. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt.lib +0 -0
  103. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt_a.lib +0 -0
  104. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/readme.txt +22 -0
  105. data/test/file_indexing/index_agent_test/patterns.input +3 -0
  106. data/test/file_indexing/index_agent_test.rb +51 -0
  107. data/test/file_monitoring/file_monitoring_test/conf.yml +4 -0
  108. data/test/file_monitoring/file_monitoring_test/conf_win32.yml +5 -0
  109. data/test/file_monitoring/file_monitoring_test/log +56 -0
  110. data/test/file_monitoring/file_monitoring_test.rb +0 -0
  111. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000 +1000 -0
  112. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000.0 +1000 -0
  113. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000.1 +1000 -0
  114. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500 +1500 -0
  115. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500.0 +1500 -0
  116. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500.1 +1500 -0
  117. data/test/file_monitoring/monitor_path_test/test_file.500 +500 -0
  118. data/test/file_monitoring/monitor_path_test/test_file.500.0 +500 -0
  119. data/test/file_monitoring/monitor_path_test/test_file.500.1 +500 -0
  120. data/test/file_monitoring/monitor_path_test.rb +153 -0
  121. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500 +1500 -0
  122. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.0 +1500 -0
  123. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.1 +1500 -0
  124. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000 +1000 -0
  125. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.0 +1000 -0
  126. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.1 +1000 -0
  127. data/test/file_utils/fileutil_mksymlink_test/test_file.500 +500 -0
  128. data/test/file_utils/fileutil_mksymlink_test/test_file.500.0 +500 -0
  129. data/test/file_utils/fileutil_mksymlink_test/test_file.500.1 +500 -0
  130. data/test/file_utils/fileutil_mksymlink_test.rb +125 -0
  131. data/test/file_utils/time_modification_test.rb +132 -0
  132. data/test/params/params_spec.rb +280 -0
  133. data/test/params/params_test.rb +43 -0
  134. data/test/run_in_background/run_in_background_test.rb +122 -0
  135. data/test/run_in_background/test_app +57 -0
  136. metadata +272 -132
  137. data/lib/content_server/globals.rb +0 -10
@@ -0,0 +1,1967 @@
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 "xsltlocale.h"
25
+ #include "numbersInternals.h"
26
+
27
+ #ifdef __cplusplus
28
+ extern "C" {
29
+ #endif
30
+
31
+ /* #define XSLT_DEBUG_PROFILE_CACHE */
32
+
33
+ /**
34
+ * XSLT_IS_TEXT_NODE:
35
+ *
36
+ * check if the argument is a text node
37
+ */
38
+ #define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
39
+ (((n)->type == XML_TEXT_NODE) || \
40
+ ((n)->type == XML_CDATA_SECTION_NODE)))
41
+
42
+
43
+ /**
44
+ * XSLT_MARK_RES_TREE_FRAG:
45
+ *
46
+ * internal macro to set up tree fragments
47
+ */
48
+ #define XSLT_MARK_RES_TREE_FRAG(n) \
49
+ (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
50
+
51
+ /**
52
+ * XSLT_IS_RES_TREE_FRAG:
53
+ *
54
+ * internal macro to test tree fragments
55
+ */
56
+ #define XSLT_IS_RES_TREE_FRAG(n) \
57
+ ((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
58
+ ((n)->name != NULL) && ((n)->name[0] == ' '))
59
+
60
+ /**
61
+ * XSLT_REFACTORED_KEYCOMP:
62
+ *
63
+ * Internal define to enable on-demand xsl:key computation.
64
+ * That's the only mode now but the define is kept for compatibility
65
+ */
66
+ #define XSLT_REFACTORED_KEYCOMP
67
+
68
+ /**
69
+ * XSLT_FAST_IF:
70
+ *
71
+ * Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
72
+ * for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
73
+ */
74
+ #define XSLT_FAST_IF
75
+
76
+ /**
77
+ * XSLT_REFACTORED:
78
+ *
79
+ * Internal define to enable the refactored parts of Libxslt.
80
+ */
81
+ /* #define XSLT_REFACTORED */
82
+ /* ==================================================================== */
83
+
84
+ /**
85
+ * XSLT_REFACTORED_VARS:
86
+ *
87
+ * Internal define to enable the refactored variable part of libxslt
88
+ */
89
+ #define XSLT_REFACTORED_VARS
90
+
91
+ #ifdef XSLT_REFACTORED
92
+
93
+ extern const xmlChar *xsltXSLTAttrMarker;
94
+
95
+
96
+ /* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
97
+
98
+ /* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
99
+
100
+ /**
101
+ * XSLT_REFACTORED_XSLT_NSCOMP
102
+ *
103
+ * Internal define to enable the pointer-comparison of
104
+ * namespaces of XSLT elements.
105
+ */
106
+ /* #define XSLT_REFACTORED_XSLT_NSCOMP */
107
+
108
+ /**
109
+ * XSLT_REFACTORED_XPATHCOMP:
110
+ *
111
+ * Internal define to enable the optimization of the
112
+ * compilation of XPath expressions.
113
+ */
114
+ #define XSLT_REFACTORED_XPATHCOMP
115
+
116
+ #ifdef XSLT_REFACTORED_XSLT_NSCOMP
117
+
118
+ extern const xmlChar *xsltConstNamespaceNameXSLT;
119
+
120
+ /**
121
+ * IS_XSLT_ELEM_FAST:
122
+ *
123
+ * quick test to detect XSLT elements
124
+ */
125
+ #define IS_XSLT_ELEM_FAST(n) \
126
+ (((n) != NULL) && ((n)->ns != NULL) && \
127
+ ((n)->ns->href == xsltConstNamespaceNameXSLT))
128
+
129
+ /**
130
+ * IS_XSLT_ATTR_FAST:
131
+ *
132
+ * quick test to detect XSLT attributes
133
+ */
134
+ #define IS_XSLT_ATTR_FAST(a) \
135
+ (((a) != NULL) && ((a)->ns != NULL) && \
136
+ ((a)->ns->href == xsltConstNamespaceNameXSLT))
137
+
138
+ /**
139
+ * XSLT_HAS_INTERNAL_NSMAP:
140
+ *
141
+ * check for namespace mapping
142
+ */
143
+ #define XSLT_HAS_INTERNAL_NSMAP(s) \
144
+ (((s) != NULL) && ((s)->principal) && \
145
+ ((s)->principal->principalData) && \
146
+ ((s)->principal->principalData->nsMap))
147
+
148
+ /**
149
+ * XSLT_GET_INTERNAL_NSMAP:
150
+ *
151
+ * get pointer to namespace map
152
+ */
153
+ #define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
154
+
155
+ #else /* XSLT_REFACTORED_XSLT_NSCOMP */
156
+
157
+ /**
158
+ * IS_XSLT_ELEM_FAST:
159
+ *
160
+ * quick check whether this is an xslt element
161
+ */
162
+ #define IS_XSLT_ELEM_FAST(n) \
163
+ (((n) != NULL) && ((n)->ns != NULL) && \
164
+ (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
165
+
166
+ /**
167
+ * IS_XSLT_ATTR_FAST:
168
+ *
169
+ * quick check for xslt namespace attribute
170
+ */
171
+ #define IS_XSLT_ATTR_FAST(a) \
172
+ (((a) != NULL) && ((a)->ns != NULL) && \
173
+ (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
174
+
175
+
176
+ #endif /* XSLT_REFACTORED_XSLT_NSCOMP */
177
+
178
+
179
+ /**
180
+ * XSLT_REFACTORED_MANDATORY_VERSION:
181
+ *
182
+ * TODO: Currently disabled to surpress regression test failures, since
183
+ * the old behaviour was that a missing version attribute
184
+ * produced a only a warning and not an error, which was incerrect.
185
+ * So the regression tests need to be fixed if this is enabled.
186
+ */
187
+ /* #define XSLT_REFACTORED_MANDATORY_VERSION */
188
+
189
+ /**
190
+ * xsltPointerList:
191
+ *
192
+ * Pointer-list for various purposes.
193
+ */
194
+ typedef struct _xsltPointerList xsltPointerList;
195
+ typedef xsltPointerList *xsltPointerListPtr;
196
+ struct _xsltPointerList {
197
+ void **items;
198
+ int number;
199
+ int size;
200
+ };
201
+
202
+ #endif
203
+
204
+ /**
205
+ * XSLT_REFACTORED_PARSING:
206
+ *
207
+ * Internal define to enable the refactored parts of Libxslt
208
+ * related to parsing.
209
+ */
210
+ /* #define XSLT_REFACTORED_PARSING */
211
+
212
+ /**
213
+ * XSLT_MAX_SORT:
214
+ *
215
+ * Max number of specified xsl:sort on an element.
216
+ */
217
+ #define XSLT_MAX_SORT 15
218
+
219
+ /**
220
+ * XSLT_PAT_NO_PRIORITY:
221
+ *
222
+ * Specific value for pattern without priority expressed.
223
+ */
224
+ #define XSLT_PAT_NO_PRIORITY -12345789
225
+
226
+ /**
227
+ * xsltRuntimeExtra:
228
+ *
229
+ * Extra information added to the transformation context.
230
+ */
231
+ typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
232
+ typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
233
+ struct _xsltRuntimeExtra {
234
+ void *info; /* pointer to the extra data */
235
+ xmlFreeFunc deallocate; /* pointer to the deallocation routine */
236
+ union { /* dual-purpose field */
237
+ void *ptr; /* data not needing deallocation */
238
+ int ival; /* integer value storage */
239
+ } val;
240
+ };
241
+
242
+ /**
243
+ * XSLT_RUNTIME_EXTRA_LST:
244
+ * @ctxt: the transformation context
245
+ * @nr: the index
246
+ *
247
+ * Macro used to access extra information stored in the context
248
+ */
249
+ #define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
250
+ /**
251
+ * XSLT_RUNTIME_EXTRA_FREE:
252
+ * @ctxt: the transformation context
253
+ * @nr: the index
254
+ *
255
+ * Macro used to free extra information stored in the context
256
+ */
257
+ #define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
258
+ /**
259
+ * XSLT_RUNTIME_EXTRA:
260
+ * @ctxt: the transformation context
261
+ * @nr: the index
262
+ *
263
+ * Macro used to define extra information stored in the context
264
+ */
265
+ #define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
266
+
267
+ /**
268
+ * xsltTemplate:
269
+ *
270
+ * The in-memory structure corresponding to an XSLT Template.
271
+ */
272
+ typedef struct _xsltTemplate xsltTemplate;
273
+ typedef xsltTemplate *xsltTemplatePtr;
274
+ struct _xsltTemplate {
275
+ struct _xsltTemplate *next;/* chained list sorted by priority */
276
+ struct _xsltStylesheet *style;/* the containing stylesheet */
277
+ xmlChar *match; /* the matching string */
278
+ float priority; /* as given from the stylesheet, not computed */
279
+ const xmlChar *name; /* the local part of the name QName */
280
+ const xmlChar *nameURI; /* the URI part of the name QName */
281
+ const xmlChar *mode;/* the local part of the mode QName */
282
+ const xmlChar *modeURI;/* the URI part of the mode QName */
283
+ xmlNodePtr content; /* the template replacement value */
284
+ xmlNodePtr elem; /* the source element */
285
+
286
+ /*
287
+ * TODO: @inheritedNsNr and @inheritedNs won't be used in the
288
+ * refactored code.
289
+ */
290
+ int inheritedNsNr; /* number of inherited namespaces */
291
+ xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
292
+
293
+ /* Profiling informations */
294
+ int nbCalls; /* the number of time the template was called */
295
+ unsigned long time; /* the time spent in this template */
296
+ void *params; /* xsl:param instructions */
297
+ };
298
+
299
+ /**
300
+ * xsltDecimalFormat:
301
+ *
302
+ * Data structure of decimal-format.
303
+ */
304
+ typedef struct _xsltDecimalFormat xsltDecimalFormat;
305
+ typedef xsltDecimalFormat *xsltDecimalFormatPtr;
306
+ struct _xsltDecimalFormat {
307
+ struct _xsltDecimalFormat *next; /* chained list */
308
+ xmlChar *name;
309
+ /* Used for interpretation of pattern */
310
+ xmlChar *digit;
311
+ xmlChar *patternSeparator;
312
+ /* May appear in result */
313
+ xmlChar *minusSign;
314
+ xmlChar *infinity;
315
+ xmlChar *noNumber; /* Not-a-number */
316
+ /* Used for interpretation of pattern and may appear in result */
317
+ xmlChar *decimalPoint;
318
+ xmlChar *grouping;
319
+ xmlChar *percent;
320
+ xmlChar *permille;
321
+ xmlChar *zeroDigit;
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 hold 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 hold 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
+ xsltLocale locale; /* sort */
1050
+ const xmlChar *case_order; /* sort */
1051
+ int lower_first; /* sort */
1052
+
1053
+ const xmlChar *use;
1054
+ int has_use;
1055
+
1056
+ const xmlChar *select; /* sort, copy-of, value-of, apply-templates */
1057
+
1058
+ xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
1059
+ };
1060
+
1061
+
1062
+ /**
1063
+ * xsltStyleItemWhen:
1064
+ *
1065
+ * <xsl:when
1066
+ * test = boolean-expression>
1067
+ * <!-- Content: template -->
1068
+ * </xsl:when>
1069
+ * Allowed parent: xsl:choose
1070
+ */
1071
+ typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
1072
+ typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
1073
+
1074
+ struct _xsltStyleItemWhen {
1075
+ XSLT_ITEM_COMMON_FIELDS
1076
+
1077
+ const xmlChar *test;
1078
+ xmlXPathCompExprPtr comp;
1079
+ };
1080
+
1081
+ /**
1082
+ * xsltStyleItemOtherwise:
1083
+ *
1084
+ * Allowed parent: xsl:choose
1085
+ * <xsl:otherwise>
1086
+ * <!-- Content: template -->
1087
+ * </xsl:otherwise>
1088
+ */
1089
+ typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
1090
+ typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
1091
+
1092
+ struct _xsltStyleItemOtherwise {
1093
+ XSLT_ITEM_COMMON_FIELDS
1094
+ };
1095
+
1096
+ typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
1097
+ typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
1098
+
1099
+ struct _xsltStyleItemInclude {
1100
+ XSLT_ITEM_COMMON_FIELDS
1101
+ xsltDocumentPtr include;
1102
+ };
1103
+
1104
+ /************************************************************************
1105
+ * *
1106
+ * XSLT elements in forwards-compatible mode *
1107
+ * *
1108
+ ************************************************************************/
1109
+
1110
+ typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
1111
+ typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
1112
+ struct _xsltStyleItemUknown {
1113
+ XSLT_ITEM_COMMON_FIELDS
1114
+ };
1115
+
1116
+
1117
+ /************************************************************************
1118
+ * *
1119
+ * Extension elements *
1120
+ * *
1121
+ ************************************************************************/
1122
+
1123
+ /*
1124
+ * xsltStyleItemExtElement:
1125
+ *
1126
+ * Reflects extension elements.
1127
+ *
1128
+ * NOTE: Due to the fact that the structure xsltElemPreComp is most
1129
+ * probably already heavily in use out there by users, so we cannot
1130
+ * easily change it, we'll create an intermediate structure which will
1131
+ * hold an xsltElemPreCompPtr.
1132
+ * BIG NOTE: The only problem I see here is that the user processes the
1133
+ * content of the stylesheet tree, possibly he'll lookup the node->psvi
1134
+ * fields in order to find subsequent extension functions.
1135
+ * In this case, the user's code will break, since the node->psvi
1136
+ * field will hold now the xsltStyleItemExtElementPtr and not
1137
+ * the xsltElemPreCompPtr.
1138
+ * However the place where the structure is anchored in the node-tree,
1139
+ * namely node->psvi, has beed already once been moved from node->_private
1140
+ * to node->psvi, so we have a precedent here, which, I think, should allow
1141
+ * us to change such semantics without headaches.
1142
+ */
1143
+ typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
1144
+ typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
1145
+ struct _xsltStyleItemExtElement {
1146
+ XSLT_ITEM_COMMON_FIELDS
1147
+ xsltElemPreCompPtr item;
1148
+ };
1149
+
1150
+ /************************************************************************
1151
+ * *
1152
+ * Literal result elements *
1153
+ * *
1154
+ ************************************************************************/
1155
+
1156
+ typedef struct _xsltEffectiveNs xsltEffectiveNs;
1157
+ typedef xsltEffectiveNs *xsltEffectiveNsPtr;
1158
+ struct _xsltEffectiveNs {
1159
+ xsltEffectiveNsPtr nextInStore; /* storage next */
1160
+ xsltEffectiveNsPtr next; /* next item in the list */
1161
+ const xmlChar *prefix;
1162
+ const xmlChar *nsName;
1163
+ /*
1164
+ * Indicates if eclared on the literal result element; dunno if really
1165
+ * needed.
1166
+ */
1167
+ int holdByElem;
1168
+ };
1169
+
1170
+ /*
1171
+ * Info for literal result elements.
1172
+ * This will be set on the elem->psvi field and will be
1173
+ * shared by literal result elements, which have the same
1174
+ * excluded result namespaces; i.e., this *won't* be created uniquely
1175
+ * for every literal result element.
1176
+ */
1177
+ typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
1178
+ typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
1179
+ struct _xsltStyleItemLRElementInfo {
1180
+ XSLT_ITEM_COMMON_FIELDS
1181
+ /*
1182
+ * @effectiveNs is the set of effective ns-nodes
1183
+ * on the literal result element, which will be added to the result
1184
+ * element if not already existing in the result tree.
1185
+ * This means that excluded namespaces (via exclude-result-prefixes,
1186
+ * extension-element-prefixes and the XSLT namespace) not added
1187
+ * to the set.
1188
+ * Namespace-aliasing was applied on the @effectiveNs.
1189
+ */
1190
+ xsltEffectiveNsPtr effectiveNs;
1191
+
1192
+ };
1193
+
1194
+ #ifdef XSLT_REFACTORED
1195
+
1196
+ typedef struct _xsltNsAlias xsltNsAlias;
1197
+ typedef xsltNsAlias *xsltNsAliasPtr;
1198
+ struct _xsltNsAlias {
1199
+ xsltNsAliasPtr next; /* next in the list */
1200
+ xmlNsPtr literalNs;
1201
+ xmlNsPtr targetNs;
1202
+ xmlDocPtr docOfTargetNs;
1203
+ };
1204
+ #endif
1205
+
1206
+ #ifdef XSLT_REFACTORED_XSLT_NSCOMP
1207
+
1208
+ typedef struct _xsltNsMap xsltNsMap;
1209
+ typedef xsltNsMap *xsltNsMapPtr;
1210
+ struct _xsltNsMap {
1211
+ xsltNsMapPtr next; /* next in the list */
1212
+ xmlDocPtr doc;
1213
+ xmlNodePtr elem; /* the element holding the ns-decl */
1214
+ xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
1215
+ const xmlChar *origNsName; /* the original XML namespace name */
1216
+ const xmlChar *newNsName; /* the mapped XML namespace name */
1217
+ };
1218
+ #endif
1219
+
1220
+ /************************************************************************
1221
+ * *
1222
+ * Compile-time structures for *internal* use only *
1223
+ * *
1224
+ ************************************************************************/
1225
+
1226
+ typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
1227
+ typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
1228
+
1229
+ typedef struct _xsltNsList xsltNsList;
1230
+ typedef xsltNsList *xsltNsListPtr;
1231
+ struct _xsltNsList {
1232
+ xsltNsListPtr next; /* next in the list */
1233
+ xmlNsPtr ns;
1234
+ };
1235
+
1236
+ /*
1237
+ * xsltVarInfo:
1238
+ *
1239
+ * Used at compilation time for parameters and variables.
1240
+ */
1241
+ typedef struct _xsltVarInfo xsltVarInfo;
1242
+ typedef xsltVarInfo *xsltVarInfoPtr;
1243
+ struct _xsltVarInfo {
1244
+ xsltVarInfoPtr next; /* next in the list */
1245
+ xsltVarInfoPtr prev;
1246
+ int depth; /* the depth in the tree */
1247
+ const xmlChar *name;
1248
+ const xmlChar *nsName;
1249
+ };
1250
+
1251
+ /**
1252
+ * xsltCompilerNodeInfo:
1253
+ *
1254
+ * Per-node information during compile-time.
1255
+ */
1256
+ typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
1257
+ typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
1258
+ struct _xsltCompilerNodeInfo {
1259
+ xsltCompilerNodeInfoPtr next;
1260
+ xsltCompilerNodeInfoPtr prev;
1261
+ xmlNodePtr node;
1262
+ int depth;
1263
+ xsltTemplatePtr templ; /* The owning template */
1264
+ int category; /* XSLT element, LR-element or
1265
+ extension element */
1266
+ xsltStyleType type;
1267
+ xsltElemPreCompPtr item; /* The compiled information */
1268
+ /* The current in-scope namespaces */
1269
+ xsltNsListContainerPtr inScopeNs;
1270
+ /* The current excluded result namespaces */
1271
+ xsltPointerListPtr exclResultNs;
1272
+ /* The current extension instruction namespaces */
1273
+ xsltPointerListPtr extElemNs;
1274
+
1275
+ /* The current info for literal result elements. */
1276
+ xsltStyleItemLRElementInfoPtr litResElemInfo;
1277
+ /*
1278
+ * Set to 1 if in-scope namespaces changed,
1279
+ * or excluded result namespaces changed,
1280
+ * or extension element namespaces changed.
1281
+ * This will trigger creation of new infos
1282
+ * for literal result elements.
1283
+ */
1284
+ int nsChanged;
1285
+ int preserveWhitespace;
1286
+ int stripWhitespace;
1287
+ int isRoot; /* whether this is the stylesheet's root node */
1288
+ int forwardsCompat; /* whether forwards-compatible mode is enabled */
1289
+ /* whether the content of an extension element was processed */
1290
+ int extContentHandled;
1291
+ /* the type of the current child */
1292
+ xsltStyleType curChildType;
1293
+ };
1294
+
1295
+ /**
1296
+ * XSLT_CCTXT:
1297
+ *
1298
+ * get pointer to compiler context
1299
+ */
1300
+ #define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt)
1301
+
1302
+ typedef enum {
1303
+ XSLT_ERROR_SEVERITY_ERROR = 0,
1304
+ XSLT_ERROR_SEVERITY_WARNING
1305
+ } xsltErrorSeverityType;
1306
+
1307
+ typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
1308
+ typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
1309
+ struct _xsltCompilerCtxt {
1310
+ void *errorCtxt; /* user specific error context */
1311
+ /*
1312
+ * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
1313
+ xsltErrorSeverityType errSeverity;
1314
+ int warnings; /* TODO: number of warnings found at
1315
+ compilation */
1316
+ int errors; /* TODO: number of errors found at
1317
+ compilation */
1318
+ xmlDictPtr dict;
1319
+ xsltStylesheetPtr style;
1320
+ int simplified; /* whether this is a simplified stylesheet */
1321
+ /* TODO: structured/unstructured error contexts. */
1322
+ int depth; /* Current depth of processing */
1323
+
1324
+ xsltCompilerNodeInfoPtr inode;
1325
+ xsltCompilerNodeInfoPtr inodeList;
1326
+ xsltCompilerNodeInfoPtr inodeLast;
1327
+ xsltPointerListPtr tmpList; /* Used for various purposes */
1328
+ /*
1329
+ * The XSLT version as specified by the stylesheet's root element.
1330
+ */
1331
+ int isInclude;
1332
+ int hasForwardsCompat; /* whether forwards-compatible mode was used
1333
+ in a parsing episode */
1334
+ int maxNodeInfos; /* TEMP TODO: just for the interest */
1335
+ int maxLREs; /* TEMP TODO: just for the interest */
1336
+ /*
1337
+ * In order to keep the old behaviour, applying strict rules of
1338
+ * the spec can be turned off. This has effect only on special
1339
+ * mechanisms like whitespace-stripping in the stylesheet.
1340
+ */
1341
+ int strict;
1342
+ xsltPrincipalStylesheetDataPtr psData;
1343
+ #ifdef XSLT_REFACTORED_XPATHCOMP
1344
+ xmlXPathContextPtr xpathCtxt;
1345
+ #endif
1346
+ xsltStyleItemUknownPtr unknownItem;
1347
+ int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
1348
+ xsltNsAliasPtr nsAliases;
1349
+ xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
1350
+ xsltVarInfoPtr ivar; /* topmost local variable/param. */
1351
+ };
1352
+
1353
+ #else /* XSLT_REFACTORED */
1354
+ /*
1355
+ * The old structures before refactoring.
1356
+ */
1357
+
1358
+ /**
1359
+ * _xsltStylePreComp:
1360
+ *
1361
+ * The in-memory structure corresponding to XSLT stylesheet constructs
1362
+ * precomputed data.
1363
+ */
1364
+ struct _xsltStylePreComp {
1365
+ xsltElemPreCompPtr next; /* chained list */
1366
+ xsltStyleType type; /* type of the element */
1367
+ xsltTransformFunction func; /* handling function */
1368
+ xmlNodePtr inst; /* the instruction */
1369
+
1370
+ /*
1371
+ * Pre computed values.
1372
+ */
1373
+
1374
+ const xmlChar *stype; /* sort */
1375
+ int has_stype; /* sort */
1376
+ int number; /* sort */
1377
+ const xmlChar *order; /* sort */
1378
+ int has_order; /* sort */
1379
+ int descending; /* sort */
1380
+ const xmlChar *lang; /* sort */
1381
+ int has_lang; /* sort */
1382
+ xsltLocale locale; /* 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
+ /*
1420
+ * The in-memory structure corresponding to an XSLT Variable
1421
+ * or Param.
1422
+ */
1423
+ typedef struct _xsltStackElem xsltStackElem;
1424
+ typedef xsltStackElem *xsltStackElemPtr;
1425
+ struct _xsltStackElem {
1426
+ struct _xsltStackElem *next;/* chained list */
1427
+ xsltStylePreCompPtr comp; /* the compiled form */
1428
+ int computed; /* was the evaluation done */
1429
+ const xmlChar *name; /* the local part of the name QName */
1430
+ const xmlChar *nameURI; /* the URI part of the name QName */
1431
+ const xmlChar *select; /* the eval string */
1432
+ xmlNodePtr tree; /* the sequence constructor if no eval
1433
+ string or the location */
1434
+ xmlXPathObjectPtr value; /* The value if computed */
1435
+ xmlDocPtr fragment; /* The Result Tree Fragments (needed for XSLT 1.0)
1436
+ which are bound to the variable's lifetime. */
1437
+ int level; /* the depth in the tree;
1438
+ -1 if persistent (e.g. a given xsl:with-param) */
1439
+ xsltTransformContextPtr context; /* The transformation context; needed to cache
1440
+ the variables */
1441
+ int flags;
1442
+ };
1443
+
1444
+ #ifdef XSLT_REFACTORED
1445
+
1446
+ struct _xsltPrincipalStylesheetData {
1447
+ /*
1448
+ * Namespace dictionary for ns-prefixes and ns-names:
1449
+ * TODO: Shared between stylesheets, and XPath mechanisms.
1450
+ * Not used yet.
1451
+ */
1452
+ xmlDictPtr namespaceDict;
1453
+ /*
1454
+ * Global list of in-scope namespaces.
1455
+ */
1456
+ xsltPointerListPtr inScopeNamespaces;
1457
+ /*
1458
+ * Global list of information for [xsl:]excluded-result-prefixes.
1459
+ */
1460
+ xsltPointerListPtr exclResultNamespaces;
1461
+ /*
1462
+ * Global list of information for [xsl:]extension-element-prefixes.
1463
+ */
1464
+ xsltPointerListPtr extElemNamespaces;
1465
+ xsltEffectiveNsPtr effectiveNs;
1466
+ #ifdef XSLT_REFACTORED_XSLT_NSCOMP
1467
+ /*
1468
+ * Namespace name map to get rid of string comparison of namespace names.
1469
+ */
1470
+ xsltNsMapPtr nsMap;
1471
+ #endif
1472
+ };
1473
+
1474
+
1475
+ #endif
1476
+ /*
1477
+ * Note that we added a @compCtxt field to anchor an stylesheet compilation
1478
+ * context, since, due to historical reasons, various compile-time function
1479
+ * take only the stylesheet as argument and not a compilation context.
1480
+ */
1481
+ struct _xsltStylesheet {
1482
+ /*
1483
+ * The stylesheet import relation is kept as a tree.
1484
+ */
1485
+ struct _xsltStylesheet *parent;
1486
+ struct _xsltStylesheet *next;
1487
+ struct _xsltStylesheet *imports;
1488
+
1489
+ xsltDocumentPtr docList; /* the include document list */
1490
+
1491
+ /*
1492
+ * General data on the style sheet document.
1493
+ */
1494
+ xmlDocPtr doc; /* the parsed XML stylesheet */
1495
+ xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
1496
+ preserve space elements */
1497
+ int stripAll; /* strip-space * (1) preserve-space * (-1) */
1498
+ xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
1499
+
1500
+ /*
1501
+ * Global variable or parameters.
1502
+ */
1503
+ xsltStackElemPtr variables; /* linked list of param and variables */
1504
+
1505
+ /*
1506
+ * Template descriptions.
1507
+ */
1508
+ xsltTemplatePtr templates; /* the ordered list of templates */
1509
+ void *templatesHash; /* hash table or wherever compiled templates
1510
+ informations are stored */
1511
+ void *rootMatch; /* template based on / */
1512
+ void *keyMatch; /* template based on key() */
1513
+ void *elemMatch; /* template based on * */
1514
+ void *attrMatch; /* template based on @* */
1515
+ void *parentMatch; /* template based on .. */
1516
+ void *textMatch; /* template based on text() */
1517
+ void *piMatch; /* template based on processing-instruction() */
1518
+ void *commentMatch; /* template based on comment() */
1519
+
1520
+ /*
1521
+ * Namespace aliases.
1522
+ * NOTE: Not used in the refactored code.
1523
+ */
1524
+ xmlHashTablePtr nsAliases; /* the namespace alias hash tables */
1525
+
1526
+ /*
1527
+ * Attribute sets.
1528
+ */
1529
+ xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
1530
+
1531
+ /*
1532
+ * Namespaces.
1533
+ * TODO: Eliminate this.
1534
+ */
1535
+ xmlHashTablePtr nsHash; /* the set of namespaces in use:
1536
+ ATTENTION: This is used for
1537
+ execution of XPath expressions; unfortunately
1538
+ it restricts the stylesheet to have distinct
1539
+ prefixes.
1540
+ TODO: We need to get rid of this.
1541
+ */
1542
+ void *nsDefs; /* ATTENTION TODO: This is currently used to store
1543
+ xsltExtDefPtr (in extensions.c) and
1544
+ *not* xmlNsPtr.
1545
+ */
1546
+
1547
+ /*
1548
+ * Key definitions.
1549
+ */
1550
+ void *keys; /* key definitions */
1551
+
1552
+ /*
1553
+ * Output related stuff.
1554
+ */
1555
+ xmlChar *method; /* the output method */
1556
+ xmlChar *methodURI; /* associated namespace if any */
1557
+ xmlChar *version; /* version string */
1558
+ xmlChar *encoding; /* encoding string */
1559
+ int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */
1560
+
1561
+ /*
1562
+ * Number formatting.
1563
+ */
1564
+ xsltDecimalFormatPtr decimalFormat;
1565
+ int standalone; /* standalone = "yes" | "no" */
1566
+ xmlChar *doctypePublic; /* doctype-public string */
1567
+ xmlChar *doctypeSystem; /* doctype-system string */
1568
+ int indent; /* should output being indented */
1569
+ xmlChar *mediaType; /* media-type string */
1570
+
1571
+ /*
1572
+ * Precomputed blocks.
1573
+ */
1574
+ xsltElemPreCompPtr preComps;/* list of precomputed blocks */
1575
+ int warnings; /* number of warnings found at compilation */
1576
+ int errors; /* number of errors found at compilation */
1577
+
1578
+ xmlChar *exclPrefix; /* last excluded prefixes */
1579
+ xmlChar **exclPrefixTab; /* array of excluded prefixes */
1580
+ int exclPrefixNr; /* number of excluded prefixes in scope */
1581
+ int exclPrefixMax; /* size of the array */
1582
+
1583
+ void *_private; /* user defined data */
1584
+
1585
+ /*
1586
+ * Extensions.
1587
+ */
1588
+ xmlHashTablePtr extInfos; /* the extension data */
1589
+ int extrasNr; /* the number of extras required */
1590
+
1591
+ /*
1592
+ * For keeping track of nested includes
1593
+ */
1594
+ xsltDocumentPtr includes; /* points to last nested include */
1595
+
1596
+ /*
1597
+ * dictionary: shared between stylesheet, context and documents.
1598
+ */
1599
+ xmlDictPtr dict;
1600
+ /*
1601
+ * precompiled attribute value templates.
1602
+ */
1603
+ void *attVTs;
1604
+ /*
1605
+ * if namespace-alias has an alias for the default stylesheet prefix
1606
+ * NOTE: Not used in the refactored code.
1607
+ */
1608
+ const xmlChar *defaultAlias;
1609
+ /*
1610
+ * bypass pre-processing (already done) (used in imports)
1611
+ */
1612
+ int nopreproc;
1613
+ /*
1614
+ * all document text strings were internalized
1615
+ */
1616
+ int internalized;
1617
+ /*
1618
+ * Literal Result Element as Stylesheet c.f. section 2.3
1619
+ */
1620
+ int literal_result;
1621
+ /*
1622
+ * The principal stylesheet
1623
+ */
1624
+ xsltStylesheetPtr principal;
1625
+ #ifdef XSLT_REFACTORED
1626
+ /*
1627
+ * Compilation context used during compile-time.
1628
+ */
1629
+ xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
1630
+
1631
+ xsltPrincipalStylesheetDataPtr principalData;
1632
+ #endif
1633
+ };
1634
+
1635
+ typedef struct _xsltTransformCache xsltTransformCache;
1636
+ typedef xsltTransformCache *xsltTransformCachePtr;
1637
+ struct _xsltTransformCache {
1638
+ xmlDocPtr RVT;
1639
+ int nbRVT;
1640
+ xsltStackElemPtr stackItems;
1641
+ int nbStackItems;
1642
+ #ifdef XSLT_DEBUG_PROFILE_CACHE
1643
+ int dbgCachedRVTs;
1644
+ int dbgReusedRVTs;
1645
+ int dbgCachedVars;
1646
+ int dbgReusedVars;
1647
+ #endif
1648
+ };
1649
+
1650
+ /*
1651
+ * The in-memory structure corresponding to an XSLT Transformation.
1652
+ */
1653
+ typedef enum {
1654
+ XSLT_OUTPUT_XML = 0,
1655
+ XSLT_OUTPUT_HTML,
1656
+ XSLT_OUTPUT_TEXT
1657
+ } xsltOutputType;
1658
+
1659
+ typedef enum {
1660
+ XSLT_STATE_OK = 0,
1661
+ XSLT_STATE_ERROR,
1662
+ XSLT_STATE_STOPPED
1663
+ } xsltTransformState;
1664
+
1665
+ struct _xsltTransformContext {
1666
+ xsltStylesheetPtr style; /* the stylesheet used */
1667
+ xsltOutputType type; /* the type of output */
1668
+
1669
+ xsltTemplatePtr templ; /* the current template */
1670
+ int templNr; /* Nb of templates in the stack */
1671
+ int templMax; /* Size of the templtes stack */
1672
+ xsltTemplatePtr *templTab; /* the template stack */
1673
+
1674
+ xsltStackElemPtr vars; /* the current variable list */
1675
+ int varsNr; /* Nb of variable list in the stack */
1676
+ int varsMax; /* Size of the variable list stack */
1677
+ xsltStackElemPtr *varsTab; /* the variable list stack */
1678
+ int varsBase; /* the var base for current templ */
1679
+
1680
+ /*
1681
+ * Extensions
1682
+ */
1683
+ xmlHashTablePtr extFunctions; /* the extension functions */
1684
+ xmlHashTablePtr extElements; /* the extension elements */
1685
+ xmlHashTablePtr extInfos; /* the extension data */
1686
+
1687
+ const xmlChar *mode; /* the current mode */
1688
+ const xmlChar *modeURI; /* the current mode URI */
1689
+
1690
+ xsltDocumentPtr docList; /* the document list */
1691
+
1692
+ xsltDocumentPtr document; /* the current source document; can be NULL if an RTF */
1693
+ xmlNodePtr node; /* the current node being processed */
1694
+ xmlNodeSetPtr nodeList; /* the current node list */
1695
+ /* xmlNodePtr current; the node */
1696
+
1697
+ xmlDocPtr output; /* the resulting document */
1698
+ xmlNodePtr insert; /* the insertion node */
1699
+
1700
+ xmlXPathContextPtr xpathCtxt; /* the XPath context */
1701
+ xsltTransformState state; /* the current state */
1702
+
1703
+ /*
1704
+ * Global variables
1705
+ */
1706
+ xmlHashTablePtr globalVars; /* the global variables and params */
1707
+
1708
+ xmlNodePtr inst; /* the instruction in the stylesheet */
1709
+
1710
+ int xinclude; /* should XInclude be processed */
1711
+
1712
+ const char * outputFile; /* the output URI if known */
1713
+
1714
+ int profile; /* is this run profiled */
1715
+ long prof; /* the current profiled value */
1716
+ int profNr; /* Nb of templates in the stack */
1717
+ int profMax; /* Size of the templtaes stack */
1718
+ long *profTab; /* the profile template stack */
1719
+
1720
+ void *_private; /* user defined data */
1721
+
1722
+ int extrasNr; /* the number of extras used */
1723
+ int extrasMax; /* the number of extras allocated */
1724
+ xsltRuntimeExtraPtr extras; /* extra per runtime informations */
1725
+
1726
+ xsltDocumentPtr styleList; /* the stylesheet docs list */
1727
+ void * sec; /* the security preferences if any */
1728
+
1729
+ xmlGenericErrorFunc error; /* a specific error handler */
1730
+ void * errctx; /* context for the error handler */
1731
+
1732
+ xsltSortFunc sortfunc; /* a ctxt specific sort routine */
1733
+
1734
+ /*
1735
+ * handling of temporary Result Value Tree
1736
+ * (XSLT 1.0 term: "Result Tree Fragment")
1737
+ */
1738
+ xmlDocPtr tmpRVT; /* list of RVT without persistance */
1739
+ xmlDocPtr persistRVT; /* list of persistant RVTs */
1740
+ int ctxtflags; /* context processing flags */
1741
+
1742
+ /*
1743
+ * Speed optimization when coalescing text nodes
1744
+ */
1745
+ const xmlChar *lasttext; /* last text node content */
1746
+ unsigned int lasttsize; /* last text node size */
1747
+ unsigned int lasttuse; /* last text node use */
1748
+ /*
1749
+ * Per Context Debugging
1750
+ */
1751
+ int debugStatus; /* the context level debug status */
1752
+ unsigned long* traceCode; /* pointer to the variable holding the mask */
1753
+
1754
+ int parserOptions; /* parser options xmlParserOption */
1755
+
1756
+ /*
1757
+ * dictionary: shared between stylesheet, context and documents.
1758
+ */
1759
+ xmlDictPtr dict;
1760
+ xmlDocPtr tmpDoc; /* Obsolete; not used in the library. */
1761
+ /*
1762
+ * all document text strings are internalized
1763
+ */
1764
+ int internalized;
1765
+ int nbKeys;
1766
+ int hasTemplKeyPatterns;
1767
+ xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
1768
+ xmlNodePtr initialContextNode;
1769
+ xmlDocPtr initialContextDoc;
1770
+ xsltTransformCachePtr cache;
1771
+ void *contextVariable; /* the current variable item */
1772
+ xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
1773
+ the instruction which created the fragment
1774
+ exits */
1775
+ xmlDocPtr localRVTBase;
1776
+ int keyInitLevel; /* Needed to catch recursive keys issues */
1777
+ int funcLevel; /* Needed to catch recursive functions issues */
1778
+ };
1779
+
1780
+ /**
1781
+ * CHECK_STOPPED:
1782
+ *
1783
+ * Macro to check if the XSLT processing should be stopped.
1784
+ * Will return from the function.
1785
+ */
1786
+ #define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
1787
+
1788
+ /**
1789
+ * CHECK_STOPPEDE:
1790
+ *
1791
+ * Macro to check if the XSLT processing should be stopped.
1792
+ * Will goto the error: label.
1793
+ */
1794
+ #define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
1795
+
1796
+ /**
1797
+ * CHECK_STOPPED0:
1798
+ *
1799
+ * Macro to check if the XSLT processing should be stopped.
1800
+ * Will return from the function with a 0 value.
1801
+ */
1802
+ #define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
1803
+
1804
+ /*
1805
+ * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
1806
+ * possible incompatibilities between function pointers and object
1807
+ * pointers. It is defined in libxml/hash.h within recent versions
1808
+ * of libxml2, but is put here for compatibility.
1809
+ */
1810
+ #ifndef XML_CAST_FPTR
1811
+ /**
1812
+ * XML_CAST_FPTR:
1813
+ * @fptr: pointer to a function
1814
+ *
1815
+ * Macro to do a casting from an object pointer to a
1816
+ * function pointer without encountering a warning from
1817
+ * gcc
1818
+ *
1819
+ * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
1820
+ * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
1821
+ * so it is disabled now
1822
+ */
1823
+
1824
+ #define XML_CAST_FPTR(fptr) fptr
1825
+ #endif
1826
+ /*
1827
+ * Functions associated to the internal types
1828
+ xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
1829
+ xmlChar *name);
1830
+ */
1831
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1832
+ xsltNewStylesheet (void);
1833
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1834
+ xsltParseStylesheetFile (const xmlChar* filename);
1835
+ XSLTPUBFUN void XSLTCALL
1836
+ xsltFreeStylesheet (xsltStylesheetPtr style);
1837
+ XSLTPUBFUN int XSLTCALL
1838
+ xsltIsBlank (xmlChar *str);
1839
+ XSLTPUBFUN void XSLTCALL
1840
+ xsltFreeStackElemList (xsltStackElemPtr elem);
1841
+ XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL
1842
+ xsltDecimalFormatGetByName(xsltStylesheetPtr style,
1843
+ xmlChar *name);
1844
+
1845
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1846
+ xsltParseStylesheetProcess(xsltStylesheetPtr ret,
1847
+ xmlDocPtr doc);
1848
+ XSLTPUBFUN void XSLTCALL
1849
+ xsltParseStylesheetOutput(xsltStylesheetPtr style,
1850
+ xmlNodePtr cur);
1851
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1852
+ xsltParseStylesheetDoc (xmlDocPtr doc);
1853
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1854
+ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
1855
+ xsltStylesheetPtr style);
1856
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
1857
+ xsltLoadStylesheetPI (xmlDocPtr doc);
1858
+ XSLTPUBFUN void XSLTCALL
1859
+ xsltNumberFormat (xsltTransformContextPtr ctxt,
1860
+ xsltNumberDataPtr data,
1861
+ xmlNodePtr node);
1862
+ XSLTPUBFUN xmlXPathError XSLTCALL
1863
+ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
1864
+ xmlChar *format,
1865
+ double number,
1866
+ xmlChar **result);
1867
+
1868
+ XSLTPUBFUN void XSLTCALL
1869
+ xsltParseTemplateContent(xsltStylesheetPtr style,
1870
+ xmlNodePtr templ);
1871
+ XSLTPUBFUN int XSLTCALL
1872
+ xsltAllocateExtra (xsltStylesheetPtr style);
1873
+ XSLTPUBFUN int XSLTCALL
1874
+ xsltAllocateExtraCtxt (xsltTransformContextPtr ctxt);
1875
+ /*
1876
+ * Extra functions for Result Value Trees
1877
+ */
1878
+ XSLTPUBFUN xmlDocPtr XSLTCALL
1879
+ xsltCreateRVT (xsltTransformContextPtr ctxt);
1880
+ XSLTPUBFUN int XSLTCALL
1881
+ xsltRegisterTmpRVT (xsltTransformContextPtr ctxt,
1882
+ xmlDocPtr RVT);
1883
+ XSLTPUBFUN int XSLTCALL
1884
+ xsltRegisterLocalRVT (xsltTransformContextPtr ctxt,
1885
+ xmlDocPtr RVT);
1886
+ XSLTPUBFUN int XSLTCALL
1887
+ xsltRegisterPersistRVT (xsltTransformContextPtr ctxt,
1888
+ xmlDocPtr RVT);
1889
+ XSLTPUBFUN int XSLTCALL
1890
+ xsltExtensionInstructionResultRegister(
1891
+ xsltTransformContextPtr ctxt,
1892
+ xmlXPathObjectPtr obj);
1893
+ XSLTPUBFUN int XSLTCALL
1894
+ xsltExtensionInstructionResultFinalize(
1895
+ xsltTransformContextPtr ctxt);
1896
+ XSLTPUBFUN void XSLTCALL
1897
+ xsltFreeRVTs (xsltTransformContextPtr ctxt);
1898
+ XSLTPUBFUN void XSLTCALL
1899
+ xsltReleaseRVT (xsltTransformContextPtr ctxt,
1900
+ xmlDocPtr RVT);
1901
+ XSLTPUBFUN int XSLTCALL
1902
+ xsltTransStorageAdd (xsltTransformContextPtr ctxt,
1903
+ void *id,
1904
+ void *data);
1905
+ XSLTPUBFUN void * XSLTCALL
1906
+ xsltTransStorageRemove (xsltTransformContextPtr ctxt,
1907
+ void *id);
1908
+
1909
+ /*
1910
+ * Extra functions for Attribute Value Templates
1911
+ */
1912
+ XSLTPUBFUN void XSLTCALL
1913
+ xsltCompileAttr (xsltStylesheetPtr style,
1914
+ xmlAttrPtr attr);
1915
+ XSLTPUBFUN xmlChar * XSLTCALL
1916
+ xsltEvalAVT (xsltTransformContextPtr ctxt,
1917
+ void *avt,
1918
+ xmlNodePtr node);
1919
+ XSLTPUBFUN void XSLTCALL
1920
+ xsltFreeAVTList (void *avt);
1921
+
1922
+ /*
1923
+ * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
1924
+ */
1925
+
1926
+ XSLTPUBFUN void XSLTCALL
1927
+ xsltUninit (void);
1928
+
1929
+ /************************************************************************
1930
+ * *
1931
+ * Compile-time functions for *internal* use only *
1932
+ * *
1933
+ ************************************************************************/
1934
+
1935
+ #ifdef XSLT_REFACTORED
1936
+ XSLTPUBFUN void XSLTCALL
1937
+ xsltParseSequenceConstructor(
1938
+ xsltCompilerCtxtPtr cctxt,
1939
+ xmlNodePtr start);
1940
+ XSLTPUBFUN int XSLTCALL
1941
+ xsltParseAnyXSLTElem (xsltCompilerCtxtPtr cctxt,
1942
+ xmlNodePtr elem);
1943
+ #ifdef XSLT_REFACTORED_XSLT_NSCOMP
1944
+ XSLTPUBFUN int XSLTCALL
1945
+ xsltRestoreDocumentNamespaces(
1946
+ xsltNsMapPtr ns,
1947
+ xmlDocPtr doc);
1948
+ #endif
1949
+ #endif /* XSLT_REFACTORED */
1950
+
1951
+ /************************************************************************
1952
+ * *
1953
+ * Transformation-time functions for *internal* use only *
1954
+ * *
1955
+ ************************************************************************/
1956
+ XSLTPUBFUN int XSLTCALL
1957
+ xsltInitCtxtKey (xsltTransformContextPtr ctxt,
1958
+ xsltDocumentPtr doc,
1959
+ xsltKeyDefPtr keyd);
1960
+ XSLTPUBFUN int XSLTCALL
1961
+ xsltInitAllDocKeys (xsltTransformContextPtr ctxt);
1962
+ #ifdef __cplusplus
1963
+ }
1964
+ #endif
1965
+
1966
+ #endif /* __XML_XSLT_H__ */
1967
+