You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Andrei Smirnov <as...@hotjobs.com> on 2000/10/16 03:49:21 UTC

XercesDocumentBridge::importNode

hi

method in subj is not implemented. i don't know what the plan
about it but look at patch below. the major problem was that
mapping of imported xalan node to dom node was not working.
my case was someone have read another xml file with
XercesParserLiaison::parseXML.

after some looking i got idea that BridgeWalker should
create mapping when XercesDocumentBridge ctor works. that goes to
method below

void
XercesDocumentBridge::BuildBridgeTreeWalker::startNode(const DOM_Node&
node)
{
	XalanNode* const	theBridgeNode =
m_document->createBridgeNode(node, m_currentIndex, true);
                                                   ^^^^
                                              was false


after this fix the implementation of XercesDocumentBridge::importNode
have started to work for my case. only thing one need to remember that
once imported node has been added to destination tree last one
should rebuild the bridge.

andrei

=================================================================
Index: XercesParserLiaison/XercesDocumentBridge.cpp
===================================================================
RCS file:
/home/cvspublic/xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.cpp,v
retrieving revision 1.12
diff -u -r1.12 XercesDocumentBridge.cpp
--- XercesParserLiaison/XercesDocumentBridge.cpp        2000/09/19
14:47:22     1.12
+++ XercesParserLiaison/XercesDocumentBridge.cpp        2000/10/16
01:33:14
@@ -1583,17 +1583,27 @@
                        XalanNode*      importedNode,
                        bool            deep)
 {
-       // $$$ToDo: Fix this....
-       // The problem is that we must get the Xerces node that
corresponds to the
-       // importedNode parameter.  We could assume that it is indeed a
node from
-       // another XercesDocumentBridge, but I'm not sure that we should
do that.
-       throw
XercesDOMException(XercesDOMException::NO_MODIFICATION_ALLOWED_ERR);
-
-       return 0;
+       try {
+         XercesDocumentBridge* importedNodeOwner = 0;
+         importedNodeOwner =
dynamic_cast<XercesDocumentBridge*>(importedNode->getOwnerDocument());
+
+         DOM_Node dom_importedNode;
+         dom_importedNode = importedNodeOwner->mapNode(importedNode);
+
+         DOM_Node result_dom_node;
+         result_dom_node = m_xercesDocument.importNode(dom_importedNode,
deep);
+         
+         XalanNode* result_node = 0;
+         result_node = createBridgeNode(result_dom_node, 0, true);
+         assert(mapNode(result_dom_node) == result_node);
+         
+         return result_node;
+       }
+       catch (const DOM_DOMException& theException) {
+         throw XercesDOMException(theException);
+       }
 }
 
-
-
 XalanElement*
 XercesDocumentBridge::createElementNS(
                        const XalanDOMString&   namespaceURI,
@@ -1752,7 +1762,7 @@
 void
 XercesDocumentBridge::BuildBridgeTreeWalker::startNode(const DOM_Node&
node)
 {
-       XalanNode* const        theBridgeNode =
m_document->createBridgeNode(node, m_currentIndex, false);
+       XalanNode* const        theBridgeNode =
m_document->createBridgeNode(node, m_currentIndex, true);
 
        XercesBridgeNavigator&  theCurrentNodeNavigator =
m_navigators.back();