dbertoni    2002/12/19 17:45:43

  Modified:    c/src/XercesParserLiaison XercesDocumentWrapper.cpp
                        XercesDocumentWrapper.hpp
  Log:
  Implemented mapping of Xalan nodes to Xerces nodes without using a map.
  
  Revision  Changes    Path
  1.7       +100 -25   
xml-xalan/c/src/XercesParserLiaison/XercesDocumentWrapper.cpp
  
  Index: XercesDocumentWrapper.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesDocumentWrapper.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XercesDocumentWrapper.cpp 28 Nov 2002 00:26:07 -0000      1.6
  +++ XercesDocumentWrapper.cpp 20 Dec 2002 01:45:42 -0000      1.7
  @@ -200,43 +200,118 @@
   const DOMNodeType*
   XercesDocumentWrapper::mapNode(XalanNode*    theXalanNode) const
   {
  -     const DOMNodeType*      theXercesNode = 0;
  -
  -     if (theXalanNode != 0)
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +     if ((const XalanNode*)this == theXalanNode)
  +#else
  +     if (static_cast<const XalanNode*>(this) == theXalanNode)
  +#endif
        {
  -             theXercesNode = m_nodeMap.getNode(theXalanNode);
  -
  -             if (theXercesNode == 0)
  -             {
  -                     throw 
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
  -             }
  +             return m_xercesDocument;
        }
  +     else if (theXalanNode == 0 ||
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +             (const XalanDocument*)this != theXalanNode->getOwnerDocument())
  +#else
  +             static_cast<const XalanDocument*>(this) != 
theXalanNode->getOwnerDocument())
  +#endif
  +     {
  +             throw 
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
  +     }
  +     else
  +     {
  +             switch(theXalanNode->getNodeType())
  +             {
  +             case XalanNode::ATTRIBUTE_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesAttrWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesAttrWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
  +
  +             case XalanNode::CDATA_SECTION_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesCDATASectionWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesCDATASectionWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
  +
  +             case XalanNode::COMMENT_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesCommentWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesCommentWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
  +
  +             case XalanNode::DOCUMENT_FRAGMENT_NODE:
  +                     throw 
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
  +                     break;
   
  -     return theXercesNode;
  -}
  +             case XalanNode::ELEMENT_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesElementWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesElementWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
   
  +             case XalanNode::ENTITY_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesEntityWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesEntityWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
   
  +             case XalanNode::ENTITY_REFERENCE_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesEntityReferenceWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesEntityReferenceWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
   
  -const DOMAttrType*
  -XercesDocumentWrapper::mapNode(XalanAttr*    theXalanNode) const
  -{
  -     const DOMNodeType*      theXercesNode = 0;
  +             case XalanNode::NOTATION_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesNotationWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesNotationWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
   
  -     if (theXalanNode != 0)
  -     {
  -             theXercesNode = m_nodeMap.getNode(theXalanNode);
  +             case XalanNode::PROCESSING_INSTRUCTION_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesProcessingInstructionWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesProcessingInstructionWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
   
  -             if (theXercesNode == 0)
  -             {
  -                     throw 
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
  -             }
  -     }
  +             case XalanNode::TEXT_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                     return ((const 
XercesTextWrapper*)theXalanNode)->getXercesNode();
  +#else
  +                     return static_cast<const 
XercesTextWrapper*>(theXalanNode)->getXercesNode();
  +#endif
  +                     break;
   
  +             case XalanNode::DOCUMENT_TYPE_NODE:
   #if defined(XALAN_OLD_STYLE_CASTS)
  -     return (const DOMAttrType*)theXercesNode;
  +                     return ((const 
XercesDocumentTypeWrapper*)theXalanNode)->getXercesNode();
   #else
  -     return static_cast<const DOMAttrType*>(theXercesNode);
  +                     return static_cast<const 
XercesDocumentTypeWrapper*>(theXalanNode)->getXercesNode();
   #endif
  +                     break;
  +
  +             default:
  +                     assert(false);
  +                     break;
  +             }
  +
  +             return 0;
  +     }
   }
   
   
  
  
  
  1.5       +40 -3     
xml-xalan/c/src/XercesParserLiaison/XercesDocumentWrapper.hpp
  
  Index: XercesDocumentWrapper.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesDocumentWrapper.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XercesDocumentWrapper.hpp 28 Nov 2002 00:26:07 -0000      1.4
  +++ XercesDocumentWrapper.hpp 20 Dec 2002 01:45:43 -0000      1.5
  @@ -318,20 +318,57 @@
        void
        rebuildWrapper();
   
  +     /**
  +      * Map a Xerces node to the corresponding wrapper node.
  +      * If the constructor for the instance was called with
  +      * the threadSafe or buildWrapper parameter equal to
  +      * true, this call will fail.
  +      *
  +      * @param theXercesNode The Xerces instance to map
  +      *
  +      * @return The pointer to the corresponding XalanNode instance, or 0 if 
the node could not be mapped.
  +      */
        XalanNode*
        mapNode(const DOMNodeType*      theXercesNode) const;
   
  +     /**
  +      * Map a Xerces node to the corresponding wrapper node.
  +      * If the constructor for the instance was called with
  +      * the threadSafe or buildWrapper parameter equal to
  +      * true, this call will fail.
  +      *
  +      * @param theXercesNode The Xerces instance to map
  +      *
  +      * @return The pointer to the corresponding XalanNode instance, or 0 if 
the node could not be mapped.
  +      */
        XalanAttr*
        mapNode(const DOMAttrType*      theXercesNode) const;
   
  +     /**
  +      * Map a Xerces node to the corresponding wrapper node.
  +      * If the constructor for the instance was called with
  +      * the threadSafe or buildWrapper parameter equal to
  +      * true, this call will fail.
  +      *
  +      * @param theXercesNode The Xerces instance to map
  +      *
  +      * @return The pointer to the corresponding XalanNode instance, or 0 if 
the node could not be mapped.
  +      */
        XalanElement*
        mapNode(const DOMElementType*   theXercesNode) const;
   
  +     /**
  +      * Map a XalanNode to the corresponding Xerces node.
  +      * If the node not owned by this document, the
  +      * function will throw XalanDOMException with the code
  +      * WRONG_DOCUMENT_ERR.
  +      *
  +      * @param theXalanNode The Xalan instance to map
  +      *
  +      * @return The pointer to the corresponding XalanNode instance, or 0 if 
the node could not be mapped.
  +      */
        const DOMNodeType*
        mapNode(XalanNode*      theXalanNode) const;
  -
  -     const DOMAttrType*
  -     mapNode(XalanAttr*      theXalanNode) const;
   
        /**
         *
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to