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
114  const XalanAttr& attribute,
115  XalanDOMString& data)
116  {
117  append(data, attribute.getNodeValue());
118  }
119 
120 
121 
128  static void
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
184  const XalanProcessingInstruction& pi,
185  XalanDOMString& data)
186  {
187  append(data, pi.getData());
188  }
189 
190 
191 
198  static void
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
230  const XalanAttr& attribute,
231  FormatterListener& formatterListener,
232  MemberFunctionPtr function)
233  {
234  sendData(formatterListener, function, attribute.getNodeValue());
235  }
236 
244  static void
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
301  const XalanProcessingInstruction& pi,
302  FormatterListener& formatterListener,
303  MemberFunctionPtr function)
304  {
305  sendData(formatterListener, function, pi.getData());
306  }
307 
315  static void
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&
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&
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
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*
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
static const XalanDOMString::size_type & s_XMLNamespacePrefixLength
Definition: DOMServices.hpp:65
virtual XalanElement * getDocumentElement() const =0
Return a reference to the root element of the document.
static void getNodeData(const XalanProcessingInstruction &pi, XalanDOMString &data)
Retrieves data for node.
Definition: DOMServices.hpp:183
Definition: XalanNode.hpp:44
size_type length() const
Definition: XalanDOMString.hpp:209
Definition: XalanText.hpp:38
startsWith(const XalanDOMChar *theString, XalanDOMString::size_type theStringLength, const XalanDOMChar *theSubstring, XalanDOMString::size_type theSubstringLength)
Simulates the java String method startsWith().
static void getNodeData(const XalanAttr &attribute, XalanDOMString &data)
Retrieves data for node.
Definition: DOMServices.hpp:113
static XalanNode * getParentOfNode(const XalanNode &node)
Retrieve the parent of a node.
Definition: DOMServices.hpp:435
virtual const XalanDOMString & getData() const =0
The content of this processing instruction.
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
Definition: XalanAttr.hpp:38
static const XalanDOMString::size_type & s_XMLNamespaceSeparatorStringLength
Definition: DOMServices.hpp:69
static const XalanDOMString::size_type & s_XMLNamespaceURILength
Definition: DOMServices.hpp:66
virtual const XalanDOMString & getLocalName() const =0
Returns the local part of the qualified name of this node.
Definition: XalanDocumentFragment.hpp:38
Definition: XalanComment.hpp:38
static const XalanDOMString & s_XMLNamespaceWithSeparator
Definition: DOMServices.hpp:59
static void getNodeData(const XalanComment &comment, XalanDOMString &data)
Retrieves data for node.
Definition: DOMServices.hpp:129
Definition: DOMServices.hpp:50
Definition: XalanElement.hpp:42
virtual const XalanDOMString & getNodeValue() const =0
Gets the value of this node, depending on its type.
static const XalanDOMString & getLocalNameOfNode(const XalanNode &n)
Retrieve local name of node, taking into account the differences between the DOM and XSLT data models...
Definition: DOMServices.hpp:386
Definition: XalanNode.hpp:57
virtual XalanElement * getOwnerElement() const =0
The Element node this attribute is attached to or null if this attribute is not in use...
static const XalanDOMString & s_XMLNamespacePrefixURI
Definition: DOMServices.hpp:61
XalanDOMString & append(XalanDOMString &theString, const XalanDOMString &theStringToAppend)
Concatenate two strings.
Definition: DOMStringHelper.hpp:2127
static const XalanDOMString & s_XMLString
Definition: DOMServices.hpp:54
static const XalanDOMString::size_type & s_XMLStringWithSeparatorLength
Definition: DOMServices.hpp:64
virtual XalanNode * getParentNode() const =0
Gets the parent of this node.
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:62
#define XALAN_DOMSUPPORT_EXPORT
Definition: DOMSupportDefinitions.hpp:33
static void getNodeData(const XalanAttr &attribute, FormatterListener &formatterListener, MemberFunctionPtr function)
Sends the data for a node to a FormatterListener.
Definition: DOMServices.hpp:229
static const XalanDOMString & getNameOfNode(const XalanElement &element)
Retrieve the name of the node, taking into account the differences between the DOM and XSLT data mode...
Definition: DOMServices.hpp:372
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
unsigned int size_type
Definition: FormatterListener.hpp:69
static void getNodeData(const XalanComment &comment, FormatterListener &formatterListener, MemberFunctionPtr function)
Sends the data for a node to a FormatterListener.
Definition: DOMServices.hpp:245
static const XalanDOMString::size_type & s_XMLNamespacePrefixURILength
Definition: DOMServices.hpp:70
static const XalanDOMString & s_XMLStringWithSeparator
Definition: DOMServices.hpp:55
Definition: XalanProcessingInstruction.hpp:38
const XalanDOMChar * c_str() const
Definition: XalanDOMString.hpp:314
static const XalanDOMString & getNameOfNode(const XalanAttr &attr)
Retrieve the name of the node, taking into account the differences between the DOM and XSLT data mode...
Definition: DOMServices.hpp:344
static const XalanDOMString::size_type & s_XMLStringLength
Definition: DOMServices.hpp:63
This class defines an interface for classes that resolve namespace prefixes to their URIs...
Definition: PrefixResolver.hpp:37
static const XalanDOMString & s_XMLNamespaceSeparatorString
Definition: DOMServices.hpp:60
Definition: XalanDocument.hpp:51
static const XalanDOMString & s_XMLNamespaceURI
Definition: DOMServices.hpp:57
static const XalanDOMString s_emptyString
Definition: DOMServices.hpp:74
virtual const XalanDOMString & getNodeName() const =0
virtual const XalanDOMString & getNodeName() const =0
virtual const XalanDOMString & getData() const =0
Returns the character data of the node that implements this interface.
Definition: XalanDOMString.hpp:42
static const XalanDOMString::size_type & s_XMLNamespaceWithSeparatorLength
Definition: DOMServices.hpp:68
virtual const XalanDOMString & getData() const =0
Returns the character data of the node that implements this interface.
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:277
static bool isNamespaceDeclaration(const XalanAttr &n)
Determine whether or not an attribute node is declaring a namespace.
Definition: DOMServices.hpp:419
static void getNodeData(const XalanText &text, XalanDOMString &data)
Retrieves data for node.
Definition: DOMServices.hpp:199
static void getNodeData(const XalanText &text, FormatterListener &formatterListener, MemberFunctionPtr function)
Sends the data for a node to a FormatterListener.
Definition: DOMServices.hpp:316
virtual const XalanDOMString & getLocalName() const =0
Returns the local part of the qualified name of this node.
unsigned int size_type
Definition: XalanDOMString.hpp:53
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.
virtual XalanDocument * getOwnerDocument() const =0
Gets the Document object associated with this node.
static void getNodeData(const XalanProcessingInstruction &pi, FormatterListener &formatterListener, MemberFunctionPtr function)
Sends the data for a node to a FormatterListener.
Definition: DOMServices.hpp:300
static const XalanDOMString::size_type & s_XMLNamespaceLength
Definition: DOMServices.hpp:67
static const XalanDOMString & s_XMLNamespace
Definition: DOMServices.hpp:58
static const XalanDOMString & s_XMLNamespacePrefix
Definition: DOMServices.hpp:56
virtual const XalanDOMString & getNodeName() const =0

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