Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.6

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  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer. 
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution,
00021  *    if any, must include the following acknowledgment:  
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowledgment may appear in the software itself,
00025  *    if and wherever such third-party acknowledgments normally appear.
00026  *
00027  * 4. The names "Xalan" and "Apache Software Foundation" must
00028  *    not be used to endorse or promote products derived from this
00029  *    software without prior written permission. For written 
00030  *    permission, please contact apache@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache",
00033  *    nor may "Apache" appear in their name, without prior written
00034  *    permission of the Apache Software Foundation.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation and was
00052  * originally based on software copyright (c) 1999, International
00053  * Business Machines, Inc., http://www.ibm.com.  For more
00054  * information on the Apache Software Foundation, please see
00055  * <http://www.apache.org/>.
00056  */
00057 #if !defined(DOMSERVICES_HEADER_GUARD_1357924680)
00058 #define DOMSERVICES_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <xalanc/DOMSupport/DOMSupportDefinitions.hpp>
00064 
00065 
00066 
00067 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00068 #include <xalanc/XalanDOM/XalanAttr.hpp>
00069 #include <xalanc/XalanDOM/XalanComment.hpp>
00070 #include <xalanc/XalanDOM/XalanDocument.hpp>
00071 #include <xalanc/XalanDOM/XalanElement.hpp>
00072 #include <xalanc/XalanDOM/XalanProcessingInstruction.hpp>
00073 #include <xalanc/XalanDOM/XalanText.hpp>
00074 
00075 
00076 
00077 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00078 #include <xalanc/PlatformSupport/FormatterListener.hpp>
00079 
00080 
00081 
00082 XALAN_CPP_NAMESPACE_BEGIN
00083 
00084 
00085 
00086 class XalanDocument;
00087 class XalanDocumentFragment;
00088 
00089 
00090 
00091 class XALAN_DOMSUPPORT_EXPORT DOMServices
00092 {
00093 public:
00094 
00095     static const XalanDOMString&    s_XMLString;
00096     static const XalanDOMString&    s_XMLStringWithSeparator;
00097     static const XalanDOMString&    s_XMLNamespacePrefix;
00098     static const XalanDOMString&    s_XMLNamespaceURI;
00099     static const XalanDOMString&    s_XMLNamespace;
00100     static const XalanDOMString&    s_XMLNamespaceWithSeparator;
00101     static const XalanDOMString&    s_XMLNamespaceSeparatorString;
00102     static const XalanDOMString&    s_XMLNamespacePrefixURI;
00103 
00104     static const XalanDOMString::size_type&     s_XMLStringLength;
00105     static const XalanDOMString::size_type&     s_XMLStringWithSeparatorLength;
00106     static const XalanDOMString::size_type&     s_XMLNamespacePrefixLength;
00107     static const XalanDOMString::size_type&     s_XMLNamespaceURILength;
00108     static const XalanDOMString::size_type&     s_XMLNamespaceLength;
00109     static const XalanDOMString::size_type&     s_XMLNamespaceWithSeparatorLength;
00110     static const XalanDOMString::size_type&     s_XMLNamespaceSeparatorStringLength;
00111     static const XalanDOMString::size_type&     s_XMLNamespacePrefixURILength;
00112 
00113 
00114     // A dummy string to return when we need an emtpy string...
00115     static const XalanDOMString     s_emptyString;
00116 
00117 
00122     static void
00123     initialize();
00124 
00129     static void
00130     terminate();
00131 
00138     static XalanDOMString
00139     getNodeData(const XalanNode&    node);
00140 
00147     static void
00148     getNodeData(
00149             const XalanNode&    node,
00150             XalanDOMString&     data);
00151 
00158     static XalanDOMString
00159     getNodeData(const XalanAttr&    attribute)
00160     {
00161         return attribute.getNodeValue();
00162     }
00163 
00170     static void
00171     getNodeData(
00172             const XalanAttr&    attribute,
00173             XalanDOMString&     data)
00174     {
00175         append(data, attribute.getNodeValue());
00176     }
00177 
00184     static XalanDOMString
00185     getNodeData(const XalanComment&     comment)
00186     {
00187         return comment.getData();
00188     }
00189 
00196     static void
00197     getNodeData(
00198             const XalanComment&     comment,
00199             XalanDOMString&         data)
00200     {
00201         append(data, comment.getData());
00202     }
00203 
00210     static XalanDOMString
00211     getNodeData(const XalanDocument&    document);
00212 
00219     static void
00220     getNodeData(
00221             const XalanDocument&    document,
00222             XalanDOMString&         data);
00223 
00230     static XalanDOMString
00231     getNodeData(const XalanDocumentFragment&    documentFragment);
00232 
00239     static void
00240     getNodeData(
00241             const XalanDocumentFragment&    documentFragment,
00242             XalanDOMString&                 data);
00243 
00250     static XalanDOMString
00251     getNodeData(const XalanElement&     element);
00252 
00259     static void
00260     getNodeData(
00261             const XalanElement&     element,
00262             XalanDOMString&         data);
00263 
00270     static XalanDOMString
00271     getNodeData(const XalanProcessingInstruction&   pi)
00272     {
00273         return pi.getData();
00274     }
00275 
00282     static void
00283     getNodeData(
00284             const XalanProcessingInstruction&   pi,
00285             XalanDOMString&                     data)
00286     {
00287         append(data, pi.getData());
00288     }
00289 
00296     static XalanDOMString
00297     getNodeData(const XalanText&    text)
00298     {
00299         return text.getData();
00300     }
00301 
00308     static void
00309     getNodeData(
00310             const XalanText&    text,
00311             XalanDOMString&     data)
00312     {
00313         append(data, text.getData());
00314     }
00315 
00316     typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
00317 
00325     static void
00326     getNodeData(
00327             const XalanNode&    node,
00328             FormatterListener&  formatterListener,
00329             MemberFunctionPtr   function);
00330 
00338     static void
00339     getNodeData(
00340             const XalanAttr&    attribute,
00341             FormatterListener&  formatterListener,
00342             MemberFunctionPtr   function)
00343     {
00344         sendData(formatterListener, function, attribute.getNodeValue());
00345     }
00346 
00354     static void
00355     getNodeData(
00356             const XalanComment&     comment,
00357             FormatterListener&      formatterListener,
00358             MemberFunctionPtr       function)
00359     {
00360         sendData(formatterListener, function, comment.getData());
00361     }
00362 
00370     static void
00371     getNodeData(
00372             const XalanDocument&    document,
00373             FormatterListener&      formatterListener,
00374             MemberFunctionPtr       function);
00375 
00383     static void
00384     getNodeData(
00385             const XalanDocumentFragment&    documentFragment,
00386             FormatterListener&              formatterListener,
00387             MemberFunctionPtr               function);
00388 
00396     static void
00397     getNodeData(
00398             const XalanElement&     element,
00399             FormatterListener&      formatterListener,
00400             MemberFunctionPtr       function);
00401 
00409     static void
00410     getNodeData(
00411             const XalanProcessingInstruction&   pi,
00412             FormatterListener&                  formatterListener,
00413             MemberFunctionPtr                   function)
00414     {
00415         sendData(formatterListener, function, pi.getData());
00416     }
00417 
00425     static void
00426     getNodeData(
00427             const XalanText&    text,
00428             FormatterListener&  formatterListener,
00429             MemberFunctionPtr   function)
00430     {
00431         sendData(formatterListener, function, text.getData());
00432     }
00433 
00442     static const XalanDOMString&
00443     getNameOfNode(const XalanNode&  n);
00444 
00453     static const XalanDOMString&
00454     getNameOfNode(const XalanAttr&  attr)
00455     {
00456         const XalanDOMString&   theName = attr.getNodeName();
00457 
00458         if (startsWith(theName, s_XMLNamespaceWithSeparator) == true)
00459         {
00460             // Special case for namespace nodes...
00461             return attr.getLocalName();
00462         }
00463         else if (equals(theName, s_XMLNamespace) == true)
00464         {
00465             return s_emptyString;
00466         }
00467         else
00468         {
00469             return theName;
00470         }
00471     }
00472 
00481     static const XalanDOMString&
00482     getNameOfNode(const XalanElement&   element)
00483     {
00484         return element.getNodeName();
00485     }
00486 
00495     static const XalanDOMString&
00496     getLocalNameOfNode(const XalanNode&     n)
00497     {
00498         const XalanDOMString&   theLocalName = n.getLocalName();
00499 
00500         if (length(theLocalName) != 0)
00501         {
00502             return theLocalName;
00503         }
00504         else
00505         {
00506             return n.getNodeName();
00507         }
00508     }
00509 
00518     static const XalanDOMString&
00519     getNamespaceOfNode(const XalanNode& n);
00520 
00528     static bool
00529     isNamespaceDeclaration(const XalanAttr&     n)
00530     {
00531         const XalanDOMString&   theName = n.getNodeName();
00532 
00533         return startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true ||
00534                 equals(theName, DOMServices::s_XMLNamespace) == true;
00535     }
00536 
00544     static XalanNode*
00545     getParentOfNode(const XalanNode&    node)
00546     {
00547         if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE)
00548         {
00549 #if defined(XALAN_OLD_STYLE_CASTS)
00550             return ((const XalanAttr&)node).getOwnerElement();
00551 #else
00552             return static_cast<const XalanAttr&>(node).getOwnerElement();
00553 #endif
00554         }
00555         else
00556         {
00557             return node.getParentNode();
00558         }
00559     }
00560 
00568     static const XalanDOMString*
00569     getNamespaceForPrefix(
00570             const XalanDOMString&   prefix,
00571             const XalanElement&     namespaceContext);
00572 
00583     static const XalanDOMString*
00584     getNamespaceForPrefix(
00585             const XalanDOMChar*     theName,
00586             const PrefixResolver&   thePrefixResolver,
00587             bool                    isAttribute,
00588             XalanDOMString&         thePrefix);
00589 
00597     static bool
00598     isNodeAfter(
00599             const XalanNode&    node1,
00600             const XalanNode&    node2);
00601 
00610     static bool
00611     isNodeAfterSibling(
00612             const XalanNode&    parent,
00613             const XalanNode&    child1,
00614             const XalanNode&    child2);
00615 
00616 private:
00617 
00628     static XalanNode*
00629     findOwnerElement(const XalanAttr&   attr)
00630     {
00631         XalanNode* const    theOwnerElement = attr.getOwnerElement();
00632 
00633         if (theOwnerElement != 0)
00634         {
00635             return theOwnerElement;
00636         }
00637         else
00638         {
00639             return findOwnerElement(attr, *attr.getOwnerDocument()->getDocumentElement());
00640         }
00641     }
00642 
00654     static XalanNode*
00655     findOwnerElement(
00656             const XalanNode&    attr,
00657             XalanNode&          element);
00658 
00666     static void
00667     sendData(
00668             FormatterListener&      formatterListener,
00669             MemberFunctionPtr       function,
00670             const XalanDOMString&   data)
00671     {
00672         assert(length(data) == FormatterListener::size_type(length(data)));
00673 
00674         (formatterListener.*function)(c_wstr(data), FormatterListener::size_type(length(data)));
00675     }
00676 };
00677 
00678 
00679 
00680 XALAN_CPP_NAMESPACE_END
00681 
00682 
00683 
00684 #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.6
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.