I have customer records that exist as 2 records in order to create a single record so a customer has 2 meters - electic and gas.The data is recorded as 2 records (there is much more data shared between the 2 records but this illustrates the example):-
This data is in matched sets of 2 and it is possible for the customer to have either gas or electric meters or both. The data could be in either record.
I need to have a single record to display on the designer. I am using datamapper to try to do this and if I create a boundary on a trigger of element then I get 2 records so making it hard to access the second record in designer. If I trigger a boundary by using Acc_no then I get 1 record with both sets of data in but I cannot access the data as they have the same element id?
How can I create 1 set of data that I can access - ideally I need 1 set with an identifier on the data of the gas or electric like :-
Actually, it’s much simpler than that. When you set up your datamapper, you can tell it to put those two together as a single record simply by setting the “Boundaries” to create a new record when the Acc_No changes. That should give you both records together.
Note however, that the XML will have to be already in order for this to happen. if the XML is not sorted, this wouldn’t be available. Sorting methods are available through the Automation tool - in the case of XML, you might need to run XSLT on it for sorting. That is, if you can’t make sure it’s sorted as it comes out of your source system (whether that’s a database or something else).
Thanks for your answer and this is what I tried initially but I don’t see how I get the data extracted as the element has the same name. If I base the data extract on location the xpath is the same for both of these parts ./Cust_Comm/Electric Meter which is blank for the first part. If I put a second extract in ie Electric_Meter2 to try to access the second occurance it still uses the same xpath and hence gets the same data.
How do I get it to locate to the second part containing the data for the Electric Meter?
The easiest would be to extract Electric_Meter and Gas_Meter in a loop into a detail table.
If you do not want a detail table, add second extraction for those two fields, and change the XPath to ./Cust_Comm[2]/Electric_Meter
You can make that second extraction conditional to check how many elements there are with count(./Cust_Comm)