Hi Mohammed,

Please post to the list, since there are no doubt others who are interested
in what you're trying to do.

You should do something like this:

   1. Get a Xerces DOM_Document instance to use.

   2. Get a string containing an XPath expression.

   3. Wrap the Xerces document in a XercesDocumentBridge instance, using
   XercesParserLiaison::createDocument().  You can recover a pointer to the
   implementation class through XercesParserLiaison::mapDocument().

   4. If a context node other than the document is needed, use
   XercesDocumentBridge::mapNode() to map the Xerces DOM_Node to a
   XalanNode*.

   5. Use the XPathEvaluator class to evaluate the XPath.

   6. Map any results from the returned nodeset to their Xerces DOM
   counterparts using XercesDocumentBridge::mapNode().

   7. Do the append of the fragment through the Xerces APIs.

   8 . Destroy the bridge instance using
   XercesParserLiaison::destroyDocument().

   9. There is no need to map back to the Xerces DOM_Document instance,
   since you already know what it is.

You should get the latest source code through CVS to get the new
XPathEvaluator and fixes to the Xerces bridge.  There is a sample
application that uses XPathEvaluator.  See here for more details on getting
the latest sources:

   http://xml.apache.org/cvs.html

Dave

----- Forwarded by David N Bertoni/CAM/Lotus on 06/25/2001 04:35 PM -----
                                                                                       
                            
                    "Zubair                                                            
                            
                    Mohammed"             To:     [EMAIL PROTECTED]            
                            
                    <mohdzubair@ho        cc:                                          
                            
                    tmail.com>            Subject:     Re: Problem with importNode     
                            
                                                                                       
                            
                    06/25/2001                                                         
                            
                    04:18 PM                                                           
                            
                                                                                       
                            
                                                                                       
                            



Hi David,
thanks for the information about importNode.
I guess i should be posting this on the grouplist, but i thought i should
get ur view before doing so.

Basically in my application i have to build a DOM_Tree interactively.
           My inputs are Xpath locations and xml_tree fragments, and i
recieve these
incrementally(many).

Initially i recieve a basic DOM_Tree and this is classified as the
main_document.
Successively i recieve xpaths pertaining to this main_document and small
xml_fragments which i may have to add at the specified xpath locations in
the main_document.

The way i thought of doing this initially was.

1. Recieve the initial main_Document -> transform as XalanDocument and
initialize it as theTargetDoc.
2. The successive xpaths and xml_fragemtns i recieve would be passed as
calls to the XPathWrapper where i have an evaluate function.
Here i use the xpath to traverse through this theTargetDoc and find the
location where the xml_fragment has to be added and the call importNode and

do the same
           XObjectPtr          xObj = contextXPath->execute
(...............);
           const NodeRefListBase&         contextNodeList = xObj->nodeset
();
           XalanNode* targetNode = contextNodeList.item(0);

3. After 2(above) has been called iteratively, and the whole tree build up
is finished i call mapXercesDocument(theTargetDoc) to map to a DOM_Document

and send it back to the main application.

Now the problem is that as importNode would not work in the Xalan
environment, i do not know how to use the XPath feature to traverse the
tree.
Even if i want to do the build up in Xerces_Dom, then too the Xpath returns

a XalanNode as shown above

and i am not too sure as to how map this back to Xerces mode so that i can
call importNode there.


Any suggesstion would be welcome and i will post this mail to the group if
you think this would be relevent to the group.


THanks,
Mohammed Zubair.


From: [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: Problem with importNode
Date: Mon, 25 Jun 2001 15:40:54 -0400


As the comment states, it's _extremely difficult within the bridge to
implement importNode(), so it's not supported.

You should do all of your modifications with the Xerces APIs using the
Xerces DOM.  Then, when you're done, wrap the document in a
XercesDocumentBridge instance and do the transformation.  If you're going
to do modifications and transformations iteratively, make sure you destroy
the old bridge and create a new one before you transform.  The bridge is
not really designed for modification, so it's best to avoid it.

Dave




                     "Zubair
                     Mohammed"             To:     [EMAIL PROTECTED]
                     <mohdzubair@ho        cc:     (bcc: David N
Bertoni/CAM/Lotus)
                     tmail.com>            Subject:     Problem with
importNode

                     06/25/2001
                     02:52 PM
                     Please respond
                     to xalan-dev





Hi,
I am trying to use the importNode functionality in XalanDocument.

I have the following scenario.

XalanElement*  payloadNode=0;
XalanNode* node;

payloadNode = theDoc->getDocumentElement();//theDoc is a XalanDocument
node = theTargetDoc->importNode(payloadNode,true);// theTargetDoc is the
main XalanDoc under which the payloadNode has to be imported.

When i call this importNode method it goes to
XercesDocumentBridge.cpp and throws an exception

/////////////////
XalanNode*
XercesDocumentBridge::importNode(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;
}



Has anyone encountered this before.

Any  help would be appreciated.

regards,
Mohammed Zubair.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.






_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.




Reply via email to