XML Output Stage - Repeating elements

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
suemar.souza@hotmail.com
Participant
Posts: 3
Joined: Wed Jun 05, 2013 9:17 pm
Location: São Paulo - Brazil

XML Output Stage - Repeating elements

Post by suemar.souza@hotmail.com »

Hey everybody, this is my first post, and I will try to be as specific as I can, and I would appreciate your help.

I need to read data from a table and generate a XML File. I saw a couple of examples and other topics, but no one with the same context:

I read, for example, three columns:

Code: Select all

  ID | NAME   | AGE
   1 | PETER  |   35
   2 | PAUL   |  40
And need to generate a XML file with a "hard" structure, like this:

Code: Select all

  <node>
     <file> /dir/filename</file> 
     <category name="CATEGORY 1: PERSON">
          <attribute name="Name"> PETER       </attribute> 
          <attribute name="age">    35           </attribute> 
          <attribute>            </attribute>  
     </category>
     <category name "CATEGORY 2: ID">
          <attribute name="value"> 1 </attribute>
     </category>
  <node>
I would like to do something like this:

Code: Select all

INPUT COLUMN       XPATH MAPPED
PETER              /node/category/@name["Name"]/text()
35                 /node/category/@name["Age"]/text()
When the argument value of the tag "name" is "Name" I map "PETER", , when "age" I map "35".

Finally: I need to group based on the attribute name not based on the "tag".

Thanks in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

Wait for "Ernie the XML expert" to come along. :D
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

You will need a variety of techniques here. This is a fairly poor xml design...at least on the scale of using tag names as metadata....(ie. With tags of name and age instead of having true metadata stored in attribute values.).....but as a tip to get started, and to help you to use also the many many xml posts here, work first on getting your data pivoted into individual rows and groupings.....so name is on its own row, and age is on its own row, etc.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
suemar.souza@hotmail.com
Participant
Posts: 3
Joined: Wed Jun 05, 2013 9:17 pm
Location: São Paulo - Brazil

Post by suemar.souza@hotmail.com »

ray.wurlod wrote:Welcome aboard.

Wait for "Ernie the XML expert" to come along. :D
Thanks Ray, he had already appeared =D
Suemar S. Souza
suemar.souza@hotmail.com
Participant
Posts: 3
Joined: Wed Jun 05, 2013 9:17 pm
Location: São Paulo - Brazil

Post by suemar.souza@hotmail.com »

Hello Ernie, thanks a lot for your answer, it seem you are the reference regarding to XML in here.

Unfortunately I couldn't see it so far because I'm not a premium member.

I'm checking the possibilites.

Thanks in advance
Suemar S. Souza
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

One-off special since you're new to DSXchange...
eostic wrote:You will need a variety of techniques here. This is a fairly poor xml design...at least on the scale of using tag names as metadata....(ie. With tags of name and age instead of having true metadata stored in attribute values.).....but as a tip to get started, and to help you to use also the many many xml posts here, work first on getting your data pivoted into individual rows and groupings.....so name is on its own row, and age is on its own row, etc.
Now please sign up for premium membership.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply