cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Not able to get the reference for the parent node

Former Member
0 Likes
298

Hi,

I have to add some xml fragments into a target XML. This target has some repetitive XML elements. The xml fragments to be added should go into each of this repetitive XML elements in the target XML.

For example, the

following XML has <book> element repeated twice.

<?xml version="1.0" encoding="UTF-8"?>

<bookstore><book>

<title lang="eng">Harry Potter</title>

<price>29.991</price>

</book>

<book>

<title lang="eng">Learning XML</title>

<price>39.952</price>

</book>

</bookstore>

I want to add XML element <STATUS>104</STATUS> inside of each <book>

element. So, I assigned this <STATUS>104</STATUS> xml fragment for the following target XPath Local.test{/bookstore/book} using "Assign XML" radio button in Link Editor. After the assignment, it is expected that all the <book> elements will have the new element <STATUS>. But the target XML has the assignment

done only for the first <book> element.

Anybody know the worksaround for this issue?

Thanks,

Sara

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

Hi Sara,

Put that data of total bookstore in a repeater and repeat on book. Next in assignment block you need to write code Local.test{/bookstore/book[#repeater.currentItem#]}. Otherwise it will take default as book[0] and keep on adds to the first item only.

Thanks,

Rajesh

PS : Please award points if answer is useful.

Message was edited by:

Rajesh Madala

Former Member
0 Likes

You can also use the Dynamic Link in the Link Editor as oppose to referencing the Repeater.CurrentItem. Both ways will work.

Former Member
0 Likes

Hi Rajesh,

Thats what I did. But I was looking for an easier to handle this.

Thanks,

Sara

Former Member
0 Likes

hi sara,

We can use a repeater to do this.but,I would like to give u an another way which will save time of execution of transaction in case of huge data if u need to add a new column which is having to insert a same value or a value based on certain condition.U can use calculated columns action for doing this.In that u just need to give the query results set and column name which is to be added along with a value which u are going to give.u can set a value based on a condition there itself.

please revert in case of further assistance.

regards,

Ravi Kumar

sufw
Active Participant
0 Likes

Hi Ravi,

I would personally try to avoid the "CalculatedColumns" action since we have found that for large rowsets (more than a few hundred rows), the action is significantly slower than using a repeater and the "xMII XML Output" action block such as "Add Row". This seems to be regardless of the complexity of the actual calculation which is performed.

Regards,

Sascha

Former Member
0 Likes

Hello Sara,

Are you using a repeater block to enter your STATUS element to each of the book elements?

Best Regards,

Joe