on 02-13-2008 6:26 AM
Hi,
I want to copy node elements from node-1 to node-2..
These two node has exactly same structure. These node have child nodes like following:-
Node 'Transaction' has two value attributes-> 'tid', 'tname' and a value node 'Combination' which has a value attribute 'desc'
Im able to copy value attributes tid, tname using copyCorresponding, but how do I copy child node elements ???
Regards,
Amey
Edited by: Amey Mogare on Feb 13, 2008 7:26 AM
Hi,
you can use copySubTree(source,target) of WDCopyService
Regards,
Sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ya, i can use copySubTree()...
But I m not able to get how it works??
I read this from its documentation-->
-
copySubtree
public static void copySubtree(IWDNode source,
IWDNode target)
Copies all elements from to complete subtree of source to target. This is done by applying copyElements(IWDNode, IWDNode) to the nodes and then searching for equally named subnodes and recursively applying copySubtree to them.
Parameters:
source - The source node
target - The target node
Throws:
WDRuntimeException - if copyElements(IWDNode, IWDNode) fails for a node in the subtree.
-
I tried in several ways, but it is not working.. can u giv me any sample code to copy subtree???
Regards,
Amey
Hiiii Sudhir,
I guess there is something wrong in my implementation:-
Bcoz it is only copying 1st element's subtree..I tried putting it in loop too, but still not working..
public boolean BackUpTransaction( )
{
wdContext.nodeTransaction_1().invalidate();
try{
//Master = Transaction
//Target = Transaction_1
IPrivateView1.ITransaction_1Node TargetNode = wdContext.nodeTransaction_1();
IPrivateView1.ITransactionNode masterNode = wdContext.nodeTransaction();
int size = masterNode.size();
for (int i = 0; i < size; i++)
{
//Copying Transaction's value attributes
IPrivateView1.ITransactionElement masterElement = (IPrivateView1.ITransactionElement)wdContext.nodeTransaction().getElementAt(i);
IPrivateView1.ITransaction_1Node tr1node = wdContext.nodeTransaction_1();
IPrivateView1.ITransaction_1Element tr1element = tr1node.createTransaction_1Element();
WDCopyService.copyCorresponding(masterElement, tr1element);
tr1node.addElement(tr1element);
} //end of for
WDCopyService.copySubtree(wdContext.nodeTransaction().nodeCombination(),wdContext.nodeTransaction_1().nodeCombination_1());
} //end of try
catch(Exception e)
{
e.printStackTrace();
}
return true;
} //end of function
Pls suggest !!!
thank you..
Regards,
Amey
Hi,
This should diffinetly work
WDCopyService.copyElements(wdContext.nodeMain(),wdContext.nodeMain_1());
for(int k=0;k<size;k++){
IMainElement ele=wdContext.nodeMain().getMainElementAt(k);
IMain_1Element ele1=wdContext.nodeMain_1().getMain_1ElementAt(k);
WDCopyService.copyElements(ele.nodeSub(),ele1.nodeSub_1());
}
Regards,
Sudhir
Edited by: Sudhir Gorantla on Feb 15, 2008 7:07 AM
public boolean BackUpTransaction( )
{
wdContext.nodeTransaction_1().invalidate();
try{
//Master = Transaction
//Target = Transaction_1
IPrivateView1.ITransaction_1Node TargetNode = wdContext.nodeTransaction_1();
IPrivateView1.ITransactionNode masterNode = wdContext.nodeTransaction();
int size = masterNode.size();
WDCopyService.copyElements(masterNode,TargetNode);
for (int i = 0; i < size; i++)
{
WDCopyService.copyElements(masterNode.getElementAt(i).nodeCombination(),TargetNode.getElementAt(i).nodeCombination_1());
} //end of for
} //end of try
catch(Exception e)
{
e.printStackTrace();
}
return true;
} //end of function
Regards,
Sudhir
Edited by: Sudhir Gorantla on Feb 15, 2008 7:13 AM
Hi,
You can try this
WDCopyService.copyElements(wdContext.nodeTransaction(),wdContextNodeTransaction_1());
WDCopyService.copySubTree(wdContext.nodeTransaction().nodeCombination(),wdContext.nodeTransaction_1().nodeCombination());
Regards,
Sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.