xml output

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
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

xml output

Post by harryhome »

I have a seq input file with two columns. My desired o/p for this job is a xml in a seq file with some additional default data.

e.g.

input is

empname empnumber
abc 1
xyz 2


output desired is

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ImportRequest xsi:noNamespaceSchemaLocation="ImportRequest.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<company>aaa</company>
<addr>bbb</addr>
<empname>abc</empname>
<empnumber>1</empnumber>
<company>aaa</company>
<addr>bbb</addr>
<empname>xyz</empname>
<empnumber>2</empnumber>
</ImportRequest>

Here empname and empnumber are coming from input while company and addr are default.


plz guide me on the same.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What have you tried so far... anything? Always best to mention that, so we don't go through iterations of 'no, I already tried that'. :?

Best Practice is to get (or create) an xsd for the XML you will be working with. You can then import the metadata from that xsd and it will create the XPath Expressions you would need to read/write that particular structure.

Your task here seems pretty straight-forward. Add your 'hard-coded' values of company and addr to the input stream of employee information and into an XML Output stage with the proper XPath Expressions. Done.
-craig

"You can never have too many knives" -- Logan Nine Fingers
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

Post by harryhome »

thanks for reply.

In job I have taken a i/p seq file having data as

empname empnumber
abc 1
xyz 2

then i have used next stage as xml output stage, followed by a seq file stage.

now i have gone through the documentation for xml output stage, and accordingly i was creating a xml meta data (where it was showing me xpath expression for each tag in xml), but i m not able to perfectly place these xpath expression which are getting generated for each column on right place in xml output stage.

kindly tell me whether i m using right stage and how to set properties for the stage.

also we have default the values in xpath expression else where should we specify these defult value

plz guide
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You don't need the Sequential File stage after the XML Output, it is perfectly capable of writing the file out. Enable that from the Options tab.

If you use the Load option on the Input/Columns tab to bring your metadata into the stage, everything will go in the right place, including the XPath Expressions into the Description column.

As far as I know, you cannot specify a default value in the XPath expression. You'll need a stage before the XML Output to deliver those values. Be happy to be proven wrong. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

Post by harryhome »

Thanks for ur valueable inputs

I m now able to get the file from xml output stage in xml format.


nw the desired o/p is as follows ,

where addr for company is coming from i/p column and each time there ll be only two employes whose names are defaulted.
I transformation stage , i m defaulting first value "abc". how to make any futher transformation so that for a single record i ll get both empname in following format

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ImportRequest xsi:noNamespaceSchemaLocation="ImportRequest.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<company>
<addr>bbb</addr> ----------INPUT COLUMN VALUE
<empname>abc</empname> ---------Default Value
</company>
<company>
<addr>bbb</addr> ----------INPUT COLUMN VALUE
<empname>xyz</empname> ---------Default Value
</company>
</ImportRequest>



plz guide
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use code tags so that any formatting of your xml is preserved. Post both what you are getting now and what you want it to look like instead - two examples, clearly labelled which is which. Please. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

Post by harryhome »

thanks for reply
Last edited by harryhome on Fri Feb 09, 2007 2:41 am, edited 1 time in total.
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

Post by harryhome »

here is the output what i m getting,

<ImportRequest>
<SenderReference>
<RequestId>
FAST
</RequestId>
<Identity>
FAST
</Identity>
</SenderReference>
<CRTData>
<BusinessArea>
<eid>
1
2
</eid>
<name>
CG
MCG
</name>
<descriptionEn>
CG
MCG
</descriptionEn>
<date_time_updated />
<updateUserLogin>
T4950WM
T4950WM
</updateUserLogin>
</BusinessArea>
</CRTData>
</ImportRequest>




and the expected one is as follows



<ImportRequest xsi:noNamespaceSchemaLocation="ImportRequest.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SenderReference>
<RequestId>FAST</RequestId> -----value defaulted in transformer
<Identity>FAST</Identity> -----value defaulted in transformer
</SenderReference>
<CRTData>
<BusinessArea>
<eid>1</eid> -----value defaulted in transformer
<name>CG</name> -----value defaulted in transformer
<descriptionEn>CG</descriptionEn>-----value defaulted in transformer
<date_time_updated />
<updateUserLogin>T4950WM</updateUserLogin>---from input column
</BusinessArea>
<BusinessArea>
<eid>2</eid>-----value defaulted in transformer
<name>MCG</name> -----value defaulted in transformer
<descriptionEn>MCG</descriptionEn> -----value defaulted in transformer
<date_time_updated />
<updateUserLogin>T4950WM</updateUserLogin> >---from input column
</BusinessArea>
</CRTData>
</ImportRequest>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

harryhome...

Curious....how many rows, in the job results, are going INTO the XMLOutput stage?

I would expect "two," for the desired output you are looking for. It's odd that it appears to be concatenating your two values. Let us know how many rows are going "in" to the Stage and what your optios are in the stage, particularly for the "Aggregate"/trigger radio button....

Ernie
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

Post by harryhome »

for the output that we r getting currently , i/p is one row and o/p is also one row.

In stage i m aggregating all rows.
Post Reply