on 02-28-2016 4:55 PM
Hi everyone,
I have the following XML.
<header>
<key/>
<dummy1/>
</header>
<line>
<key/>
<dummy2/>
</line>
I want to populate a counter/index in field key of header and line.
A header can have many lines.
In the XML file, there can be many headers.
the header and lines are connected via field key.
Example:
<header>
<key>1</key>
<dummy1>abcd</dummy1>
</header>
<line>
<key>1</key>
<dummy2>aaaa</dummy2>
</line>
<line>
<key>1</key>
<dummy2>bbbbb</dummy2>
</line>
<header>
<key>2</key>
<dummy1>abcd</dummy1>
</header>
<line>
<key>2</key>
<dummy2>eeee</dummy2>
</line>
<line>
<key>2</key>
<dummy2>rrrr</dummy2>
</line>
<line>
<key>2</key>
<dummy2>qqqq</dummy2>
</line>
I tried to use the INDEX or COUNT in Message Mapping but I did not succeed.
Can someone help ?
Thanks,
Regards.
I'm not sure I'm following (completely).
1. Please give an example of your input and an example of the desired output.
2. Please state, what's your scenario. Is it File (Flat File) --> PI --> <Target>?
FCC is File Content Conversion by the way, some technique to make an XML document out from a flat file. Headers and items are supported with FCC.
HTH
Cheers
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Input flat file:
HMetallica
LNothing else matters
LEnter Sandman
HACDC
LHighway to hell
LBack in black
The target XML file looks like:
<header>
<band>Metallica</band>
</header>
<header>
<band>ACDC</band>
</header>
<line>
<title>Nothing else matters</title>
</line>
<line>
<title>Enter Sandman</title>
</line>
<line>
<title>Highway to hell</title>
</line>
<line>
<title>Back in black</title>
</line>
The order is changed. So I want to create a key between headers and lines thus I can regroupe them later.
The desired XML target file would be:
<header>
<band>Metallica</band>
<key>1</key>
</header>
<header>
<band>ACDC</band>
<key>2</key>
</header>
<line>
<title>Nothing else matters</title>
<key>1</key>
</line>
<line>
<title>Enter Sandman</title>
<key>1</key>
</line>
<line>
<title>Highway to hell</title>
<key>2</key>
</line>
<line>
<title>Back in black</title>
<key>2</key>
</line>
Thanks,
Regards.
So finally there's someone with a taste for good music
Anyways: If I get you correctly, you have an input flat file that already has an order which groups together bands and titles, right?
Why do you need the "target XML file" to be flat as well? You could, as Praveen has shown in the link, instantly create a deep nested XML after (graphical) mapping without the need for keys, like so:
<document>
<band>
<bandName>Metallica</bandName>
<title>Nothing else matters</title>
<title>Enter Sandman</title>
</band>
<band>
<bandName>ACDC</bandName>
<title>Highway to hell</title>
<title>Back in black</title>
</band>
</document>
If you need to obey the root structure of the "target XML file" and only could add nodes on a sub-node level (like the "key" node you introduced), then only you would need to go through the troubles of computing a key field.
Cheers
Jens
Hi David
Firstly, from your example XML, it looks like it isn't a well-formed XML. <header> and <line> are at the same level so you cannot have them interleaved like below:-
<header>
<line>
<header>
<line>
<line>
A well-formed XML will have all the <header> before all the <line>.
How is your XML generated? It is from an FCC configuration?
Secondly, it this XML structure the source or the target? What is the logic to determine the value of the index/counter? Is it by position?
Regards
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eng Swee,
The headers are like subheaders.
The xml generated is like what I described in my first post but all the headers are grouped together (and so the lines).
The purpose is to create a key between the headers and their own lines.
It is from an FCC configuration? Sorry, I do not know what is FCC.
Thanks.
Regards.
Hi David,
I suggest you use a variable on header level and populate it with the Index and SplitByValue functions.
Like this - just without the concatenation:
See also:
Standard Functions in PI 7.0 - Process Integration - SCN Wiki
Kind regards
Konrad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.