Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can we achieve Conditional increment in XSLT

User_LLJ6HMar 14 2013 — edited Mar 14 2013
Input:
<Order>
<HeaderValue1>ORDER1</HeaderValue1>
<OrderLineItems>
<Item>`A`</Item>
</OrderLineitems>
<OrderLineItems>
<Item>A</Item>
</OrderLineItems>
<OrderLineItems>
<Item>`A`</Item>`
</OrderLineItems>
<OrderLineItems>`
<Item>B</Item>`
</OrderLineItems>
</Order>
<Order>
<HeaderValue1>`ORDER2`</HeaderValue1>
<OrderLineItems>
<Item>B`</Item>
</OrderLineItems>
</Order>
**********

for each order there is a number of orderLineItems are present.For each order and items we need to assign a increment value.if the previous item value is equal to current item value.there is no need to increment just pass the value.otherwise increment value is assign to item element.


I need the output like below.

output:
**********
<Order>
<HeaderValue1>1`</HeaderValue1>
<OrderLineItems>`
<Item>2`</Item>
</OrderLineItems>
<OrderLineItems>
<Item>A`</Item>
</OrderLineItems>
<OrderLineItems>
<Item>A`</Item>
</OrderLineItems>
<OrderLineItems>
<Item>3`</Item>
</OrderLineItems>
</Order>
<Order>
<HeaderValue1>4</HeaderValue1>
<OrderLineItems>
<Item>5</Item>
</OrderLineItems>
</Order>

Here is the points we should consider:
1)There is number of orders are present.
2)for each order there is number of orderLineitems are there.
3)we have to assign a sequence number to each iteration but there is a condition is present like(Conditional increment)

if the previous item value is equal to current item value.no need to increase sequence number just pass the item value.if it is not equal just increase sequence number and assign to item.

Edited by: 913885 on Mar 14, 2013 1:17 PM

Edited by: 913885 on Mar 14, 2013 1:32 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2013
Added on Mar 14 2013
0 comments
328 views