Xalan-C++ API Reference 1.12.0
StylesheetConstructionContextDefault.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(STYLESHEETCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680)
19#define STYLESHEETCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
20
21
22
23// Base include file. Must be first.
25
26
27
29
30
31
35
36
37
38#if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) || defined(XALAN_BUILD_DLL)
40#endif
41
42
43
45
46
47
49
50
51
55
56
57
58// Base class header file...
60
61
62
63#include <xalanc/XSLT/AVT.hpp>
80
81
82
83namespace XALAN_CPP_NAMESPACE {
84
85
86
87class XPathEnvSupport;
88class XPathFactory;
89class XPathProcessor;
90class XSLTEngineImpl;
91
92
93
94/**
95 *
96 * An default implementation of an abtract class which provides support for
97 * constructing the internal representation of a stylesheet.
98 *
99 */
101{
102public:
103
107
108 // Default size for vector allocation.
109 enum {
110 eDefaultXalanDOMCharVectorBlockSize = 1024,
111 eDefaultAVTBlockSize = 128,
112 eDefaultAVTPartSimpleBlockSize = 128,
113 eDefaultAVTPartXPathBlockSize = 128,
114 eDefaultXalanQNameByValueBlockSize = 32,
115 eDefaultPointerVectorBlockSize = 512,
116 eDefaultElemApplyTemplatesBlockSize = 10,
117 eDefaultElemAttributeBlockSize = 10,
118 eDefaultElemAttributeSetBlockSize = 10,
119 eDefaultElemCallTemplateBlockSize = 10,
120 eDefaultElemElementBlockSize = 10,
121 eDefaultElemLiteralResultBlockSize = 20,
122 eDefaultElemTemplateBlockSize = 10,
123 eDefaultElemTextLiteralBlockSize = 20,
124 eDefaultElemValueOfBlockSize = 10,
125 eDefaultElemVariableBlockSize = 10,
126 eDefaultMatchPatternDataBlockSize = 10 };
127
128 /*
129 * Construct an instance. If the stylesheet(s) constructed is/are meant to be reused (a.k.a. "compiled"),
130 * the XObjectFactory and XPathFactory instance must exist for the lifetime of the construction context
131 * and, therefore, for the lifetime of the stylesheet(s). Otherwise, XObject and XPath instance will be
132 * destroyed when the corresponding factories are destryed, leaving pointers to destroyed objects in the.
133 * stylesheet(s).
134 *
135 * @param processor a reference to an XSLTEngineImpl instance. Used for error reporting.
136 * @param xpathFactory a reference to an XPathFactory instance. See comments above for important details.
137 * @param theXalanDOMCharVectorAllocatorBlockSize The block size to use for allocating vectors of XalanDOMChars
138 * @param theAVTAllocatorBlockSize The block size to use for allocating AVT instances.
139 * @param theAVTPartSimpleAllocatorBlockSize The block size to use for allocating AVTPartSimple instances.
140 * @param theAVTPartXPathAllocatorBlockSize The block size to use for allocating AVTPartXPath instances.
141 * @param theXalanQNameByValueAllocatorBlockSize The block size to use for allocating XalanQNameByValue instances.
142 * @param thePointerVectorAllocatorBlockSize The block size to use for allocating vectors of pointers.
143 */
145 MemoryManager& theManager,
148 VectorAllocatorSizeType theXalanDOMCharVectorAllocatorBlockSize = eDefaultXalanDOMCharVectorBlockSize,
153 VectorAllocatorSizeType thePointerVectorAllocatorBlockSize = eDefaultPointerVectorBlockSize);
154
155 virtual
157
158
159 // These interfaces are inherited from StylesheetConstructionContext...
160
161 virtual void
163 eSource source,
165 const XalanDOMString& msg,
166 const Locator* locator,
167 const XalanNode* sourceNode);
168
169 virtual void
171 eSource source,
173 const XalanDOMString& msg,
174 const XalanNode* sourceNode);
175
176 virtual void
178
179 virtual const XalanDOMString&
181
182 virtual const XalanDOMString&
184 const XalanDOMChar* theString,
185 XalanDOMString::size_type theLength = XalanDOMString::npos);
186
187 virtual XalanDOMString&
189
190 virtual bool
192
193 virtual StylesheetRoot*
195
196 virtual StylesheetRoot*
198
199 virtual Stylesheet*
203
204 virtual void
206
207 virtual URLAutoPtrType
209
210 virtual XalanDOMString&
214
215 virtual URLAutoPtrType
218 const XalanDOMString& base);
219
220 virtual XalanDOMString&
223 const XalanDOMString& base,
225
226 virtual const XalanDOMString&
228
229 virtual XPath*
231 const Locator* locator,
232 const XalanDOMString& str,
234 bool allowVariableReferences = true,
235 bool allowKeyFunction = true);
236
237 virtual XPath*
239 const Locator* locator,
240 const XalanDOMChar* str,
242 bool allowVariableReferences = true,
243 bool allowKeyFunction = true);
244
245 virtual XPath*
247 const Locator* locator,
248 const XalanDOMString& str,
250 bool allowVariableReferences = true,
251 bool allowKeyFunction = true);
252
253 virtual XPath*
255 const Locator* locator,
256 const XalanDOMChar* str,
258 bool allowVariableReferences = true,
259 bool allowKeyFunction = true);
260
261 virtual XPath*
263 const Locator* locator,
264 const XalanDOMChar* str,
267 bool allowVariableReferences = true,
268 bool allowKeyFunction = true);
269
270 virtual const Locator*
272
273 virtual void
275
276 virtual void
278
279 virtual const XalanDOMString&
281
282 virtual XalanDocument*
285 DocumentHandler* docHandler,
287 ErrorHandler* theErrorHandler = 0);
288
289 virtual bool
293 const Locator* theLocator = 0);
294
295 virtual bool
299 const Locator* theLocator = 0);
300
301 virtual bool
303 const XalanDOMChar* theName,
305 const Locator* theLocator = 0);
306
307 virtual eElementToken
309
310 virtual double
312
313 virtual XalanDOMChar*
315
316 virtual XalanDOMChar*
318 const XalanDOMChar* theString,
319 XalanDOMString::size_type theLength = XalanDOMString::npos,
320 bool fTerminate = true);
321
322 virtual const AVT*
324 const Locator* locator,
325 const XalanDOMChar* name,
327 const PrefixResolver& resolver);
328
329 virtual const AVTPart*
331 const XalanDOMChar* theString,
332 XalanDOMString::size_type theLength = XalanDOMString::npos);
333
334 virtual const AVTPart*
336 const Locator* locator,
337 const XalanDOMChar* str,
339 const PrefixResolver& resolver);
340
341 virtual const AVT**
343
344 virtual const AVTPart**
346
347 virtual const XalanQName*
349 const XalanDOMString& qname,
351 const Locator* locator = 0,
352 bool fUseDefault = false);
353
354 virtual const XalanQName*
356 const XalanDOMChar* qname,
358 const Locator* locator = 0,
359 bool fUseDefault = false);
360
361 virtual const XalanQName**
363 size_type& count,
366 const Locator* locator = 0,
367 bool fUseDefault = false);
368
369 virtual ElemTemplateElement*
371 int token,
373 const AttributeListType& atts,
374 const Locator* locator = 0);
375
376 virtual ElemTemplateElement*
378 int token,
380 const XalanDOMChar* name,
381 const AttributeListType& atts,
382 const Locator* locator = 0);
383
384 virtual ElemTemplateElement*
387 const XalanDOMChar* chars,
389 bool preserveSpace,
390 bool disableOutputEscaping,
391 const Locator* locator = 0);
392
393 virtual ElemTemplateElement*
396 const XalanDOMChar* name,
397 const AttributeListType& atts,
399 const Locator* locator = 0);
400
401 virtual const XalanMatchPatternData*
406 const XPath& theMatchPattern,
409
410 static eElementToken
412
415
416private:
417
418 const AVT**
419 doAllocateAVTPointerVector(size_type theSize)
420 {
422
423 return reinterpret_cast<const AVT**>(m_pointerVectorAllocator.allocate(theSize));
424 }
425
426 const AVTPart**
427 doAllocateAVTPartPointerVector(size_type theSize)
428 {
429 assert(sizeof(AVTPart**) == sizeof(PointerVectorAllocatorType::value_type));
430
431 return reinterpret_cast<const AVTPart**>(m_pointerVectorAllocator.allocate(theSize));
432 }
433
434 const XalanQName**
435 doAllocateXalanQNamePointerVector(size_type theSize)
436 {
437 assert(sizeof(XalanQName**) == sizeof(PointerVectorAllocatorType::value_type));
438
439 return reinterpret_cast<const XalanQName**>(m_pointerVectorAllocator.allocate(theSize));
440 }
441
442
443 XSLTEngineImpl& m_processor;
444
445 XPathFactory& m_xpathFactory;
446
447 typedef XalanMemMgrAutoPtr<XPathProcessor> XPathProcessAutoPtr;
448
449 XPathProcessAutoPtr m_xpathProcessor;
450
451 StylesheetVectorType m_stylesheets;
452
453 XalanDOMStringPool m_stringPool;
454
455 XalanDOMCharVectorAllocatorType m_xalanDOMCharVectorAllocator;
456
457 mutable XalanDOMString m_tempBuffer;
458
459 XalanQNameByValue m_scratchQName;
460
461 XalanDOMStringCache m_stringCache;
462
463 XalanAVTAllocator m_avtAllocator;
464
465 XalanAVTPartSimpleAllocator m_avtPartSimpleAllocator;
466
467 XalanAVTPartXPathAllocator m_avtPartXPathAllocator;
468
469 XalanQNameByValueAllocator m_xalanQNameByValueAllocator;
470
471 const XalanQNameByReference m_useAttributeSetsQName;
472
473 PointerVectorAllocatorType m_pointerVectorAllocator;
474
475 ElemTemplateElementVectorType m_allocatedElements;
476
477 XalanElemApplyTemplatesAllocator m_elemApplyTemplatesAllocator;
478
479 XalanElemAttributeAllocator m_elemAttributeAllocator;
480
481 XalanElemAttributeSetAllocator m_elemAttributeSetAllocator;
482
483 XalanElemCallTemplateAllocator m_elemCallTemplateAllocator;
484
485 XalanElemElementAllocator m_elemElementAllocator;
486
487 XalanElemLiteralResultAllocator m_elemLiteralResultAllocator;
488
489 XalanElemTemplateAllocator m_elemTemplateAllocator;
490
491 XalanElemTextLiteralAllocator m_elemTextLiteralAllocator;
492
493 XalanElemValueOfAllocator m_elemValueOfAllocator;
494
495 XalanElemVariableAllocator m_elemVariableAllocator;
496
497 XalanMatchPatternDataAllocator m_matchPatternDataAllocator;
498
499 const XalanQNameByReference m_spaceAttrQName;
500
501 // Static strings for stylesheet compilation...
502
503 // The string "if"
504 static const XalanDOMChar s_if[];
505
506 // The string "key"
507 static const XalanDOMChar s_key[];
508
509 // The string "copy"
510 static const XalanDOMChar s_copy[];
511
512 // The string "sort"
513 static const XalanDOMChar s_sort[];
514
515 // The string "text"
516 static const XalanDOMChar s_text[];
517
518 // The string "when"
519 static const XalanDOMChar s_when[];
520
521 // The string "empty"
522 static const XalanDOMChar s_empty[];
523
524 // The string "param"
525 static const XalanDOMChar s_param[];
526
527 // The string "choose"
528 static const XalanDOMChar s_choose[];
529
530 // The string "import"
531 static const XalanDOMChar s_import[];
532
533 // The string "number"
534 static const XalanDOMChar s_number[];
535
536 // The string "output"
537 static const XalanDOMChar s_output[];
538
539 // The string "comment"
540 static const XalanDOMChar s_comment[];
541
542 // The string "copy-of"
543 static const XalanDOMChar s_copyOf[];
544
545 // The string "element"
546 static const XalanDOMChar s_element[];
547
548 // The string "include"
549 static const XalanDOMChar s_include[];
550
551 // The string "message"
552 static const XalanDOMChar s_message[];
553
554 // The string "fallback"
555 static const XalanDOMChar s_fallback[];
556
557 // The string "for-each"
558 static const XalanDOMChar s_forEach[];
559
560 // The string "template"
561 static const XalanDOMChar s_template[];
562
563 // The string "value-of"
564 static const XalanDOMChar s_valueOf[];
565
566 // The string "variable"
567 static const XalanDOMChar s_variable[];
568
569 // The string "attribute"
570 static const XalanDOMChar s_attribute[];
571
572 // The string "otherwise"
573 static const XalanDOMChar s_otherwise[];
574
575 // The string "transform"
576 static const XalanDOMChar s_transform[];
577
578 // The string "stylesheet"
579 static const XalanDOMChar s_stylesheet[];
580
581 // The string "with-param"
582 static const XalanDOMChar s_withParam[];
583
584 // The string "strip-space"
585 static const XalanDOMChar s_stripSpace[];
586
587 // The string "apply-imports"
588 static const XalanDOMChar s_applyImports[];
589
590 // The string "attribute-set"
591 static const XalanDOMChar s_attributeSet[];
592
593 // The string "call-template"
594 static const XalanDOMChar s_callTemplate[];
595
596 // The string "decimal-format"
597 static const XalanDOMChar s_decimalFormat[];
598
599 // The string "preserve-space"
600 static const XalanDOMChar s_preserveSpace[];
601
602 // The string "apply-templates"
603 static const XalanDOMChar s_applyTemplates[];
604
605 // The string "namespace-alias"
606 static const XalanDOMChar s_namespaceAlias[];
607
608 // The string "processing-instruction"
609 static const XalanDOMChar s_processingInstruction[];
610
611 // A struct for an array that maps stylesheet element names
612 // to int tokens.
613 struct ElementTokenTableEntry
614 {
615 const XalanDOMChar* m_name;
616
617 eElementToken m_token;
618 };
619
620 static const ElementTokenTableEntry s_elementTokenTable[];
621
622 static const XalanSize_t s_elementTokenTableSize;
623
624 static const ElementTokenTableEntry& s_elementTokenTableLast;
625
626 static const ElementTokenTableEntry& s_elementTokenTableDummy;
627};
628
629
630
631}
632
633
634
635#endif // STYLESHEETCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
#define XALAN_XSLT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Class to hold a part, either a string or XPath, of an Attribute Value Template.
Definition AVTPart.hpp:44
Class to hold an Attribute Value Template.
Definition AVT.hpp:59
This class defines an interface for classes that resolve namespace prefixes to their URIs.
An default implementation of an abtract class which provides support for constructing the internal re...
StylesheetConstructionContextDefault(MemoryManager &theManager, XSLTEngineImpl &processor, XPathFactory &xpathFactory, VectorAllocatorSizeType theXalanDOMCharVectorAllocatorBlockSize=eDefaultXalanDOMCharVectorBlockSize, XalanAVTAllocator::size_type theAVTAllocatorBlockSize=eDefaultAVTBlockSize, XalanAVTPartSimpleAllocator::size_type theAVTPartSimpleAllocatorBlockSize=eDefaultAVTPartSimpleBlockSize, XalanAVTPartXPathAllocator::size_type theAVTPartXPathAllocatorBlockSize=eDefaultAVTPartXPathBlockSize, XalanQNameByValueAllocator::size_type theXalanQNameByValueAllocatorBlockSize=eDefaultXalanQNameByValueBlockSize, VectorAllocatorSizeType thePointerVectorAllocatorBlockSize=eDefaultPointerVectorBlockSize)
virtual const AVT * createAVT(const Locator *locator, const XalanDOMChar *name, const XalanDOMChar *stringedValue, const PrefixResolver &resolver)
Create an AVT instance.
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const Locator *locator, const XalanNode *sourceNode)
Function that is called when a problem event occurs.
virtual XalanDOMChar * allocateXalanDOMCharVector(XalanDOMString::size_type theLength)
Allocate a vector of XalanDOMChar of the specified size.
virtual XalanDOMChar * allocateXalanDOMCharVector(const XalanDOMChar *theString, XalanDOMString::size_type theLength=XalanDOMString::npos, bool fTerminate=true)
Allocate a vector of XalanDOMChar of the specified size.
virtual ElemTemplateElement * createElement(Stylesheet &stylesheetTree, const XalanDOMChar *name, const AttributeListType &atts, ExtensionNSHandler &handler, const Locator *locator=0)
virtual bool isXMLSpaceAttribute(const XalanDOMChar *theAttributeName, const Stylesheet &theStylesheet, const Locator *theLocator=0)
Given an name, determine if it is the xml:space attribute.
virtual const AVT ** allocateAVTPointerVector(size_type theLength)
Allocate a vector of const AVT* of the specified length.
virtual const XalanQName ** tokenizeQNames(size_type &count, const XalanDOMChar *qnameTokens, const NamespacesStackType &namespaces, const Locator *locator=0, bool fUseDefault=false)
Tokenize a string and return the QNames corresponding to those tokens.
virtual URLAutoPtrType getURLFromString(const XalanDOMString &urlString)
Determine the fully qualified URI for a string.
virtual double getXSLTVersionSupported() const
Get the latest XSLT version currently supported.
virtual bool isXSLUseAttributeSetsAttribute(const XalanDOMChar *theAttributeName, const Stylesheet &theStylesheet, const Locator *theLocator=0)
Given an name, determine if it is the xsl:use-attribute-sets attribute.
virtual void pushLocatorOnStack(const Locator *locator)
Push a locator on to the locator stack.
virtual XPath * createMatchPattern(const Locator *locator, const XalanDOMString &str, const PrefixResolver &resolver, bool allowVariableReferences=true, bool allowKeyFunction=true)
Create and initialize an xpath for a match pattern and return it.
virtual const AVTPart ** allocateAVTPartPointerVector(size_type theLength)
Allocate a vector of const AVTPart* of the specified length.
virtual void reset()
Reset the instance.
virtual XPath * createXPath(const Locator *locator, const XalanDOMString &str, const PrefixResolver &resolver, bool allowVariableReferences=true, bool allowKeyFunction=true)
Create and initialize an xpath and return it.
virtual ElemTemplateElement * createElement(int token, Stylesheet &stylesheetTree, const AttributeListType &atts, const Locator *locator=0)
virtual const AVTPart * createAVTPart(const XalanDOMChar *theString, XalanDOMString::size_type theLength=XalanDOMString::npos)
Create an AVTPart instance.
virtual const XalanMatchPatternData * createXalanMatchPatternData(const ElemTemplate &theTemplate, size_type thePosition, const XalanDOMString &theTargetString, const XPath &theMatchPattern, const XalanDOMString &thePatternString, XPath::eMatchScore thePriority)
Create an instance of XalanMatchPatternData, which describes data related to a match pattern and temp...
virtual XPath * createXPath(const Locator *locator, const XalanDOMChar *str, XalanDOMString::size_type len, const PrefixResolver &resolver, bool allowVariableReferences=true, bool allowKeyFunction=true)
Create and initialize an xpath and return it.
virtual Stylesheet * create(StylesheetRoot &theStylesheetRoot, const XalanDOMString &theBaseIdentifier)
Create a new Stylesheet instance.
virtual XPath * createMatchPattern(const Locator *locator, const XalanDOMChar *str, const PrefixResolver &resolver, bool allowVariableReferences=true, bool allowKeyFunction=true)
Create and initialize an xpath for a match pattern and return it.
virtual const XalanDOMString & getPooledString(const XalanDOMString &theString)
Get a pooled string given the source string.
virtual void destroy(StylesheetRoot *theStylesheetRoot)
Destroy a StylesheetRoot instance.
virtual const XalanDOMString & getXSLTNamespaceURI() const
Retrieve the URI for the current XSLT namespace, for example, "http://www.w3.org/1999/XSL/Transform".
virtual eElementToken getElementToken(const XalanDOMString &name) const
Given an XSL tag name, return an integer token that corresponds to the enums defined above.
virtual const Locator * getLocatorFromStack() const
Get the locator from the top of the locator stack.
virtual const XalanDOMString & getPooledString(const XalanDOMChar *theString, XalanDOMString::size_type theLength=XalanDOMString::npos)
Get a pooled string given the source character array.
virtual const AVTPart * createAVTPart(const Locator *locator, const XalanDOMChar *str, XalanDOMString::size_type len, const PrefixResolver &resolver)
Create an AVTPart instance.
virtual XalanDOMString & getURLStringFromString(const XalanDOMString &urlString, XalanDOMString &theResult)
Determine the fully qualified URI for a string.
static eElementToken getElementNameToken(const XalanDOMString &name)
virtual URLAutoPtrType getURLFromString(const XalanDOMString &urlString, const XalanDOMString &base)
Determine the fully qualified URI for a string.
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const XalanNode *sourceNode)
Function that is called when a problem event occurs.
virtual StylesheetRoot * create(const XalanDOMString &theBaseIdentifier)
Create a new StylesheetRoot instance.
virtual bool releaseCachedString(XalanDOMString &theString)
Return a cached string.
virtual XalanDOMString & getCachedString()
Get a cached string for temporary use.
virtual const XalanQName * createXalanQName(const XalanDOMString &qname, const NamespacesStackType &namespaces, const Locator *locator=0, bool fUseDefault=false)
Create a XalanQName-derived instance.
virtual bool isValidQName(const XalanDOMChar *theName, const Stylesheet &theStylesheet, const Locator *theLocator=0)
Given an name, determine if it is a valid QName.
virtual ElemTemplateElement * createElement(int token, Stylesheet &stylesheetTree, const XalanDOMChar *name, const AttributeListType &atts, const Locator *locator=0)
virtual XalanDOMString & getURLStringFromString(const XalanDOMString &urlString, const XalanDOMString &base, XalanDOMString &theResult)
Determine the fully qualified URI for a string.
XalanDOMCharVectorAllocatorType::size_type VectorAllocatorSizeType
virtual XalanDocument * parseXML(const XalanDOMString &urlString, DocumentHandler *docHandler, XalanDocument *docToRegister, ErrorHandler *theErrorHandler=0)
Read in the XML file, either producing a Document or calling SAX events, and register the document in...
virtual ElemTemplateElement * createElement(Stylesheet &stylesheetTree, const XalanDOMChar *chars, XalanDOMString::size_type length, bool preserveSpace, bool disableOutputEscaping, const Locator *locator=0)
Create a an element for literal text.
virtual void popLocatorStack()
Pop the locator from the top of the locator stack.
virtual const XalanQName * createXalanQName(const XalanDOMChar *qname, const NamespacesStackType &namespaces, const Locator *locator=0, bool fUseDefault=false)
Create a XalanQName-derived instance.
virtual XPath * createXPath(const Locator *locator, const XalanDOMChar *str, const PrefixResolver &resolver, bool allowVariableReferences=true, bool allowKeyFunction=true)
Create and initialize an xpath and return it.
virtual StylesheetRoot * create(const XSLTInputSource &theInputSource)
Create a new StylesheetRoot instance.
virtual const XalanDOMString & getXalanXSLNameSpaceURL() const
Get the Xalan namespace for built-in extensions.
This acts as the stylesheet root of the stylesheet tree, and holds values that are shared by all styl...
This class represents the base stylesheet or an "import" stylesheet.
It's the responsibility of the XSLTEngineImpl class, collaborating with the XML parser liaison,...
ArenaAllocatorType::size_type size_type
Xalan implementation of deque.
This class contains information concerning a match pattern in a stylesheet.
Class to represent a qualified name.
size_t size_type
Definition XalanMap.hpp:46
xercesc::AttributeList AttributeListType