Xalan-C++ API Reference  1.12.0
FormatterToXercesDOM.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(FORMATTERTOXERCESDOM_HEADER_GUARD_1357924680)
19 #define FORMATTERTOXERCESDOM_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 // Base class header file.
34 
35 
36 
38 
39 
40 
42 
43 
44 
45 namespace XALAN_CPP_NAMESPACE {
46 
47 
48 
49 /**
50  * This class takes SAX events (in addition to some extra events that SAX
51  * doesn't handle yet) and adds the result to a document or document fragment.
52  */
54 {
55 public:
56 
57  /**
58  * Construct a FormatterToXercesDOM instance. it will add the DOM nodes
59  * to the document fragment.
60  *
61  * @param doc document for nodes
62  * @param docFrag document fragment for nodes
63  * @param currentElement current element for nodes
64  */
66  DOMDocument_Type* doc,
67  DOMDocumentFragmentType* docFrag,
68  DOMElementType* currentElement,
69  MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
70 
71  /**
72  * Construct a FormatterToXercesDOM instance. it will add the DOM nodes
73  * to the document.
74  *
75  * @param doc document for nodes
76  * @param elem current element for nodes
77  */
79  DOMDocument_Type* doc,
80  DOMElementType* currentElement,
81  MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
82 
83  virtual
85 
86 
87  // These methods are inherited from FormatterListener...
88 
89  virtual void
90  charactersRaw(
91  const XMLCh* const chars,
92  const size_type length);
93 
94  virtual void
95  comment(const XMLCh* const data);
96 
97  virtual void
98  cdata(
99  const XMLCh* const ch,
100  const size_type length);
101 
102  virtual void
103  entityReference(const XMLCh* const name);
104 
105  virtual void
106  setDocumentLocator(const Locator* const locator);
107 
108  virtual void
109  startDocument();
110 
111  virtual void
112  endDocument();
113 
114  virtual void
115  startElement(
116  const XMLCh* const name,
117  AttributeListType& attrs);
118 
119  virtual void
120  endElement(const XMLCh* const name);
121 
122  virtual void
123  characters(
124  const XMLCh* const chars,
125  const size_type length);
126 
127  virtual void
128  ignorableWhitespace(
129  const XMLCh* const chars,
130  const size_type length);
131 
132  virtual void
133  processingInstruction(
134  const XMLCh* const target,
135  const XMLCh* const data);
136 
137  virtual void
138  resetDocument();
139 
141  getDocument() const
142  {
143  return m_doc;
144  }
145 
146  void
148  {
149  m_doc = theDocument;
150  }
151 
154  {
155  return m_docFrag;
156  }
157 
158  void
160  {
161  m_docFrag = theDocumentFragment;
162  }
163 
166  {
167  return m_currentElem;
168  }
169 
170  void
172  {
173  m_currentElem = theElement;
174  }
175 
176 private:
177 
178  /**
179  * Process any accumulated text and create a node for it.
180  */
181  void
182  processAccumulatedText();
183 
184  /**
185  * Append a node to the current container.
186  */
187  void
188  append(DOMNodeType* newNode);
189 
190  /**
191  * Create the appropriate element, complete with attributes set.
192  *
193  * @param theElementName The name for the new element
194  * @param attrs The SAX AttributeList for the new attributes.
195  * @return A pointer to the new instance.
196  */
198  createElement(
199  const XalanDOMChar* theElementName,
200  AttributeListType& attrs);
201 
202  void
203  addAttributes(
204  DOMElementType* theElement,
205  AttributeListType& attrs);
206 
207 
208  // Data members...
209  DOMDocument_Type* m_doc;
210 
211  DOMDocumentFragmentType* m_docFrag;
212 
213  DOMElementType* m_currentElem;
214 
215  typedef XalanVector<DOMElementType*> ElementStackType;
216 
217  ElementStackType m_elemStack;
218 
219  XalanDOMString m_buffer;
220 
221  XalanDOMString m_textBuffer;
222 
223  static const XalanDOMString s_emptyString;
224 };
225 
226 
227 
228 }
229 
230 
231 
232 #endif // FORMATTERTODOM_HEADER_GUARD_1357924680
xalanc::FormatterToXercesDOM::setCurrentElement
void setCurrentElement(DOMElementType *theElement)
Definition: FormatterToXercesDOM.hpp:171
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::AttributeListType
xercesc::AttributeList AttributeListType
Definition: AttributeListImpl.hpp:41
XalanDOMString.hpp
xalanc::XalanVector< DOMElementType * >
FormatterListener.hpp
XALAN_DEFAULT_MEMMGR
#define XALAN_DEFAULT_MEMMGR
Definition: XalanMemoryManagement.hpp:516
XalanVector.hpp
xalanc::FormatterListener::size_type
XalanSize_t size_type
Definition: FormatterListener.hpp:63
xalanc::FormatterToXercesDOM::getDocument
DOMDocument_Type * getDocument() const
Definition: FormatterToXercesDOM.hpp:141
xalanc::append
XalanDOMString & append(XalanDOMString &theString, const XalanDOMString &theStringToAppend)
Concatenate two strings.
Definition: DOMStringHelper.hpp:2294
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
XercesParserLiaisonDefinitions.hpp
xalanc::DOMNodeType
xercesc::DOMNode DOMNodeType
Definition: XercesWrapperTypes.hpp:68
xalanc::FormatterToXercesDOM::getDocumentFragment
DOMDocumentFragmentType * getDocumentFragment() const
Definition: FormatterToXercesDOM.hpp:153
xalanc::FormatterToXercesDOM
This class takes SAX events (in addition to some extra events that SAX doesn't handle yet) and adds t...
Definition: FormatterToXercesDOM.hpp:53
XALAN_XERCESPARSERLIAISON_EXPORT
#define XALAN_XERCESPARSERLIAISON_EXPORT
Definition: XercesParserLiaisonDefinitions.hpp:39
xalanc::FormatterToXercesDOM::setDocumentFragment
void setDocumentFragment(DOMDocumentFragmentType *theDocumentFragment)
Definition: FormatterToXercesDOM.hpp:159
XercesWrapperTypes.hpp
xalanc::FormatterListener
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:56
xalanc::FormatterToXercesDOM::getCurrentElement
DOMElementType * getCurrentElement() const
Definition: FormatterToXercesDOM.hpp:165
xalanc::FormatterToXercesDOM::setDocument
void setDocument(DOMDocument_Type *theDocument)
Definition: FormatterToXercesDOM.hpp:147
xalanc::DOMElementType
xercesc::DOMElement DOMElementType
Definition: XercesWrapperTypes.hpp:65
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::DOMDocumentFragmentType
xercesc::DOMDocumentFragment DOMDocumentFragmentType
Definition: XercesWrapperTypes.hpp:63
xalanc::DOMDocument_Type
xercesc::DOMDocument DOMDocument_Type
Definition: XercesDOMWrapperParsedSource.hpp:49