Xalan-C++ API Reference
1.12.0
xalanc
XSLT
StylesheetExecutionContextDefault.hpp
Go to the documentation of this file.
1
/*
2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
#if !defined(STYLESHEETEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680)
19
#define STYLESHEETEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
20
21
22
23
// Base class include file.
24
#include <
xalanc/XSLT/StylesheetExecutionContext.hpp
>
25
26
27
28
#include <ctime>
29
#include <memory>
30
31
32
33
#include <
xalanc/Include/XalanVector.hpp
>
34
#include <
xalanc/Include/XalanMap.hpp
>
35
#include <
xalanc/Include/XalanSet.hpp
>
36
#include <
xalanc/Include/XalanObjectCache.hpp
>
37
#include <
xalanc/Include/XalanObjectStackCache.hpp
>
38
39
40
#include <
xalanc/PlatformSupport/DOMStringHelper.hpp
>
41
42
43
#if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
44
#include <
xalanc/PlatformSupport/DOMStringPrintWriter.hpp
>
45
#endif
46
47
48
49
#include <
xalanc/XPath/XPathExecutionContextDefault.hpp
>
50
51
52
53
#include <
xalanc/XMLSupport/FormatterToText.hpp
>
54
55
56
57
#if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
58
#include <
xalanc/XalanSourceTree/XalanSourceTreeDocument.hpp
>
59
#endif
60
#include <
xalanc/XalanSourceTree/FormatterToSourceTree.hpp
>
61
#include <
xalanc/XalanSourceTree/XalanSourceTreeDocumentFragment.hpp
>
62
63
64
65
#include <
xalanc/XSLT/CountersTable.hpp
>
66
#include <
xalanc/XSLT/NodeSorter.hpp
>
67
#include <
xalanc/XSLT/Stylesheet.hpp
>
68
#include <
xalanc/XSLT/VariablesStack.hpp
>
69
#include <
xalanc/XSLT/XResultTreeFragAllocator.hpp
>
70
#include <
xalanc/XSLT/XalanSourceTreeDocumentAllocator.hpp
>
71
#include <
xalanc/XSLT/XalanSourceTreeDocumentFragmentAllocator.hpp
>
72
73
74
75
namespace
XALAN_CPP_NAMESPACE
{
76
77
78
79
class
XalanSourceTreeDocument;
80
class
XPathProcessor;
81
class
XSLTEngineImpl;
82
83
typedef
VariablesStack::ParamsVectorType
ParamsVectorTypeDecl
;
84
XALAN_USES_MEMORY_MANAGER
(
ParamsVectorTypeDecl
)
85
//
86
// An class which provides support for executing stylesheets.
87
//
88
class
XALAN_XSLT_EXPORT
StylesheetExecutionContextDefault
:
public
StylesheetExecutionContext
89
{
90
public
:
91
92
typedef
std::clock_t
ClockType
;
93
94
typedef
XalanVector<FormatterListener*>
FormatterListenerVectorType
;
95
typedef
XalanVector<PrintWriter*>
PrintWriterVectorType
;
96
typedef
XalanVector<XalanOutputStream*>
OutputStreamVectorType
;
97
98
typedef
XalanVector<const ElemTemplateElement*>
ElementTemplateElementStackType
;
99
typedef
std::pair<const XPath*, ClockType>
XPathCacheEntry
;
100
typedef
XalanMap <XalanDOMString, XPathCacheEntry>
XPathCacheMapType
;
101
typedef
XalanVector<const ElemTemplate*>
CurrentTemplateStackType
;
102
103
typedef
Stylesheet::KeyTablesTableType
KeyTablesTableType
;
104
typedef
ParamsVectorTypeDecl
ParamsVectorType
;
105
106
/**
107
* Construct a StylesheetExecutionContextDefault object
108
*
109
* @param theXPathEnvSupport XPath environment support class instance
110
* @param theDOMSupport DOMSupport class instance
111
* @param theXobjectFactory factory class instance for XObjects
112
* @param theCurrentNode current node in the source tree
113
* @param theContextNodeList node list for current context
114
* @param thePrefixResolver pointer to prefix resolver to use
115
*/
116
StylesheetExecutionContextDefault
(
117
MemoryManager&
theManager
,
118
XSLTEngineImpl
&
xsltProcessor
,
119
XPathEnvSupport
&
theXPathEnvSupport
,
120
DOMSupport
&
theDOMSupport
,
121
XObjectFactory
&
theXObjectFactory
,
122
XalanNode
*
theCurrentNode
= 0,
123
const
NodeRefListBase
*
theContextNodeList
= 0,
124
const
PrefixResolver
*
thePrefixResolver
= 0);
125
126
/**
127
* Construct a StylesheetExecutionContextDefault object
128
*
129
* @param theXPathEnvSupport XPath environment support class instance
130
* @param theDOMSupport DOMSupport class instance
131
* @param theXobjectFactory factory class instance for XObjects
132
* @param theCurrentNode current node in the source tree
133
* @param theContextNodeList node list for current context
134
* @param thePrefixResolver pointer to prefix resolver to use
135
*/
136
explicit
137
StylesheetExecutionContextDefault
(
138
MemoryManager&
theManager
,
139
XalanNode
*
theCurrentNode
= 0,
140
const
NodeRefListBase
*
theContextNodeList
= 0,
141
const
PrefixResolver
*
thePrefixResolver
= 0);
142
143
static
StylesheetExecutionContextDefault
*
144
create
(
145
MemoryManager&
theManager
,
146
XalanNode
*
theCurrentNode
= 0,
147
const
NodeRefListBase
*
theContextNodeList
= 0,
148
const
PrefixResolver
*
thePrefixResolver
= 0);
149
150
virtual
151
~StylesheetExecutionContextDefault
();
152
153
154
/**
155
* Set the XPathEnvSupport instance.
156
*
157
* @param theSupport a reference to the instance to use.
158
*/
159
void
160
setXPathEnvSupport
(
XPathEnvSupport
*
theSupport
)
161
{
162
m_xpathExecutionContextDefault.setXPathEnvSupport(
theSupport
);
163
}
164
165
/**
166
* Set the DOMSupport instance.
167
*
168
* @param theDOMSupport a reference to the instance to use.
169
*/
170
void
171
setDOMSupport
(
DOMSupport
*
theDOMSupport
)
172
{
173
m_xpathExecutionContextDefault.setDOMSupport(
theDOMSupport
);
174
}
175
176
/**
177
* Set the XObjectFactory instance.
178
*
179
* @param theFactory a reference to the instance to use.
180
*/
181
void
182
setXObjectFactory
(
XObjectFactory
*
theXObjectFactory
)
183
{
184
m_xpathExecutionContextDefault.setXObjectFactory(
theXObjectFactory
);
185
186
m_xobjectFactory =
theXObjectFactory
;
187
}
188
189
190
/**
191
* Set the DOMSupport instance.
192
*
193
* @param theDOMSupport a reference to the instance to use.
194
*/
195
void
196
setXSLTProcessor
(
XSLTEngineImpl
*
theProcessor
)
197
{
198
m_xsltProcessor =
theProcessor
;
199
}
200
201
bool
202
getUsePerInstanceDocumentFactory
()
const
203
{
204
return
m_usePerInstanceDocumentFactory;
205
}
206
207
void
208
setUsePerInstanceDocumentFactory
(
bool
fValue
)
209
{
210
m_usePerInstanceDocumentFactory =
fValue
;
211
}
212
213
214
// These interfaces are inherited from StylesheetExecutionContext...
215
216
virtual
bool
217
getQuietConflictWarnings
()
const
;
218
219
virtual
bool
220
getCopyTextNodesOnly
()
const
;
221
222
virtual
void
223
pushCopyTextNodesOnly
(
bool
copyTextNodesOnly
);
224
225
virtual
bool
226
popCopyTextNodesOnly
();
227
228
#if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
229
virtual
void
230
pushProcessCurrentAttribute
(
bool
processAttribute);
231
232
virtual
bool
233
popProcessCurrentAttribute
();
234
235
virtual
void
236
pushSkipElementAttributes
(
bool
skipAttributes
);
237
238
virtual
bool
239
getSkipElementAttributes
()
const
;
240
241
virtual
bool
242
popSkipElementAttributes
();
243
244
virtual
void
245
pushExecuteIf
(
bool
executeIf
);
246
247
virtual
bool
248
popExecuteIf
();
249
#endif
250
251
virtual
XalanNode
*
252
getRootDocument
()
const
;
253
254
virtual
void
255
setRootDocument
(
XalanNode
*
theDocument
);
256
257
virtual
void
258
setStylesheetRoot
(
const
StylesheetRoot
*
theStylesheet
);
259
260
virtual
const
XalanQName
*
261
getCurrentMode
()
const
;
262
263
virtual
void
264
pushCurrentMode
(
const
XalanQName
*
theMode
);
265
266
virtual
void
267
popCurrentMode
();
268
269
virtual
const
ElemTemplate
*
270
getCurrentTemplate
()
const
;
271
272
virtual
void
273
pushCurrentTemplate
(
const
ElemTemplate
*
theTemplate
);
274
275
virtual
void
276
popCurrentTemplate
();
277
278
virtual
bool
279
isElementPending
()
const
;
280
281
virtual
void
282
replacePendingAttribute
(
283
const
XalanDOMChar
*
theName
,
284
const
XalanDOMChar
*
theNewType
,
285
const
XalanDOMChar
*
theNewValue
);
286
287
virtual
void
288
pushOutputContext
(
FormatterListener
*
flistener
= 0);
289
290
virtual
void
291
popOutputContext
();
292
293
virtual
void
294
addResultAttribute
(
295
const
XalanDOMString
&
aname
,
296
const
XalanDOMString
& value);
297
298
virtual
void
299
addResultAttribute
(
300
const
XalanDOMString
&
aname
,
301
const
XalanDOMChar
* value);
302
303
virtual
void
304
copyNamespaceAttributes
(
const
XalanNode
&
src
);
305
306
virtual
const
XalanDOMString
*
307
getResultPrefixForNamespace
(
const
XalanDOMString
&
theNamespace
)
const
;
308
309
virtual
const
XalanDOMString
*
310
getResultNamespaceForPrefix
(
const
XalanDOMString
&
thePrefix
)
const
;
311
312
virtual
bool
313
isPendingResultPrefix
(
const
XalanDOMString
&
thePrefix
);
314
315
virtual
void
316
getUniqueNamespaceValue
(
XalanDOMString
&
theValue
)
const
;
317
318
virtual
FormatterListener
*
319
getFormatterListener
()
const
;
320
321
virtual
void
322
setFormatterListener
(
FormatterListener
*
flistener
);
323
324
virtual
int
325
getIndent
()
const
;
326
327
virtual
void
328
setIndent
(
int
indentAmount
);
329
330
virtual
const
XPath
*
331
createMatchPattern
(
332
const
XalanDOMString
& str,
333
const
PrefixResolver
&
resolver
);
334
335
virtual
void
336
returnXPath
(
const
XPath
*
xpath
);
337
338
virtual
void
339
pushTopLevelVariables
(
const
ParamVectorType
&
topLevelParams
);
340
341
342
virtual
const
XObjectPtr
343
createVariable
(
344
const
XPath
&
xpath
,
345
XalanNode
*
contextNode
,
346
const
PrefixResolver
&
resolver
);
347
348
#if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
349
virtual
const
XObjectPtr
350
createVariable(
351
const
ElemTemplateElement
&
templateChild
,
352
XalanNode
*
sourceNode
);
353
#endif
354
355
virtual
void
356
pushVariable
(
357
const
XalanQName
&
name
,
358
const
ElemTemplateElement
*
element
,
359
const
XalanDOMString
& str,
360
XalanNode
*
contextNode
,
361
const
PrefixResolver
&
resolver
);
362
363
virtual
void
364
pushVariable
(
365
const
XalanQName
&
name
,
366
const
XObjectPtr
val
,
367
const
ElemTemplateElement
*
element
);
368
369
virtual
void
370
pushVariable
(
371
const
XalanQName
&
name
,
372
const
ElemVariable
*
var
,
373
const
ElemTemplateElement
*
element
);
374
375
virtual
void
376
pushVariable
(
377
const
XalanQName
&
name
,
378
const
ElemTemplateElement
*
element
,
379
const
XPath
&
xpath
,
380
XalanNode
*
contextNode
,
381
const
PrefixResolver
&
resolver
);
382
383
#if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
384
virtual
void
385
pushVariable(
386
const
XalanQName
&
name
,
387
const
ElemTemplateElement
*
element
,
388
const
ElemTemplateElement
&
templateChild
,
389
XalanNode
*
sourceNode
);
390
#endif
391
392
393
virtual
void
394
pushContextMarker
();
395
396
virtual
void
397
popContextMarker
();
398
399
virtual
void
400
resolveTopLevelParams
();
401
402
virtual
void
403
clearTopLevelParams
();
404
405
#if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
406
virtual
void
beginParams
();
407
408
virtual
void
endParams
();
409
410
virtual
void
pushParam
(
const
XalanQName
&
qName
,
const
XObjectPtr
&
theValue
);
411
#else
412
virtual
void
413
pushParams(
const
ElemTemplateElement
&
xslCallTemplateElement
);
414
#endif
415
416
virtual
const
XObjectPtr
417
getParamVariable
(
const
XalanQName
&
theName
);
418
419
virtual
void
420
pushElementFrame
(
const
ElemTemplateElement
*
elem
);
421
422
virtual
void
423
popElementFrame
();
424
425
virtual
int
426
getGlobalStackFrameIndex
()
const
;
427
428
virtual
int
429
getCurrentStackFrameIndex
()
const
;
430
431
virtual
void
432
pushCurrentStackFrameIndex
(
int
currentStackFrameIndex
= -1);
433
434
virtual
void
435
popCurrentStackFrameIndex
();
436
437
virtual
void
438
startDocument
();
439
440
virtual
void
441
endDocument
();
442
443