Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

DOMServices.hpp

Go to the documentation of this file.
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(DOMSERVICES_HEADER_GUARD_1357924680)
00017 #define DOMSERVICES_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/DOMSupport/DOMSupportDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00027 #include <xalanc/XalanDOM/XalanAttr.hpp>
00028 #include <xalanc/XalanDOM/XalanComment.hpp>
00029 #include <xalanc/XalanDOM/XalanDocument.hpp>
00030 #include <xalanc/XalanDOM/XalanElement.hpp>
00031 #include <xalanc/XalanDOM/XalanProcessingInstruction.hpp>
00032 #include <xalanc/XalanDOM/XalanText.hpp>
00033 
00034 
00035 
00036 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00037 #include <xalanc/PlatformSupport/FormatterListener.hpp>
00038 
00039 
00040 
00041 XALAN_CPP_NAMESPACE_BEGIN
00042 
00043 
00044 
00045 class XalanDocument;
00046 class XalanDocumentFragment;
00047 
00048 
00049 
00050 class XALAN_DOMSUPPORT_EXPORT DOMServices
00051 {
00052 public:
00053 
00054     static const XalanDOMString&    s_XMLString;
00055     static const XalanDOMString&    s_XMLStringWithSeparator;
00056     static const XalanDOMString&    s_XMLNamespacePrefix;
00057     static const XalanDOMString&    s_XMLNamespaceURI;
00058     static const XalanDOMString&    s_XMLNamespace;
00059     static const XalanDOMString&    s_XMLNamespaceWithSeparator;
00060     static const XalanDOMString&    s_XMLNamespaceSeparatorString;
00061     static const XalanDOMString&    s_XMLNamespacePrefixURI;
00062 
00063     static const XalanDOMString::size_type&     s_XMLStringLength;
00064     static const XalanDOMString::size_type&     s_XMLStringWithSeparatorLength;
00065     static const XalanDOMString::size_type&     s_XMLNamespacePrefixLength;
00066     static const XalanDOMString::size_type&     s_XMLNamespaceURILength;
00067     static const XalanDOMString::size_type&     s_XMLNamespaceLength;
00068     static const XalanDOMString::size_type&     s_XMLNamespaceWithSeparatorLength;
00069     static const XalanDOMString::size_type&     s_XMLNamespaceSeparatorStringLength;
00070     static const XalanDOMString::size_type&     s_XMLNamespacePrefixURILength;
00071 
00072 
00073     // A dummy string to return when we need an emtpy string...
00074     static const XalanDOMString     s_emptyString;
00075 
00076 
00081     static void
00082     initialize();
00083 
00088     static void
00089     terminate();
00090 
00097     static XalanDOMString
00098     getNodeData(const XalanNode&    node);
00099 
00106     static void
00107     getNodeData(
00108             const XalanNode&    node,
00109             XalanDOMString&     data);
00110 
00117     static XalanDOMString
00118     getNodeData(const XalanAttr&    attribute)
00119     {
00120         return attribute.getNodeValue();
00121     }
00122 
00129     static void
00130     getNodeData(
00131             const XalanAttr&    attribute,
00132             XalanDOMString&     data)
00133     {
00134         append(data, attribute.getNodeValue());
00135     }
00136 
00143     static XalanDOMString
00144     getNodeData(const XalanComment&     comment)
00145     {
00146         return comment.getData();
00147     }
00148 
00155     static void
00156     getNodeData(
00157             const XalanComment&     comment,
00158             XalanDOMString&         data)
00159     {
00160         append(data, comment.getData());
00161     }
00162 
00169     static XalanDOMString
00170     getNodeData(const XalanDocument&    document);
00171 
00178     static void
00179     getNodeData(
00180             const XalanDocument&    document,
00181             XalanDOMString&         data);
00182 
00189     static XalanDOMString
00190     getNodeData(const XalanDocumentFragment&    documentFragment);
00191 
00198     static void
00199     getNodeData(
00200             const XalanDocumentFragment&    documentFragment,
00201             XalanDOMString&                 data);
00202 
00209     static XalanDOMString
00210     getNodeData(const XalanElement&     element);
00211 
00218     static void
00219     getNodeData(
00220             const XalanElement&     element,
00221             XalanDOMString&         data);
00222 
00229     static XalanDOMString
00230     getNodeData(const XalanProcessingInstruction&   pi)
00231     {
00232         return pi.getData();
00233     }
00234 
00241     static void
00242     getNodeData(
00243             const XalanProcessingInstruction&   pi,
00244             XalanDOMString&                     data)
00245     {
00246         append(data, pi.getData());
00247     }
00248 
00255     static XalanDOMString
00256     getNodeData(const XalanText&    text)
00257     {
00258         return text.getData();
00259     }
00260 
00267     static void
00268     getNodeData(
00269             const XalanText&    text,
00270             XalanDOMString&     data)
00271     {
00272         append(data, text.getData());
00273     }
00274 
00275     typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
00276 
00284     static void
00285     getNodeData(
00286             const XalanNode&    node,
00287             FormatterListener&  formatterListener,
00288             MemberFunctionPtr   function);
00289 
00297     static void
00298     getNodeData(
00299             const XalanAttr&    attribute,
00300             FormatterListener&  formatterListener,
00301             MemberFunctionPtr   function)
00302     {
00303         sendData(formatterListener, function, attribute.getNodeValue());
00304     }
00305 
00313     static void
00314     getNodeData(
00315             const XalanComment&     comment,
00316             FormatterListener&      formatterListener,
00317             MemberFunctionPtr       function)
00318     {
00319         sendData(formatterListener, function, comment.getData());
00320     }
00321 
00329     static void
00330     getNodeData(
00331             const XalanDocument&    document,
00332             FormatterListener&      formatterListener,
00333             MemberFunctionPtr       function);
00334 
00342     static void
00343     getNodeData(
00344             const XalanDocumentFragment&    documentFragment,
00345             FormatterListener&              formatterListener,
00346             MemberFunctionPtr               function);
00347 
00355     static void
00356     getNodeData(
00357             const XalanElement&     element,
00358             FormatterListener&      formatterListener,
00359             MemberFunctionPtr       function);
00360 
00368     static void
00369     getNodeData(
00370             const XalanProcessingInstruction&   pi,
00371             FormatterListener&                  formatterListener,
00372             MemberFunctionPtr                   function)
00373     {
00374         sendData(formatterListener, function, pi.getData());
00375     }
00376 
00384     static void
00385     getNodeData(
00386             const XalanText&    text,
00387             FormatterListener&  formatterListener,
00388             MemberFunctionPtr   function)
00389     {
00390         sendData(formatterListener, function, text.getData());
00391     }
00392 
00401     static const XalanDOMString&
00402     getNameOfNode(const XalanNode&  n);
00403 
00412     static const XalanDOMString&
00413     getNameOfNode(const XalanAttr&  attr)
00414     {
00415         const XalanDOMString&   theName = attr.getNodeName();
00416 
00417         if (startsWith(theName, s_XMLNamespaceWithSeparator) == true)
00418         {
00419             // Special case for namespace nodes...
00420             return attr.getLocalName();
00421         }
00422         else if (equals(theName, s_XMLNamespace) == true)
00423         {
00424             return s_emptyString;
00425         }
00426         else
00427         {
00428             return theName;
00429         }
00430     }
00431 
00440     static const XalanDOMString&
00441     getNameOfNode(const XalanElement&   element)
00442     {
00443         return element.getNodeName();
00444     }
00445 
00454     static const XalanDOMString&
00455     getLocalNameOfNode(const XalanNode&     n)
00456     {
00457         const XalanDOMString&   theLocalName = n.getLocalName();
00458 
00459         if (length(theLocalName) != 0)
00460         {
00461             return theLocalName;
00462         }
00463         else
00464         {
00465             return n.getNodeName();
00466         }
00467     }
00468 
00477     static const XalanDOMString&
00478     getNamespaceOfNode(const XalanNode& n);
00479 
00487     static bool
00488     isNamespaceDeclaration(const XalanAttr&     n)
00489     {
00490         const XalanDOMString&   theName = n.getNodeName();
00491 
00492         return startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true ||
00493                 equals(theName, DOMServices::s_XMLNamespace) == true;
00494     }
00495 
00503     static XalanNode*
00504     getParentOfNode(const XalanNode&    node)
00505     {
00506         if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE)
00507         {
00508 #if defined(XALAN_OLD_STYLE_CASTS)
00509             return ((const XalanAttr&)node).getOwnerElement();
00510 #else
00511             return static_cast<const XalanAttr&>(node).getOwnerElement();
00512 #endif
00513         }
00514         else
00515         {
00516             return node.getParentNode();
00517         }
00518     }
00519 
00527     static const XalanDOMString*
00528     getNamespaceForPrefix(
00529             const XalanDOMString&   prefix,
00530             const XalanElement&     namespaceContext);
00531 
00542     static const XalanDOMString*
00543     getNamespaceForPrefix(
00544             const XalanDOMChar*     theName,
00545             const PrefixResolver&   thePrefixResolver,
00546             bool                    isAttribute,
00547             XalanDOMString&         thePrefix);
00548 
00556     static bool
00557     isNodeAfter(
00558             const XalanNode&    node1,
00559             const XalanNode&    node2);
00560 
00569     static bool
00570     isNodeAfterSibling(
00571             const XalanNode&    parent,
00572             const XalanNode&    child1,
00573             const XalanNode&    child2);
00574 
00575 private:
00576 
00587     static XalanNode*
00588     findOwnerElement(const XalanAttr&   attr)
00589     {
00590         XalanNode* const    theOwnerElement = attr.getOwnerElement();
00591 
00592         if (theOwnerElement != 0)
00593         {
00594             return theOwnerElement;
00595         }
00596         else
00597         {
00598             return findOwnerElement(attr, *attr.getOwnerDocument()->getDocumentElement());
00599         }
00600     }
00601 
00613     static XalanNode*
00614     findOwnerElement(
00615             const XalanNode&    attr,
00616             XalanNode&          element);
00617 
00625     static void
00626     sendData(
00627             FormatterListener&      formatterListener,
00628             MemberFunctionPtr       function,
00629             const XalanDOMString&   data)
00630     {
00631         assert(length(data) == FormatterListener::size_type(length(data)));
00632 
00633         (formatterListener.*function)(c_wstr(data), FormatterListener::size_type(length(data)));
00634     }
00635 };
00636 
00637 
00638 
00639 XALAN_CPP_NAMESPACE_END
00640 
00641 
00642 
00643 #endif  // DOMSERVICES_HEADER_GUARD_1357924680

Interpreting class diagrams

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

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