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(XALANSOURCETREEDOCUMENT_HEADER_GUARD_1357924680) 00019 #define XALANSOURCETREEDOCUMENT_HEADER_GUARD_1357924680 00020 00021 00022 00023 #include <xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp> 00024 00025 00026 00027 #include <xalanc/XalanDOM/XalanDocument.hpp> 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 00030 00031 00032 #include <xalanc/Include/STLHelper.hpp> 00033 #include <xalanc/Include/XalanMap.hpp> 00034 00035 00036 00037 #include <xalanc/PlatformSupport/XalanArrayAllocator.hpp> 00038 #include <xalanc/PlatformSupport/XalanDOMStringAllocator.hpp> 00039 #include <xalanc/PlatformSupport/XalanDOMStringPool.hpp> 00040 00041 00042 00043 #include <xalanc/XalanSourceTree/XalanSourceTreeAttributeAllocator.hpp> 00044 #include <xalanc/XalanSourceTree/XalanSourceTreeAttributeNSAllocator.hpp> 00045 #include <xalanc/XalanSourceTree/XalanSourceTreeCommentAllocator.hpp> 00046 #include <xalanc/XalanSourceTree/XalanSourceTreeElementAAllocator.hpp> 00047 #include <xalanc/XalanSourceTree/XalanSourceTreeElementANSAllocator.hpp> 00048 #include <xalanc/XalanSourceTree/XalanSourceTreeElementNAAllocator.hpp> 00049 #include <xalanc/XalanSourceTree/XalanSourceTreeElementNANSAllocator.hpp> 00050 #include <xalanc/XalanSourceTree/XalanSourceTreeProcessingInstructionAllocator.hpp> 00051 #include <xalanc/XalanSourceTree/XalanSourceTreeTextAllocator.hpp> 00052 #include <xalanc/XalanSourceTree/XalanSourceTreeTextIWSAllocator.hpp> 00053 00054 00055 00056 XALAN_DECLARE_XERCES_CLASS(Attributes) 00057 XALAN_DECLARE_XERCES_CLASS(AttributeList) 00058 00059 00060 00061 XALAN_CPP_NAMESPACE_BEGIN 00062 00063 00064 00065 typedef XERCES_CPP_NAMESPACE_QUALIFIER Attributes AttributesType; 00066 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType; 00067 00068 00069 00070 class PrefixResolver; 00071 class XalanSourceTreeAttr; 00072 00073 00074 00075 class XALAN_XALANSOURCETREE_EXPORT XalanSourceTreeDocument : public XalanDocument 00076 { 00077 public: 00078 00079 typedef XalanArrayAllocator<XalanSourceTreeAttr*> AttributesArrayAllocatorType; 00080 00081 typedef XalanMap< 00082 const XalanDOMChar*, 00083 XalanSourceTreeElement*> ElementByIDMapType; 00084 00085 typedef XalanMap< 00086 XalanDOMString, 00087 XalanDOMString> UnparsedEntityURIMapType; 00088 00089 00090 /** 00091 * Perform static initialization. See class XalanSourceTreeInit. 00092 */ 00093 static void 00094 initialize(MemoryManager& theManager); 00095 00096 /** 00097 * Perform static shut down. See class XalanSourceTreeInit. 00098 */ 00099 static void 00100 terminate(); 00101 00102 00103 enum { eDefaultAttributeAllocatorBlockSize = 100, 00104 eDefaultAttributeNSAllocatorBlockSize = 50, 00105 eDefaultCommentAllocatorBlockSize = 10, 00106 eDefaultElementAllocatorBlockSize = 100, 00107 eDefaultElementNSAllocatorBlockSize = 100, 00108 eDefaultPIAllocatorBlockSize = 10, 00109 eDefaultTextAllocatorBlockSize = 100, 00110 eDefaultTextIWSAllocatorBlockSize = 100, 00111 eDefaultNamesStringPoolBlockSize = XalanDOMStringPool::eDefaultBlockSize, 00112 eDefaultNamesStringPoolBucketCount = XalanDOMStringPool::eDefaultBucketCount, 00113 eDefaultNamesStringPoolBucketSize = XalanDOMStringPool::eDefaultBucketSize, 00114 eDefaultValuesStringPoolBlockSize = XalanDOMStringPool::eDefaultBlockSize, 00115 eDefaultValuesStringPoolBucketCount = 997, 00116 eDefaultValuesStringPoolBucketSize = XalanDOMStringPool::eDefaultBucketSize }; 00117 00118 00119 typedef XalanSourceTreeAttributeAllocator::size_type allocator_size_type; 00120 typedef XalanDOMStringPool::block_size_type block_size_type; 00121 typedef XalanDOMStringPool::bucket_count_type bucket_count_type; 00122 typedef XalanDOMStringPool::bucket_size_type bucket_size_type; 00123 00124 /** 00125 * 00126 * Constructor for XalanSourceTreeDocument. 00127 * 00128 * @param fPoolAllText If false, text node data that is not whitespace will not be pooled. 00129 * @param theNamesStringPoolBlockSize The block size for allocating strings in the name pool 00130 * @param theNamesStringPoolBucketCount The number of buckets for allocating strings in the name pool 00131 * @param theNamesStringPoolBucketSize The bucket size for allocating strings in the name pool 00132 * @param theValuesStringPoolBlockSize The block size for allocating strings in the values pool 00133 * @param theValuesStringPoolBucketCount The number of buckets for allocating strings in the values pool 00134 * @param theValuesStringPoolBucketSize The bucket size for allocating strings in the values pool 00135 * 00136 */ 00137 XalanSourceTreeDocument( 00138 MemoryManager& theManager, 00139 bool fPoolAllText = s_poolAllTextNodes, 00140 block_size_type theNamesStringPoolBlockSize = eDefaultNamesStringPoolBlockSize, 00141 bucket_count_type theNamesStringPoolBucketCount = eDefaultNamesStringPoolBucketCount, 00142 bucket_size_type theNamesStringPoolBucketSize = eDefaultNamesStringPoolBucketSize, 00143 block_size_type theValuesStringPoolBlockSize = eDefaultValuesStringPoolBlockSize, 00144 bucket_count_type theValuesStringPoolBucketCount = eDefaultValuesStringPoolBucketCount, 00145 bucket_size_type theValuesStringPoolBucketSize = eDefaultValuesStringPoolBucketSize); 00146 00147 00148 static XalanSourceTreeDocument* 00149 create( 00150 MemoryManager& theManager, 00151 bool fPoolAllText = s_poolAllTextNodes, 00152 block_size_type theNamesStringPoolBlockSize = eDefaultNamesStringPoolBlockSize, 00153 bucket_count_type theNamesStringPoolBucketCount = eDefaultNamesStringPoolBucketCount, 00154 bucket_size_type theNamesStringPoolBucketSize = eDefaultNamesStringPoolBucketSize, 00155 block_size_type theValuesStringPoolBlockSize = eDefaultValuesStringPoolBlockSize, 00156 bucket_count_type theValuesStringPoolBucketCount = eDefaultValuesStringPoolBucketCount, 00157 bucket_size_type theValuesStringPoolBucketSize = eDefaultValuesStringPoolBucketSize); 00158 00159 /** 00160 * 00161 * Constructor for XalanSourceTreeDocument. 00162 * 00163 * @param theAttributeBlockSize The block size for allocating attribute nodes 00164 * @param theAttributeNSBlockSize The block size for allocating attribute NS nodes 00165 * @param theCommentBlockSize The block size for allocating comment nodes 00166 * @param theElementBlockSize The block size for allocating element nodes 00167 * @param theElementNSBlockSize The block size for allocating element nodes 00168 * @param theTextBlockSize The block size for allocating text nodes, 00169 * @param theTextIWSBlockSize The block size for allocating text IWS nodes, 00170 * @param fPoolAllText If false, text node data that is not whitespace will not be pooled. 00171 * 00172 */ 00173 XalanSourceTreeDocument( 00174 MemoryManager& theManager, 00175 allocator_size_type theAttributeBlockSize, 00176 allocator_size_type theAttributeNSBlockSize, 00177 allocator_size_type theCommentBlockSize, 00178 allocator_size_type theElementBlockSize, 00179 allocator_size_type theElementNSBlockSize, 00180 allocator_size_type thePIBlockSize, 00181 allocator_size_type theTextBlockSize, 00182 allocator_size_type theTextIWSBlockSize, 00183 bool fPoolAllText = s_poolAllTextNodes); 00184 00185 virtual 00186 ~XalanSourceTreeDocument(); 00187 00188 // These interfaces are inherited from XalanNode... 00189 virtual const XalanDOMString& 00190 getNodeName() const; 00191 00192 virtual const XalanDOMString& 00193 getNodeValue() const; 00194 00195 virtual NodeType 00196 getNodeType() const; 00197 00198 virtual XalanNode* 00199 getParentNode() const; 00200 00201 virtual const XalanNodeList* 00202 getChildNodes() const; 00203 00204 virtual XalanNode* 00205 getFirstChild() const; 00206 00207 virtual XalanNode* 00208 getLastChild() const; 00209 00210 virtual XalanNode* 00211 getPreviousSibling() const; 00212 00213 virtual XalanNode* 00214 getNextSibling() const; 00215 00216 virtual const XalanNamedNodeMap* 00217 getAttributes() const; 00218 00219 virtual XalanDocument* 00220 getOwnerDocument() const; 00221 00222 virtual const XalanDOMString& 00223 getNamespaceURI() const; 00224 00225 virtual const XalanDOMString& 00226 getPrefix() const; 00227 00228 virtual const XalanDOMString& 00229 getLocalName() const; 00230 00231 virtual bool 00232 isIndexed() const; 00233 00234 virtual IndexType 00235 getIndex() const; 00236 00237 virtual XalanElement* 00238 getDocumentElement() const; 00239 00240 virtual XalanElement* 00241 getElementById(const XalanDOMString& elementId) const; 00242 00243 00244 // Interfaces not inherited from XalanDocument... 00245 00246 static bool 00247 getPoolAllTextNodes() 00248 { 00249 return s_poolAllTextNodes; 00250 } 00251 00252 static void 00253 setPoolAllTextNodes(bool fPool) 00254 { 00255 s_poolAllTextNodes = fPool; 00256 } 00257 00258 00259 XalanSourceTreeElement* 00260 createElementNode( 00261 const XalanDOMChar* name, 00262 const AttributeListType& attrs, 00263 XalanNode* theParentNode = 0, 00264 XalanNode* thePreviousSibling = 0, 00265 XalanNode* theNextSibling = 0, 00266 bool fAddXMLNamespaceAttribute = false); 00267 00268 XalanSourceTreeElement* 00269 createElementNode( 00270 const XalanDOMChar* uri, 00271 const XalanDOMChar* localname, 00272 const XalanDOMChar* qname, 00273 const AttributesType& attrs, 00274 XalanNode* theParentNode = 0, 00275 XalanNode* thePreviousSibling = 0, 00276 XalanNode* theNextSibling = 0, 00277 bool fAddXMLNamespaceAttribute = false); 00278 00279 XalanSourceTreeElement* 00280 createElementNode( 00281 const XalanDOMChar* tagName, 00282 const AttributeListType& attrs, 00283 const PrefixResolver& thePrefixResolver, 00284 XalanNode* theParentNode = 0, 00285 XalanNode* thePreviousSibling = 0, 00286 XalanNode* theNextSibling = 0, 00287 bool fAddXMLNamespaceAttribute = false); 00288 00289 XalanSourceTreeElement* 00290 createElementNode( 00291 const XalanDOMChar* name, 00292 const AttributesType& attrs, 00293 XalanNode* theParentNode = 0, 00294 XalanNode* thePreviousSibling = 0, 00295 XalanNode* theNextSibling = 0, 00296 bool fAddXMLNamespaceAttribute = false); 00297 00298 XalanSourceTreeComment* 00299 createCommentNode( 00300 const XalanDOMChar* data, 00301 XalanDOMString::size_type length, 00302 XalanNode* theParentNode = 0, 00303 XalanNode* thePreviousSibling = 0, 00304 XalanNode* theNextSibling = 0); 00305 00306 XalanSourceTreeProcessingInstruction* 00307 createProcessingInstructionNode( 00308 const XalanDOMChar* target, 00309 const XalanDOMChar* data, 00310 XalanNode* theParentNode = 0, 00311 XalanNode* thePreviousSibling = 0, 00312 XalanNode* theNextSibling = 0); 00313 00314 XalanSourceTreeText* 00315 createTextNode( 00316 const XalanDOMChar* chars, 00317 XalanDOMString::size_type length, 00318 XalanNode* theParentNode = 0, 00319 XalanNode* thePreviousSibling = 0, 00320 XalanNode* theNextSibling = 0); 00321 00322 XalanSourceTreeText* 00323 createTextIWSNode( 00324 const XalanDOMChar* chars, 00325 XalanDOMString::size_type length, 00326 XalanNode* theParentNode = 0, 00327 XalanNode* thePreviousSibling = 0, 00328 XalanNode* theNextSibling = 0); 00329 00330 void 00331 unparsedEntityDeclaration( 00332 const XalanDOMChar* name, 00333 const XalanDOMChar* publicId, 00334 const XalanDOMChar* systemId, 00335 const XalanDOMChar* notationName); 00336 00337 const XalanDOMString& 00338 getUnparsedEntityURI(const XalanDOMString& theName) const; 00339 00340 // Child node setters... 00341 void 00342 appendChildNode(XalanSourceTreeComment* theChild); 00343 00344 void 00345 appendChildNode(XalanSourceTreeElement* theChild); 00346 00347 void 00348 appendChildNode(XalanSourceTreeProcessingInstruction* theChild); 00349 00350 private: 00351 00352 MemoryManager& 00353 getMemoryManager() 00354 { 00355 return m_stringBuffer.getMemoryManager(); 00356 } 00357 00358 // Helper functions... 00359 XalanSourceTreeAttr* 00360 createAttribute( 00361 const XalanDOMChar* theName, 00362 const XalanDOMChar* theValue, 00363 XalanSourceTreeElement* theOwnerElement, 00364 const PrefixResolver& thePrefixResolver); 00365 00366 XalanSourceTreeAttr* 00367 createAttribute( 00368 const XalanDOMChar* theName, 00369 const XalanDOMChar* theValue, 00370 XalanSourceTreeElement* theOwnerElement); 00371 00372 size_t 00373 createAttributes( 00374 XalanSourceTreeAttr** theAttributeVector, 00375 const AttributeListType& attrs, 00376 size_t theStartIndex, 00377 XalanSourceTreeElement* theOwnerElement, 00378 bool fCreateNamespaces, 00379 const PrefixResolver* thePrefixResolver = 0); 00380 00381 XalanSourceTreeElement* 00382 createElementNode( 00383 const XalanDOMChar* theTagName, 00384 XalanSourceTreeAttr** theAttributeVector, 00385 XalanSize_t theAttributeCount, 00386 XalanNode* theParentNode, 00387 XalanNode* thePreviousSibling, 00388 XalanNode* theNextSibling, 00389 const PrefixResolver& thePrefixResolver); 00390 00391 size_t 00392 createAttributes( 00393 XalanSourceTreeAttr** theAttributeVector, 00394 const AttributesType& theAttributes, 00395 size_t theStartIndex, 00396 XalanSourceTreeElement* theOwnerElement, 00397 bool fCreateNamespaces); 00398 00399 void 00400 createAttributes( 00401 const AttributesType& theAttributes, 00402 XalanSourceTreeAttr** theAttributeVector, 00403 XalanSourceTreeElement* theOwnerElement, 00404 bool fAddXMLNamespaceAttribute); 00405 00406 const XalanDOMString& 00407 getTextNodeString( 00408 const XalanDOMChar* chars, 00409 XalanDOMString::size_type length); 00410 00411 const XalanDOMString* 00412 getNamespaceForPrefix( 00413 const XalanDOMChar* theName, 00414 const PrefixResolver& thePrefixResolver, 00415 XalanDOMString& thePrefix, 00416 bool fUseDefault, 00417 const XalanDOMChar** theLocalName = 0); 00418 00419 // Not implemented... 00420 XalanSourceTreeDocument(const XalanSourceTreeDocument& theSource); 00421 00422 XalanSourceTreeDocument& 00423 operator=(const XalanSourceTreeDocument& theRHS); 00424 00425 bool 00426 operator==(const XalanSourceTreeDocument& theRHS) const; 00427 00428 00429 // Data members... 00430 XalanNode* m_firstChild; 00431 00432 XalanSourceTreeElement* m_documentElement; 00433 00434 XalanSourceTreeAttributeAllocator m_attributeAllocator; 00435 00436 XalanSourceTreeAttributeNSAllocator m_attributeNSAllocator; 00437 00438 XalanSourceTreeCommentAllocator m_commentAllocator; 00439 00440 XalanSourceTreeElementAAllocator m_elementAAllocator; 00441 00442 XalanSourceTreeElementANSAllocator m_elementANSAllocator; 00443 00444 XalanSourceTreeElementNAAllocator m_elementNAAllocator; 00445 00446 XalanSourceTreeElementNANSAllocator m_elementNANSAllocator; 00447 00448 XalanSourceTreeProcessingInstructionAllocator m_piAllocator; 00449 00450 XalanSourceTreeTextAllocator m_textAllocator; 00451 00452 XalanSourceTreeTextIWSAllocator m_textIWSAllocator; 00453 00454 XalanDOMStringPool m_namesStringPool; 00455 00456 XalanDOMStringPool m_valuesStringPool; 00457 00458 AttributesArrayAllocatorType m_attributesVector; 00459 00460 IndexType m_nextIndexValue; 00461 00462 const bool m_poolAllText; 00463 00464 ElementByIDMapType m_elementsByID; 00465 00466 UnparsedEntityURIMapType m_unparsedEntityURIs; 00467 00468 XalanDOMStringAllocator m_nonPooledStrings; 00469 00470 XalanDOMString m_stringBuffer; 00471 00472 static const XalanDOMString& s_nameString; 00473 00474 static bool s_poolAllTextNodes; 00475 }; 00476 00477 00478 00479 XALAN_CPP_NAMESPACE_END 00480 00481 00482 00483 #endif // !defined(XALANSOURCETREEDOCUMENT_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 |
|