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(FORMATTERTOXERCESDOM_HEADER_GUARD_1357924680) 00019 #define FORMATTERTOXERCESDOM_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/Include/XalanVector.hpp> 00029 00030 00031 00032 // Base class header file. 00033 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00034 00035 00036 00037 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00038 00039 00040 00041 #include <xalanc/XercesParserLiaison/XercesWrapperTypes.hpp> 00042 00043 00044 00045 XALAN_CPP_NAMESPACE_BEGIN 00046 00047 00048 00049 /** 00050 * This class takes SAX events (in addition to some extra events that SAX 00051 * doesn't handle yet) and adds the result to a document or document fragment. 00052 */ 00053 class XALAN_XERCESPARSERLIAISON_EXPORT FormatterToXercesDOM : public FormatterListener 00054 { 00055 public: 00056 00057 /** 00058 * Construct a FormatterToXercesDOM instance. it will add the DOM nodes 00059 * to the document fragment. 00060 * 00061 * @param doc document for nodes 00062 * @param docFrag document fragment for nodes 00063 * @param currentElement current element for nodes 00064 */ 00065 FormatterToXercesDOM( 00066 DOMDocument_Type* doc, 00067 DOMDocumentFragmentType* docFrag, 00068 DOMElementType* currentElement, 00069 MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00070 00071 /** 00072 * Construct a FormatterToXercesDOM instance. it will add the DOM nodes 00073 * to the document. 00074 * 00075 * @param doc document for nodes 00076 * @param elem current element for nodes 00077 */ 00078 FormatterToXercesDOM( 00079 DOMDocument_Type* doc, 00080 DOMElementType* currentElement, 00081 MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00082 00083 virtual 00084 ~FormatterToXercesDOM(); 00085 00086 00087 // These methods are inherited from FormatterListener... 00088 00089 virtual void 00090 charactersRaw( 00091 const XMLCh* const chars, 00092 const size_type length); 00093 00094 virtual void 00095 comment(const XMLCh* const data); 00096 00097 virtual void 00098 cdata( 00099 const XMLCh* const ch, 00100 const size_type length); 00101 00102 virtual void 00103 entityReference(const XMLCh* const name); 00104 00105 virtual void 00106 setDocumentLocator(const Locator* const locator); 00107 00108 virtual void 00109 startDocument(); 00110 00111 virtual void 00112 endDocument(); 00113 00114 virtual void 00115 startElement( 00116 const XMLCh* const name, 00117 AttributeListType& attrs); 00118 00119 virtual void 00120 endElement(const XMLCh* const name); 00121 00122 virtual void 00123 characters( 00124 const XMLCh* const chars, 00125 const size_type length); 00126 00127 virtual void 00128 ignorableWhitespace( 00129 const XMLCh* const chars, 00130 const size_type length); 00131 00132 virtual void 00133 processingInstruction( 00134 const XMLCh* const target, 00135 const XMLCh* const data); 00136 00137 virtual void 00138 resetDocument(); 00139 00140 DOMDocument_Type* 00141 getDocument() const 00142 { 00143 return m_doc; 00144 } 00145 00146 void 00147 setDocument(DOMDocument_Type* theDocument) 00148 { 00149 m_doc = theDocument; 00150 } 00151 00152 DOMDocumentFragmentType* 00153 getDocumentFragment() const 00154 { 00155 return m_docFrag; 00156 } 00157 00158 void 00159 setDocumentFragment(DOMDocumentFragmentType* theDocumentFragment) 00160 { 00161 m_docFrag = theDocumentFragment; 00162 } 00163 00164 DOMElementType* 00165 getCurrentElement() const 00166 { 00167 return m_currentElem; 00168 } 00169 00170 void 00171 setCurrentElement(DOMElementType* theElement) 00172 { 00173 m_currentElem = theElement; 00174 } 00175 00176 private: 00177 00178 /** 00179 * Process any accumulated text and create a node for it. 00180 */ 00181 void 00182 processAccumulatedText(); 00183 00184 /** 00185 * Append a node to the current container. 00186 */ 00187 void 00188 append(DOMNodeType* newNode); 00189 00190 /** 00191 * Create the appropriate element, complete with attributes set. 00192 * 00193 * @param theElementName The name for the new element 00194 * @param attrs The SAX AttributeList for the new attributes. 00195 * @return A pointer to the new instance. 00196 */ 00197 DOMElementType* 00198 createElement( 00199 const XalanDOMChar* theElementName, 00200 AttributeListType& attrs); 00201 00202 void 00203 addAttributes( 00204 DOMElementType* theElement, 00205 AttributeListType& attrs); 00206 00207 00208 // Data members... 00209 DOMDocument_Type* m_doc; 00210 00211 DOMDocumentFragmentType* m_docFrag; 00212 00213 DOMElementType* m_currentElem; 00214 00215 typedef XalanVector<DOMElementType*> ElementStackType; 00216 00217 ElementStackType m_elemStack; 00218 00219 XalanDOMString m_buffer; 00220 00221 XalanDOMString m_textBuffer; 00222 00223 static const XalanDOMString s_emptyString; 00224 }; 00225 00226 00227 00228 XALAN_CPP_NAMESPACE_END 00229 00230 00231 00232 #endif // FORMATTERTODOM_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 |
|