00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680) 00017 #define FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp> 00023 00024 00025 00026 #include <vector> 00027 00028 00029 00030 // Base class header file. 00031 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00032 00033 00034 00035 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00036 00037 00038 00039 XALAN_CPP_NAMESPACE_BEGIN 00040 00041 00042 00043 class PrefixResolver; 00044 class XalanNode; 00045 class XalanSourceTreeDocument; 00046 class XalanSourceTreeDocumentFragment; 00047 class XalanSourceTreeElement; 00048 00049 00050 00055 class XALAN_XALANSOURCETREE_EXPORT FormatterToSourceTree : public FormatterListener 00056 { 00057 public: 00058 00059 #if defined(XALAN_NO_STD_NAMESPACE) 00060 typedef vector<XalanSourceTreeElement*> ElementStackType; 00061 typedef vector<XalanNode*> LastChildStackType; 00062 #else 00063 typedef std::vector<XalanSourceTreeElement*> ElementStackType; 00064 typedef std::vector<XalanNode*> LastChildStackType; 00065 #endif 00066 00067 enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 }; 00068 00072 static void 00073 initialize(); 00074 00078 static void 00079 terminate(); 00080 00081 00088 explicit 00089 FormatterToSourceTree(XalanSourceTreeDocument* theDocument = 0); 00090 00098 FormatterToSourceTree( 00099 XalanSourceTreeDocument* theDocument, 00100 XalanSourceTreeDocumentFragment* theDocumentFragment); 00101 00102 virtual 00103 ~FormatterToSourceTree(); 00104 00105 00106 XalanSourceTreeDocument* 00107 getDocument() const 00108 { 00109 return m_document; 00110 } 00111 00112 void 00113 setDocument(XalanSourceTreeDocument* theDocument) 00114 { 00115 m_document = theDocument; 00116 } 00117 00118 XalanSourceTreeDocumentFragment* 00119 getDocumentFragment() const 00120 { 00121 return m_documentFragment; 00122 } 00123 00124 void 00125 setDocumentFragment(XalanSourceTreeDocumentFragment* theDocumentFragment) 00126 { 00127 m_documentFragment = theDocumentFragment; 00128 } 00129 00130 XalanSourceTreeElement* 00131 getCurrentElement() const 00132 { 00133 return m_currentElement; 00134 } 00135 00136 void 00137 setCurrentElement(XalanSourceTreeElement* theElement) 00138 { 00139 m_currentElement = theElement; 00140 } 00141 00142 // These methods are inherited from DocumentHandler ... 00143 00144 virtual void 00145 charactersRaw( 00146 const XMLCh* const chars, 00147 const unsigned int length); 00148 00149 virtual void 00150 comment(const XMLCh* const data); 00151 00152 virtual void 00153 cdata( 00154 const XMLCh* const ch, 00155 const unsigned int length); 00156 00157 virtual void 00158 entityReference(const XMLCh* const name); 00159 00160 virtual void 00161 setDocumentLocator(const LocatorType* const locator); 00162 00163 virtual void 00164 startDocument(); 00165 00166 virtual void 00167 endDocument(); 00168 00169 virtual void 00170 startElement( 00171 const XMLCh* const name, 00172 AttributeListType& attrs); 00173 00174 virtual void 00175 endElement(const XMLCh* const name); 00176 00177 virtual void 00178 characters( 00179 const XMLCh* const chars, 00180 const unsigned int length); 00181 00182 virtual void 00183 ignorableWhitespace( 00184 const XMLCh* const chars, 00185 const unsigned int length); 00186 00187 virtual void 00188 processingInstruction( 00189 const XMLCh* const target, 00190 const XMLCh* const data); 00191 00192 virtual void 00193 resetDocument(); 00194 00195 private: 00196 00197 // Some utility functions... 00198 void 00199 processAccumulatedText(); 00200 00201 XalanSourceTreeElement* 00202 createElementNode( 00203 const XalanDOMChar* name, 00204 AttributeListType& attrs, 00205 XalanSourceTreeElement* theParentElement); 00206 00207 void 00208 doCharacters( 00209 const XalanDOMChar* chars, 00210 XalanDOMString::size_type length); 00211 00212 void 00213 doProcessingInstruction( 00214 const XalanDOMChar* target, 00215 const XalanDOMChar* data); 00216 00217 00218 // Data members... 00219 XalanSourceTreeDocument* m_document; 00220 00221 XalanSourceTreeDocumentFragment* m_documentFragment; 00222 00223 XalanSourceTreeElement* m_currentElement; 00224 00225 ElementStackType m_elementStack; 00226 00227 // The last child appended to the current element. This is 00228 // an important optimization, because XalanSourceTreeElement 00229 // does not have a pointer to it's last child. Without this, 00230 // appending a child becomes a linear search. 00231 XalanNode* m_lastChild; 00232 00233 // Stack of last children appended. There is a one-to-one 00234 // correspondance to the entries in m_elementStack. 00235 LastChildStackType m_lastChildStack; 00236 00237 XalanDOMString m_textBuffer; 00238 }; 00239 00240 00241 00242 XALAN_CPP_NAMESPACE_END 00243 00244 00245 00246 #endif // FORMATTERTOSOURCETREE_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.8 |
|