00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(STYLESHEETCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680) 00019 #define STYLESHEETCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/Include/XalanVector.hpp> 00029 00030 00031 00032 #include <xalanc/PlatformSupport/ArenaAllocator.hpp> 00033 #include <xalanc/PlatformSupport/XalanArrayAllocator.hpp> 00034 #include <xalanc/PlatformSupport/XalanDOMStringPool.hpp> 00035 00036 00037 00038 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) || defined(XALAN_BUILD_DLL) 00039 #include <xalanc/XPath/XPathProcessor.hpp> 00040 #endif 00041 00042 00043 00044 #include <xalanc/Include/XalanMemMgrAutoPtr.hpp> 00045 00046 00047 00048 #include <xalanc/PlatformSupport/XalanDOMStringCache.hpp> 00049 00050 00051 00052 #include <xalanc/XPath/XalanQNameByReference.hpp> 00053 #include <xalanc/XPath/XalanQNameByValue.hpp> 00054 #include <xalanc/XPath/XalanQNameByValueAllocator.hpp> 00055 00056 00057 00058 // Base class header file... 00059 #include <xalanc/XSLT/StylesheetConstructionContext.hpp> 00060 00061 00062 00063 #include <xalanc/XSLT/AVT.hpp> 00064 #include <xalanc/XSLT/XalanAVTAllocator.hpp> 00065 #include <xalanc/XSLT/AVTPartSimple.hpp> 00066 #include <xalanc/XSLT/XalanAVTPartSimpleAllocator.hpp> 00067 #include <xalanc/XSLT/AVTPartXPath.hpp> 00068 #include <xalanc/XSLT/XalanAVTPartXPathAllocator.hpp> 00069 #include <xalanc/XSLT/XalanElemApplyTemplatesAllocator.hpp> 00070 #include <xalanc/XSLT/XalanElemAttributeAllocator.hpp> 00071 #include <xalanc/XSLT/XalanElemAttributeSetAllocator.hpp> 00072 #include <xalanc/XSLT/XalanElemCallTemplateAllocator.hpp> 00073 #include <xalanc/XSLT/XalanElemElementAllocator.hpp> 00074 #include <xalanc/XSLT/XalanElemLiteralResultAllocator.hpp> 00075 #include <xalanc/XSLT/XalanElemTemplateAllocator.hpp> 00076 #include <xalanc/XSLT/XalanElemTextLiteralAllocator.hpp> 00077 #include <xalanc/XSLT/XalanElemValueOfAllocator.hpp> 00078 #include <xalanc/XSLT/XalanElemVariableAllocator.hpp> 00079 #include "xalanc/XSLT/XalanMatchPatternDataAllocator.hpp" 00080 00081 00082 00083 XALAN_CPP_NAMESPACE_BEGIN 00084 00085 00086 00087 class XPathEnvSupport; 00088 class XPathFactory; 00089 class XPathProcessor; 00090 class XSLTEngineImpl; 00091 00092 00093 00094 /** 00095 * 00096 * An default implementation of an abtract class which provides support for 00097 * constructing the internal representation of a stylesheet. 00098 * 00099 */ 00100 class XALAN_XSLT_EXPORT StylesheetConstructionContextDefault : public StylesheetConstructionContext 00101 { 00102 public: 00103 00104 typedef XalanArrayAllocator<XalanDOMChar> XalanDOMCharVectorAllocatorType; 00105 typedef XalanArrayAllocator<const void*> PointerVectorAllocatorType; 00106 typedef XalanDOMCharVectorAllocatorType::size_type VectorAllocatorSizeType; 00107 00108 // Default size for vector allocation. 00109 enum { 00110 eDefaultXalanDOMCharVectorBlockSize = 1024, 00111 eDefaultAVTBlockSize = 128, 00112 eDefaultAVTPartSimpleBlockSize = 128, 00113 eDefaultAVTPartXPathBlockSize = 128, 00114 eDefaultXalanQNameByValueBlockSize = 32, 00115 eDefaultPointerVectorBlockSize = 512, 00116 eDefaultElemApplyTemplatesBlockSize = 10, 00117 eDefaultElemAttributeBlockSize = 10, 00118 eDefaultElemAttributeSetBlockSize = 10, 00119 eDefaultElemCallTemplateBlockSize = 10, 00120 eDefaultElemElementBlockSize = 10, 00121 eDefaultElemLiteralResultBlockSize = 20, 00122 eDefaultElemTemplateBlockSize = 10, 00123 eDefaultElemTextLiteralBlockSize = 20, 00124 eDefaultElemValueOfBlockSize = 10, 00125 eDefaultElemVariableBlockSize = 10, 00126 eDefaultMatchPatternDataBlockSize = 10 }; 00127 00128 /* 00129 * Construct an instance. If the stylesheet(s) constructed is/are meant to be reused (a.k.a. "compiled"), 00130 * the XObjectFactory and XPathFactory instance must exist for the lifetime of the construction context 00131 * and, therefore, for the lifetime of the stylesheet(s). Otherwise, XObject and XPath instance will be 00132 * destroyed when the corresponding factories are destryed, leaving pointers to destroyed objects in the. 00133 * stylesheet(s). 00134 * 00135 * @param processor a reference to an XSLTEngineImpl instance. Used for error reporting. 00136 * @param xpathFactory a reference to an XPathFactory instance. See comments above for important details. 00137 * @param theXalanDOMCharVectorAllocatorBlockSize The block size to use for allocating vectors of XalanDOMChars 00138 * @param theAVTAllocatorBlockSize The block size to use for allocating AVT instances. 00139 * @param theAVTPartSimpleAllocatorBlockSize The block size to use for allocating AVTPartSimple instances. 00140 * @param theAVTPartXPathAllocatorBlockSize The block size to use for allocating AVTPartXPath instances. 00141 * @param theXalanQNameByValueAllocatorBlockSize The block size to use for allocating XalanQNameByValue instances. 00142 * @param thePointerVectorAllocatorBlockSize The block size to use for allocating vectors of pointers. 00143 */ 00144 StylesheetConstructionContextDefault( 00145 MemoryManager& theManager, 00146 XSLTEngineImpl& processor, 00147 XPathFactory& xpathFactory, 00148 VectorAllocatorSizeType theXalanDOMCharVectorAllocatorBlockSize = eDefaultXalanDOMCharVectorBlockSize, 00149 XalanAVTAllocator::size_type theAVTAllocatorBlockSize = eDefaultAVTBlockSize, 00150 XalanAVTPartSimpleAllocator::size_type theAVTPartSimpleAllocatorBlockSize = eDefaultAVTPartSimpleBlockSize, 00151 XalanAVTPartXPathAllocator::size_type theAVTPartXPathAllocatorBlockSize = eDefaultAVTPartXPathBlockSize, 00152 XalanQNameByValueAllocator::size_type theXalanQNameByValueAllocatorBlockSize = eDefaultXalanQNameByValueBlockSize, 00153 VectorAllocatorSizeType thePointerVectorAllocatorBlockSize = eDefaultPointerVectorBlockSize); 00154 00155 virtual 00156 ~StylesheetConstructionContextDefault(); 00157 00158 00159 // These interfaces are inherited from StylesheetConstructionContext... 00160 00161 virtual void 00162 problem( 00163 eSource source, 00164 eClassification classification, 00165 const XalanDOMString& msg, 00166 const Locator* locator, 00167 const XalanNode* sourceNode); 00168 00169 virtual void 00170 problem( 00171 eSource source, 00172 eClassification classification, 00173 const XalanDOMString& msg, 00174 const XalanNode* sourceNode); 00175 00176 virtual void 00177 reset(); 00178 00179 virtual const XalanDOMString& 00180 getPooledString(const XalanDOMString& theString); 00181 00182 virtual const XalanDOMString& 00183 getPooledString( 00184 const XalanDOMChar* theString, 00185 XalanDOMString::size_type theLength = XalanDOMString::npos); 00186 00187 virtual XalanDOMString& 00188 getCachedString(); 00189 00190 virtual bool 00191 releaseCachedString(XalanDOMString& theString); 00192 00193 virtual StylesheetRoot* 00194 create(const XalanDOMString& theBaseIdentifier); 00195 00196 virtual StylesheetRoot* 00197 create(const XSLTInputSource& theInputSource); 00198 00199 virtual Stylesheet* 00200 create( 00201 StylesheetRoot& theStylesheetRoot, 00202 const XalanDOMString& theBaseIdentifier); 00203 00204 virtual void 00205 destroy(StylesheetRoot* theStylesheetRoot); 00206 00207 virtual URLAutoPtrType 00208 getURLFromString(const XalanDOMString& urlString); 00209 00210 virtual XalanDOMString& 00211 getURLStringFromString( 00212 const XalanDOMString& urlString, 00213 XalanDOMString& theResult); 00214 00215 virtual URLAutoPtrType 00216 getURLFromString( 00217 const XalanDOMString& urlString, 00218 const XalanDOMString& base); 00219 00220 virtual XalanDOMString& 00221 getURLStringFromString( 00222 const XalanDOMString& urlString, 00223 const XalanDOMString& base, 00224 XalanDOMString& theResult); 00225 00226 virtual const XalanDOMString& 00227 getXSLTNamespaceURI() const; 00228 00229 virtual XPath* 00230 createMatchPattern( 00231 const Locator* locator, 00232 const XalanDOMString& str, 00233 const PrefixResolver& resolver, 00234 bool allowVariableReferences = true, 00235 bool allowKeyFunction = true); 00236 00237 virtual XPath* 00238 createMatchPattern( 00239 const Locator* locator, 00240 const XalanDOMChar* str, 00241 const PrefixResolver& resolver, 00242 bool allowVariableReferences = true, 00243 bool allowKeyFunction = true); 00244 00245 virtual XPath* 00246 createXPath( 00247 const Locator* locator, 00248 const XalanDOMString& str, 00249 const PrefixResolver& resolver, 00250 bool allowVariableReferences = true, 00251 bool allowKeyFunction = true); 00252 00253 virtual XPath* 00254 createXPath( 00255 const Locator* locator, 00256 const XalanDOMChar* str, 00257 const PrefixResolver& resolver, 00258 bool allowVariableReferences = true, 00259 bool allowKeyFunction = true); 00260 00261 virtual XPath* 00262 createXPath( 00263 const Locator* locator, 00264 const XalanDOMChar* str, 00265 XalanDOMString::size_type len, 00266 const PrefixResolver& resolver, 00267 bool allowVariableReferences = true, 00268 bool allowKeyFunction = true); 00269 00270 virtual const Locator* 00271 getLocatorFromStack() const; 00272 00273 virtual void 00274 pushLocatorOnStack(const Locator* locator); 00275 00276 virtual void 00277 popLocatorStack(); 00278 00279 virtual const XalanDOMString& 00280 getXalanXSLNameSpaceURL() const; 00281 00282 virtual XalanDocument* 00283 parseXML( 00284 const XalanDOMString& urlString, 00285 DocumentHandler* docHandler, 00286 XalanDocument* docToRegister, 00287 ErrorHandler* theErrorHandler = 0); 00288 00289 virtual bool 00290 isXMLSpaceAttribute( 00291 const XalanDOMChar* theAttributeName, 00292 const Stylesheet& theStylesheet, 00293 const Locator* theLocator = 0); 00294 00295 virtual bool 00296 isXSLUseAttributeSetsAttribute( 00297 const XalanDOMChar* theAttributeName, 00298 const Stylesheet& theStylesheet, 00299 const Locator* theLocator = 0); 00300 00301 virtual bool 00302 isValidQName( 00303 const XalanDOMChar* theName, 00304 const Stylesheet& theStylesheet, 00305 const Locator* theLocator = 0); 00306 00307 virtual eElementToken 00308 getElementToken(const XalanDOMString& name) const; 00309 00310 virtual double 00311 getXSLTVersionSupported() const; 00312 00313 virtual XalanDOMChar* 00314 allocateXalanDOMCharVector(XalanDOMString::size_type theLength); 00315 00316 virtual XalanDOMChar* 00317 allocateXalanDOMCharVector( 00318 const XalanDOMChar* theString, 00319 XalanDOMString::size_type theLength = XalanDOMString::npos, 00320 bool fTerminate = true); 00321 00322 virtual const AVT* 00323 createAVT( 00324 const Locator* locator, 00325 const XalanDOMChar* name, 00326 const XalanDOMChar* stringedValue, 00327 const PrefixResolver& resolver); 00328 00329 virtual const AVTPart* 00330 createAVTPart( 00331 const XalanDOMChar* theString, 00332 XalanDOMString::size_type theLength = XalanDOMString::npos); 00333 00334 virtual const AVTPart* 00335 createAVTPart( 00336 const Locator* locator, 00337 const XalanDOMChar* str, 00338 XalanDOMString::size_type len, 00339 const PrefixResolver& resolver); 00340 00341 virtual const AVT** 00342 allocateAVTPointerVector(size_type theLength); 00343 00344 virtual const AVTPart** 00345 allocateAVTPartPointerVector(size_type theLength); 00346 00347 virtual const XalanQName* 00348 createXalanQName( 00349 const XalanDOMString& qname, 00350 const NamespacesStackType& namespaces, 00351 const Locator* locator = 0, 00352 bool fUseDefault = false); 00353 00354 virtual const XalanQName* 00355 createXalanQName( 00356 const XalanDOMChar* qname, 00357 const NamespacesStackType& namespaces, 00358 const Locator* locator = 0, 00359 bool fUseDefault = false); 00360 00361 virtual const XalanQName** 00362 tokenizeQNames( 00363 size_type& count, 00364 const XalanDOMChar* qnameTokens, 00365 const NamespacesStackType& namespaces, 00366 const Locator* locator = 0, 00367 bool fUseDefault = false); 00368 00369 virtual ElemTemplateElement* 00370 createElement( 00371 int token, 00372 Stylesheet& stylesheetTree, 00373 const AttributeListType& atts, 00374 const Locator* locator = 0); 00375 00376 virtual ElemTemplateElement* 00377 createElement( 00378 int token, 00379 Stylesheet& stylesheetTree, 00380 const XalanDOMChar* name, 00381 const AttributeListType& atts, 00382 const Locator* locator = 0); 00383 00384 virtual ElemTemplateElement* 00385 createElement( 00386 Stylesheet& stylesheetTree, 00387 const XalanDOMChar* chars, 00388 XalanDOMString::size_type length, 00389 bool preserveSpace, 00390 bool disableOutputEscaping, 00391 const Locator* locator = 0); 00392 00393 virtual ElemTemplateElement* 00394 createElement( 00395 Stylesheet& stylesheetTree, 00396 const XalanDOMChar* name, 00397 const AttributeListType& atts, 00398 ExtensionNSHandler& handler, 00399 const Locator* locator = 0); 00400 00401 virtual const XalanMatchPatternData* 00402 createXalanMatchPatternData( 00403 const ElemTemplate& theTemplate, 00404 size_type thePosition, 00405 const XalanDOMString& theTargetString, 00406 const XPath& theMatchPattern, 00407 const XalanDOMString& thePatternString, 00408 XPath::eMatchScore thePriority); 00409 00410 static eElementToken 00411 getElementNameToken(const XalanDOMString& name); 00412 00413 typedef XalanVector<StylesheetRoot*> StylesheetVectorType; 00414 typedef XalanVector<ElemTemplateElement*> ElemTemplateElementVectorType; 00415 00416 private: 00417 00418 const AVT** 00419 doAllocateAVTPointerVector(size_type theSize) 00420 { 00421 assert(sizeof(AVT**) == sizeof(PointerVectorAllocatorType::value_type)); 00422 00423 return reinterpret_cast<const AVT**>(m_pointerVectorAllocator.allocate(theSize)); 00424 } 00425 00426 const AVTPart** 00427 doAllocateAVTPartPointerVector(size_type theSize) 00428 { 00429 assert(sizeof(AVTPart**) == sizeof(PointerVectorAllocatorType::value_type)); 00430 00431 return reinterpret_cast<const AVTPart**>(m_pointerVectorAllocator.allocate(theSize)); 00432 } 00433 00434 const XalanQName** 00435 doAllocateXalanQNamePointerVector(size_type theSize) 00436 { 00437 assert(sizeof(XalanQName**) == sizeof(PointerVectorAllocatorType::value_type)); 00438 00439 return reinterpret_cast<const XalanQName**>(m_pointerVectorAllocator.allocate(theSize)); 00440 } 00441 00442 00443 XSLTEngineImpl& m_processor; 00444 00445 XPathFactory& m_xpathFactory; 00446 00447 typedef XalanMemMgrAutoPtr<XPathProcessor> XPathProcessAutoPtr; 00448 00449 XPathProcessAutoPtr m_xpathProcessor; 00450 00451 StylesheetVectorType m_stylesheets; 00452 00453 XalanDOMStringPool m_stringPool; 00454 00455 XalanDOMCharVectorAllocatorType m_xalanDOMCharVectorAllocator; 00456 00457 mutable XalanDOMString m_tempBuffer; 00458 00459 XalanQNameByValue m_scratchQName; 00460 00461 XalanDOMStringCache m_stringCache; 00462 00463 XalanAVTAllocator m_avtAllocator; 00464 00465 XalanAVTPartSimpleAllocator m_avtPartSimpleAllocator; 00466 00467 XalanAVTPartXPathAllocator m_avtPartXPathAllocator; 00468 00469 XalanQNameByValueAllocator m_xalanQNameByValueAllocator; 00470 00471 const XalanQNameByReference m_useAttributeSetsQName; 00472 00473 PointerVectorAllocatorType m_pointerVectorAllocator; 00474 00475 ElemTemplateElementVectorType m_allocatedElements; 00476 00477 XalanElemApplyTemplatesAllocator m_elemApplyTemplatesAllocator; 00478 00479 XalanElemAttributeAllocator m_elemAttributeAllocator; 00480 00481 XalanElemAttributeSetAllocator m_elemAttributeSetAllocator; 00482 00483 XalanElemCallTemplateAllocator m_elemCallTemplateAllocator; 00484 00485 XalanElemElementAllocator m_elemElementAllocator; 00486 00487 XalanElemLiteralResultAllocator m_elemLiteralResultAllocator; 00488 00489 XalanElemTemplateAllocator m_elemTemplateAllocator; 00490 00491 XalanElemTextLiteralAllocator m_elemTextLiteralAllocator; 00492 00493 XalanElemValueOfAllocator m_elemValueOfAllocator; 00494 00495 XalanElemVariableAllocator m_elemVariableAllocator; 00496 00497 XalanMatchPatternDataAllocator m_matchPatternDataAllocator; 00498 00499 const XalanQNameByReference m_spaceAttrQName; 00500 00501 // Static strings for stylesheet compilation... 00502 00503 // The string "if" 00504 static const XalanDOMChar s_if[]; 00505 00506 // The string "key" 00507 static const XalanDOMChar s_key[]; 00508 00509 // The string "copy" 00510 static const XalanDOMChar s_copy[]; 00511 00512 // The string "sort" 00513 static const XalanDOMChar s_sort[]; 00514 00515 // The string "text" 00516 static const XalanDOMChar s_text[]; 00517 00518 // The string "when" 00519 static const XalanDOMChar s_when[]; 00520 00521 // The string "empty" 00522 static const XalanDOMChar s_empty[]; 00523 00524 // The string "param" 00525 static const XalanDOMChar s_param[]; 00526 00527 // The string "choose" 00528 static const XalanDOMChar s_choose[]; 00529 00530 // The string "import" 00531 static const XalanDOMChar s_import[]; 00532 00533 // The string "number" 00534 static const XalanDOMChar s_number[]; 00535 00536 // The string "output" 00537 static const XalanDOMChar s_output[]; 00538 00539 // The string "comment" 00540 static const XalanDOMChar s_comment[]; 00541 00542 // The string "copy-of" 00543 static const XalanDOMChar s_copyOf[]; 00544 00545 // The string "element" 00546 static const XalanDOMChar s_element[]; 00547 00548 // The string "include" 00549 static const XalanDOMChar s_include[]; 00550 00551 // The string "message" 00552 static const XalanDOMChar s_message[]; 00553 00554 // The string "fallback" 00555 static const XalanDOMChar s_fallback[]; 00556 00557 // The string "for-each" 00558 static const XalanDOMChar s_forEach[]; 00559 00560 // The string "template" 00561 static const XalanDOMChar s_template[]; 00562 00563 // The string "value-of" 00564 static const XalanDOMChar s_valueOf[]; 00565 00566 // The string "variable" 00567 static const XalanDOMChar s_variable[]; 00568 00569 // The string "attribute" 00570 static const XalanDOMChar s_attribute[]; 00571 00572 // The string "otherwise" 00573 static const XalanDOMChar s_otherwise[]; 00574 00575 // The string "transform" 00576 static const XalanDOMChar s_transform[]; 00577 00578 // The string "stylesheet" 00579 static const XalanDOMChar s_stylesheet[]; 00580 00581 // The string "with-param" 00582 static const XalanDOMChar s_withParam[]; 00583 00584 // The string "strip-space" 00585 static const XalanDOMChar s_stripSpace[]; 00586 00587 // The string "apply-imports" 00588 static const XalanDOMChar s_applyImports[]; 00589 00590 // The string "attribute-set" 00591 static const XalanDOMChar s_attributeSet[]; 00592 00593 // The string "call-template" 00594 static const XalanDOMChar s_callTemplate[]; 00595 00596 // The string "decimal-format" 00597 static const XalanDOMChar s_decimalFormat[]; 00598 00599 // The string "preserve-space" 00600 static const XalanDOMChar s_preserveSpace[]; 00601 00602 // The string "apply-templates" 00603 static const XalanDOMChar s_applyTemplates[]; 00604 00605 // The string "namespace-alias" 00606 static const XalanDOMChar s_namespaceAlias[]; 00607 00608 // The string "processing-instruction" 00609 static const XalanDOMChar s_processingInstruction[]; 00610 00611 // A struct for an array that maps stylesheet element names 00612 // to int tokens. 00613 struct ElementTokenTableEntry 00614 { 00615 const XalanDOMChar* m_name; 00616 00617 eElementToken m_token; 00618 }; 00619 00620 static const ElementTokenTableEntry s_elementTokenTable[]; 00621 00622 static const XalanSize_t s_elementTokenTableSize; 00623 00624 static const ElementTokenTableEntry& s_elementTokenTableLast; 00625 00626 static const ElementTokenTableEntry& s_elementTokenTableDummy; 00627 }; 00628 00629 00630 00631 XALAN_CPP_NAMESPACE_END 00632 00633 00634 00635 #endif // STYLESHEETCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|