cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy a table from a context subnode into another subnode

Former Member
0 Kudos

Hi

I have to copy a table residing in a subnode of a context node into a subnode a value node. I would be grateful if anybody could provide a template.

Thanks.

René Morel

Accepted Solutions (1)

Accepted Solutions (1)

lajitha_menon
Contributor
0 Kudos

Hi Rene,

You can use the following code. ValueNodeSrc is your source node and ValueNodeDest is your destination node. If there are any attributes, whose names do not match, you have to manually set it after you do the WDcopyService like this

elemDest.setAttributeValue("Name1",elemSrc.getAttributeValue("FirstName"));

		IWDNodeElement elemSrc;
		IWDNodeElement elemDest;
		int size = ValueNodeSrc.size();
		for (int i = 0; i < size; i++) {

			ValueNodeSrc.setLeadSelection(i);
			elemSrc = ValueNodeSrc.getCurrentElement();

			elemDest = ValueNodeDest.createElement();
			ValueNodeDest.addElement(elemDest);

			WDCopyService.copyCorresponding(elemSrc, elemDest);

		}

Answers (4)

Answers (4)

monalisa_biswal
Contributor
0 Kudos

Yes.It is possible.Since ur destination node is a value node it ll not cause any error

Former Member
0 Kudos

Hi

Thanks a lot for all answers.

Can I use the WDCopyService mixed Content and Value nodes? My source table is in a Context node while the destination table is a Value node.

Regards

René Morel

Former Member
0 Kudos

Rene,

Any node in WD is "context node"

Do you mean Model Node and Value Node or something different?

VS

monalisa_biswal
Contributor
0 Kudos

If the structure of two nodes are same u can use following method

WDCopyService.copyElements(wdContext.node<sourcenode>,wdContext.node<targetnode>).

Former Member
0 Kudos

Hi,

a simple example with two context nodes (node1 and node2), and a String attribute, which is copied from node1 to node2.

NodeNode n = wdContext.nodeNode();
    INodeElement el = n.currentNodeElement();
    String str = el.getTable();
    
    INode2Node n2 = wdContext.nodeNode2();
    INode2Element el2 = n2.createNode2Element();
    el2.setTable2(str);
    n2.addElement(el2);

Hope I understood you correctly.

Kind Regards

Ilona