Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

DOMServices.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(DOMSERVICES_HEADER_GUARD_1357924680)
17 #define DOMSERVICES_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
33 
34 
35 
38 
39 
40 
41 XALAN_CPP_NAMESPACE_BEGIN
42 
43 
44 
45 class XalanDocument;
47 
48 
49 
51 {
52 public:
53 
54  static const XalanDOMString& s_XMLString;
62 
71 
72 
73  // A dummy string to return when we need an emtpy string...
75 
76 
81  static void
82  initialize(MemoryManagerType& theManager);
83 
88  static void
89  terminate();
90 
91 
92 
99  static void
100  getNodeData(
101  const XalanNode& node,
102  XalanDOMString& data);
103 
104 
105 
112  static void
113  getNodeData(
114  const XalanAttr& attribute,
115  XalanDOMString& data)
116  {
117  append(data, attribute.getNodeValue());
118  }
119 
120 
121 
128  static void
129  getNodeData(
130  const XalanComment& comment,
131  XalanDOMString& data)
132  {
133  append(data, comment.getData());
134  }
135 
136 
137 
144  static void
145  getNodeData(
146  const XalanDocument& document,
147  XalanDOMString& data);
148 
149 
150 
157  static void
158  getNodeData(
159  const XalanDocumentFragment& documentFragment,
160  XalanDOMString& data);
161 
162 
163 
170  static void
171  getNodeData(
172  const XalanElement& element,
173  XalanDOMString& data);
174 
175 
182  static void
183  getNodeData(
184  const XalanProcessingInstruction& pi,
185  XalanDOMString& data)
186  {
187  append(data, pi.getData());
188  }
189 
190 
191 
198  static void
199  getNodeData(
200  const XalanText& text,
201  XalanDOMString& data)
202  {
203  append(data, text.getData());
204  }
205 
206  typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
207 
215  static void
216  getNodeData(
217  const XalanNode& node,
218  FormatterListener& formatterListener,
219  MemberFunctionPtr function);
220 
228  static void
229  getNodeData(
230  const XalanAttr& attribute,
231  FormatterListener& formatterListener,
232  MemberFunctionPtr function)
233  {
234  sendData(formatterListener, function, attribute.getNodeValue());
235  }
236 
244  static void
245  getNodeData(
246  const XalanComment& comment,
247  FormatterListener& formatterListener,
248  MemberFunctionPtr function)
249  {
250  sendData(formatterListener, function, comment.getData());
251  }
252 
260  static void
261  getNodeData(
262  const XalanDocument& document,
263  FormatterListener& formatterListener,
264  MemberFunctionPtr function);
265 
273  static void
274  getNodeData(
275  const XalanDocumentFragment& documentFragment,
276  FormatterListener& formatterListener,
277  MemberFunctionPtr function);
278 
286  static void
287  getNodeData(
288  const XalanElement& element,
289  FormatterListener& formatterListener,
290  MemberFunctionPtr function);
291 
299  static void
300  getNodeData(
301  const XalanProcessingInstruction& pi,
302  FormatterListener& formatterListener,
303  MemberFunctionPtr function)
304  {
305  sendData(formatterListener, function, pi.getData());
306  }
307 
315  static void
316  getNodeData(
317  const XalanText& text,
318  FormatterListener& formatterListener,
319  MemberFunctionPtr function)
320  {
321  sendData(formatterListener, function, text.getData());
322  }
323 
332  static const XalanDOMString&
333  getNameOfNode(const XalanNode& n);
334 
343  static const XalanDOMString&
344  getNameOfNode(const XalanAttr& attr)
345  {
346  const XalanDOMString& theName = attr.getNodeName();
347 
348  if (startsWith(theName, s_XMLNamespaceWithSeparator) == true)
349  {
350  // Special case for namespace nodes...
351  return attr.getLocalName();
352  }
353  else if (equals(theName, s_XMLNamespace) == true)
354  {
355  return s_emptyString;
356  }
357  else
358  {
359  return theName;
360  }
361  }
362 
371  static const XalanDOMString&
372  getNameOfNode(const XalanElement& element)
373  {
374  return element.getNodeName();
375  }
376 
385  static const XalanDOMString&
386  getLocalNameOfNode(const XalanNode& n)
387  {
388  const XalanDOMString& theLocalName = n.getLocalName();
389 
390  if (length(theLocalName) != 0)
391  {
392  return theLocalName;
393  }
394  else
395  {
396  return n.getNodeName();
397  }
398  }
399 
408  static const XalanDOMString&
409  getNamespaceOfNode(const XalanNode& n);
410 
418  static bool
419  isNamespaceDeclaration(const XalanAttr& n)
420  {
421  const XalanDOMString& theName = n.getNodeName();
422 
423  return startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true ||
424  equals(theName, DOMServices::s_XMLNamespace) == true;
425  }
426 
434  static XalanNode*
435  getParentOfNode(const XalanNode& node)
436  {
438  {
439 #if defined(XALAN_OLD_STYLE_CASTS)
440  return ((const XalanAttr&)node).getOwnerElement();
441 #else
442  return static_cast<const XalanAttr&>(node).getOwnerElement();
443 #endif
444  }
445  else
446  {
447  return node.getParentNode();
448  }
449  }
450 
458  static const XalanDOMString*
459  getNamespaceForPrefix(
460  const XalanDOMString& prefix,
461  const XalanElement& namespaceContext);
462 
473  static const XalanDOMString*
474  getNamespaceForPrefix(
475  const XalanDOMChar* theName,
476  const PrefixResolver& thePrefixResolver,
477  bool isAttribute,
478  XalanDOMString& thePrefix);
479 
487  static bool
488  isNodeAfter(
489  const XalanNode& node1,
490  const XalanNode& node2);
491 
500  static bool
501  isNodeAfterSibling(
502  const XalanNode& parent,
503  const XalanNode& child1,
504  const XalanNode& child2);
505 
506 private:
507 
518  static XalanNode*
519  findOwnerElement(const XalanAttr& attr)
520  {
521  XalanNode* const theOwnerElement = attr.getOwnerElement();
522 
523  if (theOwnerElement != 0)
524  {
525  return theOwnerElement;
526  }
527  else
528  {
529  return findOwnerElement(attr, *attr.getOwnerDocument()->getDocumentElement());
530  }
531  }
532 
544  static XalanNode*
545  findOwnerElement(
546  const XalanNode& attr,
547  XalanNode& element);
548 
556  static void
557  sendData(
558  FormatterListener& formatterListener,
559  MemberFunctionPtr function,
560  const XalanDOMString& data)
561  {
562  const XalanDOMString::size_type theLength =
563  data.length();
564 
565  if (theLength != 0)
566  {
567  assert(theLength == FormatterListener::size_type(theLength));
568 
569  (formatterListener.*function)(
570  data.c_str(),
571  FormatterListener::size_type(theLength));
572  }
573  }
574 };
575 
576 
577 
578 XALAN_CPP_NAMESPACE_END
579 
580 
581 
582 #endif // DOMSERVICES_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo