dbertoni    01/01/08 10:12:24

  Modified:    c/src/DOMSupport DOMServices.cpp DOMServices.hpp
                        DOMSupport.hpp DOMSupportDefault.cpp
                        DOMSupportDefault.hpp
  Log:
  Made some functions inline.  Added new functions to DOMSupport.
  
  Revision  Changes    Path
  1.22      +55 -0     xml-xalan/c/src/DOMSupport/DOMServices.cpp
  
  Index: DOMServices.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMServices.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DOMServices.cpp   2001/01/03 19:27:05     1.21
  +++ DOMServices.cpp   2001/01/08 18:12:24     1.22
  @@ -788,3 +788,58 @@
   
        return isNodeAfterSibling;
   }
  +
  +
  +
  +XalanNode*
  +DOMServices::findOwnerElement(
  +                     const XalanNode&        attr,
  +                     XalanNode&                      element)
  +{
  +
  +    XalanNode*       parent = 0;
  +
  +     const XalanNamedNodeMap* const  attrs = element.getAttributes();
  +
  +     if(attrs != 0)
  +     {
  +             const unsigned int      nAttrs = attrs->getLength();
  +
  +             for(unsigned int i = 0; i < nAttrs; i++)
  +             {
  +                     if(attrs->item(i) == &attr)
  +                     {
  +                             parent = &element;
  +                                     
  +                             break;
  +                     }
  +             }
  +     }
  +
  +     if(parent == 0)
  +    {
  +             bool            fFound = false;
  +
  +             XalanNode*      child = element.getFirstChild();
  +
  +             while(child != 0 && fFound == false)
  +             {
  +                     if(child->getNodeType() == XalanNode::ELEMENT_NODE)
  +                     {
  +                             parent = findOwnerElement(attr, *child);
  +
  +                             if(parent != 0)
  +                             {
  +                                     fFound = true;
  +                             }
  +                     }
  +
  +                     if (fFound == false)
  +                     {
  +                             child = child->getNextSibling();
  +                     }
  +             }
  +    }
  +
  +     return parent;
  +}
  
  
  
  1.17      +46 -5     xml-xalan/c/src/DOMSupport/DOMServices.hpp
  
  Index: DOMServices.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMServices.hpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DOMServices.hpp   2001/01/03 19:27:06     1.16
  +++ DOMServices.hpp   2001/01/08 18:12:24     1.17
  @@ -67,6 +67,7 @@
   #include <XalanDOM/XalanDOMString.hpp>
   #include <XalanDOM/XalanAttr.hpp>
   #include <XalanDOM/XalanComment.hpp>
  +#include <XalanDOM/XalanDocument.hpp>
   #include <XalanDOM/XalanElement.hpp>
   #include <XalanDOM/XalanProcessingInstruction.hpp>
   #include <XalanDOM/XalanText.hpp>
  @@ -389,11 +390,11 @@
        {
                if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE)
                {
  -     #if defined(XALAN_OLD_STYLE_CASTS)
  -                     return ((const XalanAttr&)node).getOwnerElement();
  -     #else
  -                     return static_cast<const 
XalanAttr&>(node).getOwnerElement();
  -     #endif
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return findOwnerElement((const XalanAttr&)node);
  +#else
  +                     return findOwnerElement(static_cast<const 
XalanAttr&>(node));
  +#endif
                }
                else
                {
  @@ -438,6 +439,46 @@
                        const XalanNode&        parent,
                        const XalanNode&        child1,
                        const XalanNode&        child2);
  +
  +private:
  +
  +     /**
  +      * If necessary, do a brute-force search for an owner element.  This is
  +      * necessary when a given DOM implementation returns 0 for
  +      * XalanAttr::getOwnerElement()
  +      *
  +      * @param attr The XalanAttr instance for which to find the owner 
element
  +      * @return A pointer to the element node that owns the attribute
  +      */
  +     static XalanNode*
  +     findOwnerElement(const XalanAttr&       attr)
  +     {
  +             XalanNode* const        theOwnerElement = 
attr.getOwnerElement();
  +
  +             if (theOwnerElement != 0)
  +             {
  +                     return theOwnerElement;
  +             }
  +             else
  +             {
  +                     return findOwnerElement(attr, 
*attr.getOwnerDocument()->getDocumentElement());
  +             }
  +     }
  +
  +     /**
  +      * If necessary, do a brute-force search for an owner element.  This is
  +      * necessary when a given DOM implementation returns 0 for
  +      * XalanAttr::getOwnerElement()
  +      *
  +      * @param attr The XalanAttr instance for which to find the owner 
element
  +      * @param element The document element
  +      * @return A pointer to the element node that owns the attribute
  +      */
  +     static XalanNode*
  +     findOwnerElement(
  +                     const XalanNode&        attr,
  +                     XalanNode&                      element);
  +
   };
   
   
  
  
  
  1.7       +18 -4     xml-xalan/c/src/DOMSupport/DOMSupport.hpp
  
  Index: DOMSupport.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMSupport.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DOMSupport.hpp    2000/12/30 17:55:33     1.6
  +++ DOMSupport.hpp    2001/01/08 18:12:24     1.7
  @@ -97,13 +97,15 @@
        // These interfaces are new to DOMSupport...
   
        /**
  -      * Retrieve namespace corresponding to a DOM node
  +      * Retrieve the URI corresponding to a namespace prefix
         * 
  -      * @param theNode DOM node whose namespace is queried
  -      * @return namespace corresponding to 'theNode'
  +      * @param prefix prefix for a namespace
  +      * @return URI corresponding to namespace
         */
        virtual const XalanDOMString&
  -     getNamespaceOfNode(const XalanNode&     theNode) const = 0;
  +     getNamespaceForPrefix(
  +                     const XalanDOMString&   prefix, 
  +                     const XalanElement&             namespaceContext) const 
= 0;
   
        /**
         * Retrieves the URI of the named unparsed entity
  @@ -117,6 +119,18 @@
        getUnparsedEntityURI(
                        const XalanDOMString&   theName,
                        const XalanDocument&    theDocument) const = 0;
  +
  +     /**
  +      * Determine if a node is after another node, in document order.
  +      *
  +      * @param node1 The first node
  +      * @param node2 The second node
  +      * @return true if node1 one is after node2, or false if it is not.
  +      */
  +     virtual bool
  +     isNodeAfter(
  +                     const XalanNode&        node1,
  +                     const XalanNode&        node2) const = 0;
   };
   
   
  
  
  
  1.9       +14 -4     xml-xalan/c/src/DOMSupport/DOMSupportDefault.cpp
  
  Index: DOMSupportDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMSupportDefault.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DOMSupportDefault.cpp     2000/12/30 17:55:33     1.8
  +++ DOMSupportDefault.cpp     2001/01/08 18:12:24     1.9
  @@ -80,7 +80,6 @@
   
   DOMSupportDefault::DOMSupportDefault() :
        DOMSupport(),
  -     m_resolver(),
        m_pool()
   {
   }
  @@ -96,15 +95,16 @@
   void
   DOMSupportDefault::reset()
   {
  -     m_resolver.reset();
   }
   
   
   
   const XalanDOMString&
  -DOMSupportDefault::getNamespaceOfNode(const XalanNode&       theNode) const
  +DOMSupportDefault::getNamespaceForPrefix(
  +                     const XalanDOMString&   prefix, 
  +                     const XalanElement&             namespaceContext) const
   {
  -     return m_resolver.getNamespaceOfNode(theNode);
  +     return DOMServices::getNamespaceForPrefix(prefix, namespaceContext);
   }
   
   
  @@ -172,4 +172,14 @@
   #else
        return m_pool.get(theURI);
   #endif
  +}
  +
  +
  +
  +bool
  +DOMSupportDefault::isNodeAfter(
  +                     const XalanNode&        node1,
  +                     const XalanNode&        node2) const
  +{
  +     return DOMServices::isNodeAfter(node1, node2);
   }
  
  
  
  1.7       +10 -4     xml-xalan/c/src/DOMSupport/DOMSupportDefault.hpp
  
  Index: DOMSupportDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMSupportDefault.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DOMSupportDefault.hpp     2000/12/30 17:55:33     1.6
  +++ DOMSupportDefault.hpp     2001/01/08 18:12:24     1.7
  @@ -69,7 +69,6 @@
   
   
   #include <DOMSupport/DOMSupport.hpp>
  -#include <DOMSupport/NamespaceResolver.hpp>
   
   
   
  @@ -87,18 +86,25 @@
        virtual void
        reset();
   
  +
        // These interfaces are inherited from DOMSupport...
  +
        virtual const XalanDOMString&
  -     getNamespaceOfNode(const XalanNode&     theNode) const;
  +     getNamespaceForPrefix(
  +                     const XalanDOMString&   prefix, 
  +                     const XalanElement&             namespaceContext) const;
   
        virtual const XalanDOMString&
        getUnparsedEntityURI(
                        const XalanDOMString&   theName,
                        const XalanDocument&    theDocument) const;
   
  -private:
  +     virtual bool
  +     isNodeAfter(
  +                     const XalanNode&        node1,
  +                     const XalanNode&        node2) const;
   
  -     NamespaceResolver                       m_resolver;
  +private:
   
        mutable XalanDOMStringPool      m_pool;
   };
  
  
  

Reply via email to