AnsweredAssumed Answered

Assigning XML counter from a database query

Question asked by mrelzer on Aug 10, 2017
Latest reply on Aug 11, 2017 by mrelzer

I have a nearly working process where I am mapping a database query to an XML file.


The resulting XML looks something like this (I've stripped quite a bit to make it easier to read) :


      <CREATE SEGMENT="1">
   <ITEM SEGMENT="11">
      <CREATE SEGMENT="11">


Note that the first ITEM has a segment value of 1, but the second has a value of 11. This appears to come from my query, which returns 13 records. The first 10 record (1-10) make up the content in the first ITEM element, while the the last three (11-13) make up the second. I have tried using both the "Line Item Increment" and the "Sequential Value" to handle this -- but either way the second <ITEM> ends up being 11 (seemingly the numerical record position in the query).


I need this number to end up being sequential -- and the ability to reset at certain points. For example... I need the output to end up as :


ITEM = 1

   CREATE = 1

ITEM = 2

   CREATE = 1


If there were two CREATES inside of an ITEM, the second would be a value of 2.





So I guess there are technically two questions here... How can I create some sort of counter that adds one for each time it is assigned on the output side of the mapping (as opposed to using the input count)... and how can I reset the number when a certain condition is met (for example when the ITEM counter moves to 2, reset the CREATE counter).