Help with XML Output Stage

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
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Help with XML Output Stage

Post by mac4rfree85 »

Hi Guys,

This is my first attempt at creating an XML file, though i have worked in parsing an XML file earlier.

My input file is as below

Code: Select all

TransactionID,TransactionLineNumber,StoreID,ScanType,PLUID
1030104,1,625,2,21155269
1030105,1,626,1,21155270
I want to convert it to XML stage as below.

Code: Select all

<Transaction>
 <TransactionID>1030104</TransactionID>
	<LineItemDetail>
                <TransactionLineNumber>1</TransactionLineNumber>
                <StoreID>625</StoreID>
                <ScanType>2</ScanType>
                <PLUID>21155269</PLUID>
	</LineItemDetail>
	<TransactionID>1030105</TransactionID>
	<LineItemDetail>
                <TransactionLineNumber>1</TransactionLineNumber>
                <StoreID>626</StoreID>
                <ScanType>1</ScanType>
                <PLUID>21155270</PLUID>
	</LineItemDetail>
</Transaction>
I am reading sequential file and passing it to XML output stage. In the derivation of Sequential stage, i am giving the XPATH expressions.
I have given TransactionID as trigger column. In output tab, i have defined a single column as Varchar(999999).
But it is throwing an error as

Code: Select all

The input rule does not map to any output rule
Can somebody help me with this.

Cheers!!!!
Last edited by mac4rfree85 on Tue Sep 06, 2011 7:09 am, edited 1 time in total.
Mac4rfree
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Import the document you have below via the xml metadata importer. Click only the inner most boxes (with the "T"). There should be five of them. Indicate TransactionLineNumber as a key. Load that tabledef into your input link.

Spend time searching thru other threads here concerning additional details of the stage, but that's the basics.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

I have saved the metadata using the XML Metadata Importer and marked TransactionLineNumber as key.
The Metadata had 5 columns with the same XPATH which i used before.
So, i used it in Output stage. But it is still getting aborted.
Mac4rfree
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why are you using a trigger column? Do you understand what that does?
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

For testing purposes, remove your output link. Put the xml document to a file.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

@chulett,, yeah that did the trick... i made it as Aggregate into one column.
Now i am able to create the file for testing as told.
But i am not able to route it as Output.
In output, i have used the same metadata definition as defined in Input.

Also the file being created by XML Output stage is having CTRL+M in each of lines. how to rectify it. Below is my XML created by Output stage.

Code: Select all

<!--^M
  - Generated by Ascential Software Corporation, DataStage - XMLOutput stage - ^M
  - Wed Sep  7 04:17:37 2011^M
  -->^M
<Transaction>^M
  <TransactionID>^M
1030104^M
  </TransactionID>^M
  <LineItemDetail>^M
    <TransactionLineNumber>^M
1^M
    </TransactionLineNumber>^M
    <StoreID>^M
625^M
    </StoreID>^M
    <ScanType>^M
2^M
    </ScanType>^M
    <PLUID>^M
21155269^M
    </PLUID>^M
  </LineItemDetail>^M
</Transaction>^M
<Transaction>^M
  <TransactionID>^M
1030105^M
  </TransactionID>^M
  <LineItemDetail>^M
    <TransactionLineNumber>^M
1^M
    </TransactionLineNumber>^M
    <StoreID>^M
626^M
    </StoreID>^M
    <ScanType>^M
1^M
    </ScanType>^M
    <PLUID>^M
21155270^M
    </PLUID>^M
  </LineItemDetail>^M
</Transaction>^M
Mac4rfree
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Not sure what you mean "unable to route it as output"...do you mean on an output link to a downstream stage? If so, just have a single column like "myXMLdocument" on the output link, with a long varchar as datatype and a single '/' in the Description property.

As for the formatting....unselect any/all formatting so that it goes out as a big long string...then open it in IE or other tool that knows XML.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You get ^M characters on UNIX when you create a DOS output file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply