Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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(MemoryManagerType&      theManager);
00083 
00088     static void
00089     terminate();
00090 
00091 
00092 
00099     static void
00100     getNodeData(
00101             const XalanNode&    node,
00102             XalanDOMString&     data);
00103 
00104 
00105 
00112     static void
00113     getNodeData(
00114             const XalanAttr&    attribute,
00115             XalanDOMString&     data)
00116     {
00117         append(data, attribute.getNodeValue());
00118     }
00119 
00120 
00121 
00128     static void
00129     getNodeData(
00130             const XalanComment&     comment,
00131             XalanDOMString&         data)
00132     {
00133         append(data, comment.getData());
00134     }
00135 
00136 
00137 
00144     static void
00145     getNodeData(
00146             const XalanDocument&    document,
00147             XalanDOMString&         data);
00148 
00149 
00150 
00157     static void
00158     getNodeData(
00159             const XalanDocumentFragment&    documentFragment,
00160             XalanDOMString&                 data);
00161 
00162 
00163 
00170     static void
00171     getNodeData(
00172             const XalanElement&     element,
00173             XalanDOMString&         data);
00174 
00175 
00182     static void
00183     getNodeData(
00184             const XalanProcessingInstruction&   pi,
00185             XalanDOMString&                     data)
00186     {
00187         append(data, pi.getData());
00188     }
00189 
00190 
00191 
00198     static void
00199     getNodeData(
00200             const XalanText&    text,
00201             XalanDOMString&     data)
00202     {
00203         append(data, text.getData());
00204     }
00205 
00206     typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
00207 
00215     static void
00216     getNodeData(
00217             const XalanNode&    node,
00218             FormatterListener&  formatterListener,
00219             MemberFunctionPtr   function);
00220 
00228     static void
00229     getNodeData(
00230             const XalanAttr&    attribute,
00231             FormatterListener&  formatterListener,
00232             MemberFunctionPtr   function)
00233     {
00234         sendData(formatterListener, function, attribute.getNodeValue());
00235     }
00236 
00244     static void
00245     getNodeData(
00246             const XalanComment&     comment,
00247             FormatterListener&      formatterListener,
00248             MemberFunctionPtr       function)
00249     {
00250         sendData(formatterListener, function, comment.getData());
00251     }
00252 
00260     static void
00261     getNodeData(
00262             const XalanDocument&    document,
00263             FormatterListener&      formatterListener,
00264             MemberFunctionPtr       function);
00265 
00273     static void
00274     getNodeData(
00275             const XalanDocumentFragment&    documentFragment,
00276             FormatterListener&              formatterListener,
00277             MemberFunctionPtr               function);
00278 
00286     static void
00287     getNodeData(
00288             const XalanElement&     element,
00289             FormatterListener&      formatterListener,
00290             MemberFunctionPtr       function);
00291 
00299     static void
00300     getNodeData(
00301             const XalanProcessingInstruction&   pi,
00302             FormatterListener&                  formatterListener,
00303             MemberFunctionPtr                   function)
00304     {
00305         sendData(formatterListener, function, pi.getData());
00306     }
00307 
00315     static void
00316     getNodeData(
00317             const XalanText&    text,
00318             FormatterListener&  formatterListener,
00319             MemberFunctionPtr   function)
00320     {
00321         sendData(formatterListener, function, text.getData());
00322     }
00323 
00332     static const XalanDOMString&
00333     getNameOfNode(const XalanNode&  n);
00334 
00343     static const XalanDOMString&
00344     getNameOfNode(const XalanAttr&  attr)
00345     {
00346         const XalanDOMString&   theName = attr.getNodeName();
00347 
00348         if (startsWith(theName, s_XMLNamespaceWithSeparator) == true)
00349         {
00350             // Special case for namespace nodes...
00351             return attr.getLocalName();
00352         }
00353         else if (equals(theName, s_XMLNamespace) == true)
00354         {
00355             return s_emptyString;
00356         }
00357         else
00358         {
00359             return theName;
00360         }
00361     }
00362 
00371     static const XalanDOMString&
00372     getNameOfNode(const XalanElement&   element)
00373     {
00374         return element.getNodeName();
00375     }
00376 
00385     static const XalanDOMString&
00386     getLocalNameOfNode(const XalanNode&     n)
00387     {
00388         const XalanDOMString&   theLocalName = n.getLocalName();
00389 
00390         if (length(theLocalName) != 0)
00391         {
00392             return theLocalName;
00393         }
00394         else
00395         {
00396             return n.getNodeName();
00397         }
00398     }
00399 
00408     static const XalanDOMString&
00409     getNamespaceOfNode(const XalanNode& n);
00410 
00418     static bool
00419     isNamespaceDeclaration(const XalanAttr&     n)
00420     {
00421         const XalanDOMString&   theName = n.getNodeName();
00422 
00423         return startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true ||
00424                 equals(theName, DOMServices::s_XMLNamespace) == true;
00425     }
00426 
00434     static XalanNode*
00435     getParentOfNode(const XalanNode&    node)
00436     {
00437         if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE)
00438         {
00439 #if defined(XALAN_OLD_STYLE_CASTS)
00440             return ((const XalanAttr&)node).getOwnerElement();
00441 #else
00442             return static_cast<const XalanAttr&>(node).getOwnerElement();
00443 #endif
00444         }
00445         else
00446         {
00447             return node.getParentNode();
00448         }
00449     }
00450 
00458     static const XalanDOMString*
00459     getNamespaceForPrefix(
00460             const XalanDOMString&   prefix,
00461             const XalanElement&     namespaceContext);
00462 
00473     static const XalanDOMString*
00474     getNamespaceForPrefix(
00475             const XalanDOMChar*     theName,
00476             const PrefixResolver&   thePrefixResolver,
00477             bool                    isAttribute,
00478             XalanDOMString&         thePrefix);
00479 
00487     static bool
00488     isNodeAfter(
00489             const XalanNode&    node1,
00490             const XalanNode&    node2);
00491 
00500     static bool
00501     isNodeAfterSibling(
00502             const XalanNode&    parent,
00503             const XalanNode&    child1,
00504             const XalanNode&    child2);
00505 
00506 private:
00507 
00518     static XalanNode*
00519     findOwnerElement(const XalanAttr&   attr)
00520     {
00521         XalanNode* const    theOwnerElement = attr.getOwnerElement();
00522 
00523         if (theOwnerElement != 0)
00524         {
00525             return theOwnerElement;
00526         }
00527         else
00528         {
00529             return findOwnerElement(attr, *attr.getOwnerDocument()->getDocumentElement());
00530         }
00531     }
00532 
00544     static XalanNode*
00545     findOwnerElement(
00546             const XalanNode&    attr,
00547             XalanNode&          element);
00548 
00556     static void
00557     sendData(
00558             FormatterListener&      formatterListener,
00559             MemberFunctionPtr       function,
00560             const XalanDOMString&   data)
00561     {
00562         const XalanDOMString::size_type     theLength =
00563             data.length();
00564 
00565         if (theLength != 0)
00566         {
00567             assert(theLength == FormatterListener::size_type(theLength));
00568 
00569             (formatterListener.*function)(
00570                 data.c_str(),
00571                 FormatterListener::size_type(theLength));
00572         }
00573     }
00574 };
00575 
00576 
00577 
00578 XALAN_CPP_NAMESPACE_END
00579 
00580 
00581 
00582 #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